[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:
wandererfan
2022-11-20 17:00:08 -05:00
committed by WandererFan
parent cd3960f456
commit 894f6408a4
5 changed files with 127 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
import FreeCAD
import unittest
from .TechDrawTestUtilities import createPageWithSVGTemplate
from PySide import QtCore
class DrawViewSectionTest(unittest.TestCase):
def setUp(self):
@@ -15,7 +15,7 @@ class DrawViewSectionTest(unittest.TestCase):
self.page = createPageWithSVGTemplate()
self.page.Scale = 5.0
# page.ViewObject.show() # unit tests run in console mode
print("page created")
print("DrawViewSection test: page created")
self.view = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewPart", "View")
self.page.addView(self.view)
@@ -24,9 +24,22 @@ class DrawViewSectionTest(unittest.TestCase):
self.view.Rotation = 0.0
self.view.X = 30.0
self.view.Y = 150.0
print("view created")
FreeCAD.ActiveDocument.recompute()
#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_()
print("DrawViewSection test: view created")
def tearDown(self):
print("DrawViewSection test: finished")
FreeCAD.closeDocument("TDSection")
def testMakeDrawViewSection(self):
@@ -40,10 +53,21 @@ class DrawViewSectionTest(unittest.TestCase):
section.Direction = (0.0, 1.0, 0.0)
section.SectionNormal = (0.0, 1.0, 0.0)
section.SectionOrigin = (5.0, 5.0, 5.0)
self.view.touch()
print("section created")
print("DrawViewSection test: section created")
FreeCAD.ActiveDocument.recompute()
#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 = section.getVisibleEdges()
self.assertEqual(len(edges), 4, "DrawViewSection has wrong number of edges")
self.assertTrue("Up-to-date" in section.State)