From d216999a1c5ae75292f92991c7f377dd0f1f5f04 Mon Sep 17 00:00:00 2001 From: Sergey BELASH Date: Thu, 17 Jul 2014 19:16:51 +0400 Subject: [PATCH] Ability to switch test coverage test ON/OFF added (OFF by default) --- CMakeLists.txt | 4 ++-- eclipse.sh | 1 + src/ConstructionPlugin/CMakeLists.txt | 3 +-- src/ConstructionPlugin/Test/CMakeLists.txt | 2 +- src/ModelAPI/CMakeLists.txt | 3 +++ src/ModelAPI/Test/CMakeLists.txt | 5 +++++ src/ModelAPI/Test/test_undo.py | 26 ++++++++++++++++++++++ 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/ModelAPI/Test/CMakeLists.txt create mode 100644 src/ModelAPI/Test/test_undo.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cfd58728..496b3f5f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ IF(UNIX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") #Supporting test coverage checks (gcov) in the DEBUG mode - IF(CMAKE_BUILD_TYPE MATCHES Debug) + IF(USE_TEST_COVERAGE) INCLUDE(CodeCoverage) MESSAGE(STATUS "Setting flags for gcov support the the gcc...") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") @@ -29,7 +29,7 @@ IF(UNIX) SETUP_TARGET_FOR_COVERAGE(test_coverage # Name for custom target. ctest # Name of the test driver executable that runs the tests. coverage) # Name of output directory. - ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + ENDIF(USE_TEST_COVERAGE) #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E") MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS}) diff --git a/eclipse.sh b/eclipse.sh index 0dddf7dec..27f21f7db 100755 --- a/eclipse.sh +++ b/eclipse.sh @@ -14,6 +14,7 @@ CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Debug" CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=ON" CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${ROOT_DIR}/install" CMAKE_ARGS="${CMAKE_ARGS} -DPYTHON_EXECUTABLE=${PYTHONHOME}/bin/python" +CMAKE_ARGS="${CMAKE_ARGS} -DUSE_TEST_COVERAGE=OFF" CMAKE_ARGS="${CMAKE_ARGS} ${SRC_DIR}" cmake -G "Eclipse CDT4 - Unix Makefiles" ${CMAKE_ARGS} diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index 13091e348..3b4970095 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -26,9 +26,8 @@ SET(XML_RESOURCES point_widget.xml ) -ADD_SUBDIRECTORY(Test) - INSTALL(TARGETS ConstructionPlugin DESTINATION plugins) INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) ENABLE_TESTING() +ADD_SUBDIRECTORY(Test) diff --git a/src/ConstructionPlugin/Test/CMakeLists.txt b/src/ConstructionPlugin/Test/CMakeLists.txt index 36dd358f8..2fbb8fca7 100644 --- a/src/ConstructionPlugin/Test/CMakeLists.txt +++ b/src/ConstructionPlugin/Test/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE(Common) ENABLE_TESTING() -ADD_TEST(ConstructionPluginTest +ADD_TEST(ModelAPITest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_point_name.py) diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index a79ea6a88..883288049 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -72,3 +72,6 @@ ENDIF(WIN32) INSTALL(TARGETS _ModelAPI DESTINATION swig) INSTALL(TARGETS ModelAPI DESTINATION bin) INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig) + +ENABLE_TESTING() +ADD_SUBDIRECTORY(Test) diff --git a/src/ModelAPI/Test/CMakeLists.txt b/src/ModelAPI/Test/CMakeLists.txt new file mode 100644 index 000000000..bbab60ee9 --- /dev/null +++ b/src/ModelAPI/Test/CMakeLists.txt @@ -0,0 +1,5 @@ +INCLUDE(Common) + +ENABLE_TESTING() +ADD_TEST(ModelAPITest + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_undo.py) diff --git a/src/ModelAPI/Test/test_undo.py b/src/ModelAPI/Test/test_undo.py new file mode 100644 index 000000000..74a1315cd --- /dev/null +++ b/src/ModelAPI/Test/test_undo.py @@ -0,0 +1,26 @@ +from ModelAPI import * +plugin_manager = ModelAPI_PluginManager.get() +doc = plugin_manager.rootDocument() +assert(not doc.canUndo()) +assert(not doc.canRedo()) + +doc.startOperation() +feature = doc.addFeature("Point") +feature_name = feature.data().name() +assert(feature_name == "Point_1") + +feature.execute() +doc.finishOperation(); +assert(doc.size("Construction") == 1) +assert(doc.canUndo()) +assert(not doc.canRedo()) + +doc.undo() +assert(doc.size("Construction") == 0) +assert(not doc.canUndo()) +assert(doc.canRedo()) + +doc.redo() +assert(doc.size("Construction") == 1) +assert(doc.canUndo()) +assert(not doc.canRedo()) -- 2.39.2