SET(_all_SCRIPTS
PlotCurve_Standalone.py
- plot_test.py
TestDesktop.py
)
)
SALOME_INSTALL_SCRIPTS("${_all_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON}/tests)
+# Needed for the PlotCurve_standalone.py script
SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/mockup/SalomePyQt_MockUp.py ${SALOME_INSTALL_SCRIPT_PYTHON}/tests)
SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/mockup/SalomePyQt_MockUp.py ${SALOME_CURVEPLOT_INSTALL_PYTHON})
-
-INSTALL(DIRECTORY baselines DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}/tests)
-
+# For test purposes
SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${CMAKE_BINARY_DIR}/local) # point to local curveplot package in BUILD dir
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
-#ADD_TEST(CurvePlotUnitTests ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/plot_test.py)
-#SET_TESTS_PROPERTIES(CurvePlotUnitTests PROPERTIES ENVIRONMENT "${tests_env}")
+ADD_TEST(CurvePlotUnitTests ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/plot_test.py)
+SET_TESTS_PROPERTIES(CurvePlotUnitTests PROPERTIES ENVIRONMENT "${tests_env}")
-# For test purposes
FILE(COPY ${_test_SCRIPTS} DESTINATION ${CRVPLOT_TEST_INSTALL})
FILE(COPY baselines DESTINATION ${CRVPLOT_TEST_INSTALL})
self.tmpDir = None
# Minimal UI setup:
- self.app = QApplication(sys.argv)
- desktop = TestDesktop(None)
- self.sgPyQt = SalomePyQt(desktop)
- desktop._sgPyQt = self.sgPyQt
- desktop.initialize()
+ self.app = QApplication.instance()
+ if self.app is None:
+ self.app = QApplication(sys.argv)
+
+ self.desktop = TestDesktop(None)
+ self.sgPyQt = SalomePyQt(self.desktop)
+ self.desktop._sgPyQt = self.sgPyQt
+ self.desktop.initialize()
self.plotController = PlotController.GetInstance(self.sgPyQt)
- desktop.resize(800, 600)
- desktop.show()
+ self.desktop.resize(800, 600)
+ self.desktop.show()
self._execQtWasCalled = False # Used to automatically finish Qt execution loop on tests not doing a screenshot
# Reset some class var to make sure IDs appearing in screenshots do not depend on test seq order:
def _execQt(self, withShot=False):
if withShot:
QTimer.singleShot(50, self._shotEvent) # take picture
- QTimer.singleShot(200, self.app.quit) # quit
- self.app.exec_() # will hang till quit is fired
+ QTimer.singleShot(200, self._appQuit) # quit
+ self.app.exit(self.app.exec()) # will hang till quit is fired
# Important make sure previous app is properly killed before launching next test!
# Qt doesn't like multiple running instance
self._execQt(withShot=True)
return self.retValue
+ def _appQuit(self):
+ self.desktop.destroy()
+ self.app.quit()
+
def _shotEvent(self):
self.retValue = self._snapAndCompare(self.saveW)
self.qpixmap = QPixmap(widget.size())
widget.repaint()
widget.render(self.qpixmap)
- #self.qpixmap = widget.grab()
+ self.qpixmap = widget.grab()
# Nothing to compare if rebuilding base lines, just saving file:
if self.REBUILD_BASELINES:
gen_path = self.saveCurrentPix(self.tmpDir, suffix)
base_ref = os.path.join(self._this_dir, self.__BASE_LINE_DIR, self.getTestName() + suffix)
+
ret = False
- for ref_path in glob.glob("%s_*.%s" % (base_ref, self.__FORMAT)):
+ for ref_path in glob.glob("%s.%s" % (base_ref, self.__FORMAT)):
try:
ret = filecmp.cmp(ref_path, gen_path, shallow=False)
if ret:
# Author : A. Bruneton
#
from curveplot import *
-from curveplot.PlotTestBase import PlotTestBase, processDecorator
+from curveplot.PlotTestBase import PlotTestBase, processDecorator, runOnly
from curveplot.PlotSettings import PlotSettings
from pyqtside.QtWidgets import QApplication
import sys
-qapp = QApplication(sys.argv)
class PlotTest(PlotTestBase):
""" Unit test suite for the curve plotter. The tests themselves are stored in this class,
#
# GUI tests
#
+ #
+
def testAddCurve(self):
x, y = self.generateSine()
tw = self.showTabWidget()
x, y = self.generateSine()
crvID, psID = PlotController.AddCurve(x, y, append=False)
PlotController.SetCurrentCurve(crvID)
- _, crvID2 = PlotController.AddCurve(x, y, append=False) # in a new plot set
+ crvID2, _ = PlotController.AddCurve(x, y, append=False) # in a new plot set
PlotController.SetCurrentCurve(crvID2)
# on first plot set curve should not be selected anymore
PlotController.SetCurrentPlotSet(psID)
x, y = self.generateExp()
crvId, _ = PlotController.AddCurve(x, y)
PlotController.RegisterCallback(fun)
- PlotController.SetCurrentCurve(crvId)
+ PlotController.SetCurrentCurve(crvId) # callback is be called
self.assertEqual(crvId, a_callb)
def testDeleteCallback(self):
- global a_callb
- a_callb = 0
def fun(crv_id):
global a_callb
- a_callb = crv_id
+ a_callb = 0
self.showTabWidget()
x, y = self.generateExp()
crvId, _ = PlotController.AddCurve(x, y)
+ global a_callb
+ a_callb = crvId
PlotController.RegisterCallback(fun)
PlotController.ClearCallbacks()
- PlotController.SetCurrentCurve(crvId)
+ PlotController.SetCurrentCurve(crvId) # callback won't be called
_, _ = PlotController.AddCurve(x, y)
self.assertEqual(crvId, a_callb)
self.assertEqual(psID0, psID2)
l, _ = PlotController.GetAllPlotSets()
self.assertEqual(1, len(l))
-
+
# Even if not in main:
processDecorator(__name__)