[TechDraw] Make image test a unittest
This commit is contained in:
committed by
WandererFan
parent
4fc8596d7b
commit
a1dfe2465f
@@ -143,8 +143,8 @@ SET(TDTest_SRCS
|
||||
TDTest/__init__.py
|
||||
TDTest/DrawHatchTest.py
|
||||
TDTest/DProjGroupTest.py
|
||||
TDTest/DVAnnoSymImageTest.py
|
||||
TDTest/DrawViewAnnotationTest.py
|
||||
TDTest/DrawViewImageTest.py
|
||||
TDTest/DrawViewSymbolTest.py
|
||||
TDTest/DVDimensionTest.py
|
||||
TDTest/DVPartTest.py
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# annotation & symbol test script for TechDraw module
|
||||
# creates a page, 1 annotation and import 1 symbol
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import os
|
||||
|
||||
|
||||
def DVAnnoSymImageTest():
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
print("TDTestAnno path: " + path)
|
||||
templateFileSpec = path + "/TestTemplate.svg"
|
||||
imageFileSpec = path + "/TestImage.png"
|
||||
|
||||
FreeCAD.newDocument("TDAnno")
|
||||
FreeCAD.setActiveDocument("TDAnno")
|
||||
FreeCAD.ActiveDocument = FreeCAD.getDocument("TDAnno")
|
||||
|
||||
page = FreeCAD.ActiveDocument.addObject("TechDraw::DrawPage", "Page")
|
||||
FreeCAD.ActiveDocument.addObject("TechDraw::DrawSVGTemplate", "Template")
|
||||
FreeCAD.ActiveDocument.Template.Template = templateFileSpec
|
||||
FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
|
||||
# page.ViewObject.show() # unit tests run in console mode
|
||||
|
||||
# image
|
||||
img = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewImage", "TestImage")
|
||||
img.ImageFile = imageFileSpec
|
||||
page.addView(img)
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
rc = False
|
||||
if "Up-to-date" in img.State:
|
||||
rc = True
|
||||
|
||||
FreeCAD.closeDocument("TDAnno")
|
||||
return rc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
DVAnnoSymImageTest()
|
||||
34
src/Mod/TechDraw/TDTest/DrawViewImageTest.py
Normal file
34
src/Mod/TechDraw/TDTest/DrawViewImageTest.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import os
|
||||
import unittest
|
||||
from .TechDrawTestUtilities import createPageWithSVGTemplate
|
||||
|
||||
|
||||
class DrawViewImageTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Creates a page"""
|
||||
FreeCAD.newDocument("TDAnno")
|
||||
FreeCAD.setActiveDocument("TDAnno")
|
||||
FreeCAD.ActiveDocument = FreeCAD.getDocument("TDAnno")
|
||||
self.page = createPageWithSVGTemplate()
|
||||
|
||||
def tearDown(self):
|
||||
FreeCAD.closeDocument("TDAnno")
|
||||
|
||||
def testMakeImage(self):
|
||||
"""Tests if an image can be added to page"""
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
imageFileSpec = path + "/TestImage.png"
|
||||
img = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewImage", "TestImage")
|
||||
img.ImageFile = imageFileSpec
|
||||
self.page.addView(img)
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
self.assertTrue("Up-to-date" in img.State)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -24,9 +24,9 @@ import unittest
|
||||
|
||||
from TDTest.DrawHatchTest import DrawHatchTest # noqa: F401
|
||||
from TDTest.DrawViewAnnotationTest import DrawViewAnnotationTest # noqa: F401
|
||||
from TDTest.DrawViewSymbolTest import DrawViewSymbolTest
|
||||
from TDTest.DrawViewImageTest import DrawViewImageTest # noqa: F401
|
||||
from TDTest.DrawViewSymbolTest import DrawViewSymbolTest # noqa: F401
|
||||
from TDTest.DProjGroupTest import DProjGroupTest
|
||||
from TDTest.DVAnnoSymImageTest import DVAnnoSymImageTest
|
||||
from TDTest.DVDimensionTest import DVDimensionTest
|
||||
from TDTest.DVPartTest import DVPartTest
|
||||
from TDTest.DVSectionTest import DVSectionTest
|
||||
@@ -46,14 +46,6 @@ class TechDrawTestCases(unittest.TestCase):
|
||||
else:
|
||||
print("TD DrawViewPart test failed")
|
||||
|
||||
def testAnnoSymImageCase(self):
|
||||
print("starting TD DrawAnno/Sym/Image test")
|
||||
rc = DVAnnoSymImageTest()
|
||||
if rc:
|
||||
print("TD DrawAnno/Sym/Image test passed")
|
||||
else:
|
||||
print("TD DrawAnno/Sym/Image test failed")
|
||||
|
||||
def testProjGroupCase(self):
|
||||
print("starting TD DrawProjGroup test")
|
||||
rc = DProjGroupTest()
|
||||
|
||||
Reference in New Issue
Block a user