From cf98b3beabbb2dd360657f2afcbde90f514c80c3 Mon Sep 17 00:00:00 2001 From: sbh Date: Wed, 16 Jul 2014 18:13:11 +0400 Subject: [PATCH] Unit test example added --- CMakeLists.txt | 3 +++ buildNewGEOM_deb.bat | 2 +- buildNewGEOM_eclipse.bat | 2 +- msvc10_env.bat | 3 ++- src/ConstructionPlugin/CMakeLists.txt | 4 ++++ src/ConstructionPlugin/Test/CMakeLists.txt | 5 +++++ src/ConstructionPlugin/Test/test_point_name.py | 11 +++++++++++ 7 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/ConstructionPlugin/Test/CMakeLists.txt create mode 100644 src/ConstructionPlugin/Test/test_point_name.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a276cea1..7b6d98c3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,6 @@ ADD_SUBDIRECTORY (src/GeomApp) IF(${HAVE_SALOME}) ADD_SUBDIRECTORY (src/NewGeom) ENDIF(${HAVE_SALOME}) + +FIND_PACKAGE(PythonInterp REQUIRED) +ENABLE_TESTING() diff --git a/buildNewGEOM_deb.bat b/buildNewGEOM_deb.bat index 1b4ddccf0..775608596 100644 --- a/buildNewGEOM_deb.bat +++ b/buildNewGEOM_deb.bat @@ -14,6 +14,6 @@ call %SRC_DIR%\msvc10_env.bat mkdir %ROOT_DIR%\build cd %ROOT_DIR%\build -cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install +cmake %SRC_DIR% -G "Visual Studio 10" -DPYTHON_EXECUTABLE=%PYTHONHOME%\python_d.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install start "" %MSVC_EXE% NewGEOM.sln diff --git a/buildNewGEOM_eclipse.bat b/buildNewGEOM_eclipse.bat index b5fa7c131..aa255f28f 100644 --- a/buildNewGEOM_eclipse.bat +++ b/buildNewGEOM_eclipse.bat @@ -20,10 +20,10 @@ cd %ROOT_DIR%\build-eclipse @SET CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_BUILD_TYPE=Debug @SET CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=ON @SET CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install +@SET CMAKE_ARGS=%CMAKE_ARGS% -DPYTHON_EXECUTABLE=%PYTHONHOME%\python_d.exe @SET CMAKE_ARGS=%CMAKE_ARGS% %SRC_DIR% cmake %CMAKE_ARGS% -pause @REM Should be defined at ..\local_env.bat start %ECLIPSE_EXE% diff --git a/msvc10_env.bat b/msvc10_env.bat index 1d2233ce4..ab394bec9 100644 --- a/msvc10_env.bat +++ b/msvc10_env.bat @@ -132,7 +132,8 @@ set PATH=%CMAKEDIR%\bin;%PATH% @REM ------------------------- @SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins -@SET PATH=%ROOT_DIR%\install\plugins;%PATH% +@SET PATH=%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH% +@SET PYTHONPATH=%ROOT_DIR%\install\swig;%PYTHONPATH% @REM ------------------------- if "%GUI_ROOT_DIR%" == "" ( diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index 1c81b62aa..13091e348 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -26,5 +26,9 @@ SET(XML_RESOURCES point_widget.xml ) +ADD_SUBDIRECTORY(Test) + INSTALL(TARGETS ConstructionPlugin DESTINATION plugins) INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) + +ENABLE_TESTING() diff --git a/src/ConstructionPlugin/Test/CMakeLists.txt b/src/ConstructionPlugin/Test/CMakeLists.txt new file mode 100644 index 000000000..36dd358f8 --- /dev/null +++ b/src/ConstructionPlugin/Test/CMakeLists.txt @@ -0,0 +1,5 @@ +INCLUDE(Common) + +ENABLE_TESTING() +ADD_TEST(ConstructionPluginTest + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_point_name.py) diff --git a/src/ConstructionPlugin/Test/test_point_name.py b/src/ConstructionPlugin/Test/test_point_name.py new file mode 100644 index 000000000..06e70e64f --- /dev/null +++ b/src/ConstructionPlugin/Test/test_point_name.py @@ -0,0 +1,11 @@ +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) -- 2.39.2