[TD]Add tests for geometry creation
- check that edge geometry count is correct - handle delay waiting for threads to complete - add test for DrawViewDetail
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
|
||||
# basic test script for TechDraw module
|
||||
# creates a page and 1 view
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import unittest
|
||||
from .TechDrawTestUtilities import createPageWithSVGTemplate
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
class DrawViewPartTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -21,19 +22,33 @@ class DrawViewPartTest(unittest.TestCase):
|
||||
self.page = createPageWithSVGTemplate()
|
||||
self.page.Scale = 5.0
|
||||
# page.ViewObject.show() # unit tests run in console mode
|
||||
print("page created")
|
||||
print("DrawViewPart test: page created")
|
||||
|
||||
def tearDown(self):
|
||||
print("DrawViewPart test finished")
|
||||
FreeCAD.closeDocument("TDPart")
|
||||
|
||||
def testMakeDrawViewPart(self):
|
||||
"""Tests if a view can be added to page"""
|
||||
print("testing DrawViewPart")
|
||||
view = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewPart", "View")
|
||||
self.page.addView(view)
|
||||
FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
self.assertTrue("Up-to-date" in view.State)
|
||||
|
||||
#wait for threads to complete before checking result
|
||||
loop = QtCore.QEventLoop()
|
||||
|
||||
timer = QtCore.QTimer()
|
||||
timer.setSingleShot(True)
|
||||
timer.timeout.connect(loop.quit)
|
||||
|
||||
timer.start(2000) #2 second delay
|
||||
loop.exec_()
|
||||
|
||||
edges = view.getVisibleEdges()
|
||||
self.assertEqual(len(edges), 4, "DrawViewPart has wrong number of edges")
|
||||
self.assertTrue("Up-to-date" in view.State, "DrawViewPart is not Up-to-date")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user