--- /dev/null
+#
+# NewGeom unit test system
+# How to use:
+# INCLUDE(UnitTest)
+# ...
+# ADD_UNIT_TESTS(TestUndoRedo.py
+# TestResultBody.py)
+# or
+# SET(PROJECT_UNIT_TESTS
+# TestUndoRedo.py
+# TestWhatever.py
+# )
+# ADD_UNIT_TESTS(${PROJECT_UNIT_TESTS})
+#
+# Where "TestUndoRedo.py" and "TestResultBody.py" are names
+# of python test scripts in the "./Test" directory.
+# This macro will add "Subproject_" as prefix and
+# remove ".py" for the test name automaticaly.
+#
+# Start building of the "RUN_TESTS" project in the Visual studio
+# or run "make test" on linux stations to start the testing procedure.
+#
+
+ENABLE_TESTING()
+
+MACRO(ADD_UNIT_TESTS)
+ foreach(eachFileName ${ARGN})
+ # Strip the ".py" suffix
+ GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE)
+
+ # Add "SubprojectName_" prefix
+ GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+ SET(aTestName "${aSubprojectName}_${aTestName}")
+
+ # Full path to the python test file beeing executed
+ SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/Test/${eachFileName}")
+ IF(EXISTS ${aTestFileName})
+ ADD_TEST(NAME ${aTestName}
+ COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName})
+ # Debug output...
+ #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}")
+ ELSE(EXISTS ${aTestFileName})
+ MESSAGE(WARNING "Can not find the test file: ${aTestFileName}")
+ ENDIF(EXISTS ${aTestFileName})
+ endforeach(eachFileName ${ARGN})
+ENDMACRO(ADD_UNIT_TESTS)
+
INCLUDE(Common)
+INCLUDE(UnitTest)
SET(PROJECT_HEADERS
ConstructionPlugin.h
INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
-ENABLE_TESTING()
-ADD_SUBDIRECTORY(Test)
+ADD_UNIT_TESTS(TestPointName.py
+ )
+++ /dev/null
-INCLUDE(Common)
-
-ENABLE_TESTING()
-ADD_TEST(ModelAPITest
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_point_name.py)
--- /dev/null
+from ModelAPI import *
+p = ModelAPI_PluginManager.get()
+f = p.rootDocument().addFeature("Point")
+f_name = f.data().name()
+f.execute()
+
+doc = p.rootDocument()
+f1 = doc.object("Construction", 0)
+f1_name = f1.data().name()
+
+assert (f_name == f1_name)
+++ /dev/null
-from ModelAPI import *
-p = ModelAPI_PluginManager.get()
-f = p.rootDocument().addFeature("Point")
-f_name = f.data().name()
-f.execute()
-
-doc = p.rootDocument()
-f1 = doc.object("Construction", 0)
-f1_name = f1.data().name()
-
-assert (f_name == f1_name)
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE(UnitTest)
SET(PROJECT_HEADERS
ModelAPI.h
INSTALL(TARGETS ModelAPI DESTINATION bin)
INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
-ENABLE_TESTING()
-ADD_SUBDIRECTORY(Test)
+ADD_UNIT_TESTS(TestUndoRedo.py
+ )
+++ /dev/null
-INCLUDE(Common)
-
-ENABLE_TESTING()
-ADD_TEST(ModelAPITest
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_undo.py)
--- /dev/null
+from ModelAPI import *\r
+plugin_manager = ModelAPI_PluginManager.get()\r
+doc = plugin_manager.rootDocument()\r
+assert(not doc.canUndo())\r
+assert(not doc.canRedo()) \r
+\r
+doc.startOperation()\r
+feature = doc.addFeature("Point")\r
+feature_name = feature.data().name()\r
+assert(feature_name == "Point_1")\r
+\r
+feature.execute()\r
+doc.finishOperation();\r
+assert(doc.size("Construction") == 1)\r
+assert(doc.canUndo())\r
+assert(not doc.canRedo()) \r
+\r
+doc.undo()\r
+assert(doc.size("Construction") == 0)\r
+assert(not doc.canUndo())\r
+assert(doc.canRedo())\r
+\r
+doc.redo()\r
+assert(doc.size("Construction") == 1)\r
+assert(doc.canUndo())\r
+assert(not doc.canRedo())\r
+++ /dev/null
-from ModelAPI import *\r
-plugin_manager = ModelAPI_PluginManager.get()\r
-doc = plugin_manager.rootDocument()\r
-assert(not doc.canUndo())\r
-assert(not doc.canRedo()) \r
-\r
-doc.startOperation()\r
-feature = doc.addFeature("Point")\r
-feature_name = feature.data().name()\r
-assert(feature_name == "Point_1")\r
-\r
-feature.execute()\r
-doc.finishOperation();\r
-assert(doc.size("Construction") == 1)\r
-assert(doc.canUndo())\r
-assert(not doc.canRedo()) \r
-\r
-doc.undo()\r
-assert(doc.size("Construction") == 0)\r
-assert(not doc.canUndo())\r
-assert(doc.canRedo())\r
-\r
-doc.redo()\r
-assert(doc.size("Construction") == 1)\r
-assert(doc.canUndo())\r
-assert(not doc.canRedo())\r