From: spo Date: Fri, 17 Jun 2016 14:53:44 +0000 (+0300) Subject: Remove GTest tests for C++ High API X-Git-Tag: V_2.4.0~91^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e65b7fca26ceb08079c59080c86bf6c8485338ce;p=modules%2Fshaper.git Remove GTest tests for C++ High API --- diff --git a/CMakeCommon/GTest.cmake b/CMakeCommon/GTest.cmake deleted file mode 100644 index 13c245511..000000000 --- a/CMakeCommon/GTest.cmake +++ /dev/null @@ -1,24 +0,0 @@ -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -cmake_minimum_required (VERSION 2.6) - -include(FindGTest) - - -#FIND_PACKAGE(GTest REQUIRED) -#INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) - -#FIND_PACKAGE(GMock REQUIRED) -#INCLUDE_DIRECTORIES(${GMOCK_INCLUDE_DIRS}) - - -# GCC 4.4.6 does not support some C++11 features used by GMock -add_definitions(-DGTEST_LANG_CXX11=0) - -include_directories( - $ENV{GTEST_ROOT}/googletest/include - $ENV{GTEST_ROOT}/googlemock/include -) - -set(GTEST_LIBRARY $ENV{GTEST_ROOT}/googlemock/make/gmock_main.a) - \ No newline at end of file diff --git a/src/ConstructionAPI/CMakeLists.txt b/src/ConstructionAPI/CMakeLists.txt index 2dcb3b5a9..67cad0d49 100644 --- a/src/ConstructionAPI/CMakeLists.txt +++ b/src/ConstructionAPI/CMakeLists.txt @@ -79,5 +79,3 @@ INCLUDE(UnitTest) ADD_UNIT_TESTS( TestPoint.py ) - -# ADD_SUBDIRECTORY (Test) diff --git a/src/ConstructionAPI/Test/CMakeLists.txt b/src/ConstructionAPI/Test/CMakeLists.txt deleted file mode 100644 index b04b43d26..000000000 --- a/src/ConstructionAPI/Test/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -include(GTest) - -set(PROJECT_SOURCES - TestPoint.cpp -) - -include_directories( - ${PROJECT_SOURCE_DIR}/src/ConstructionAPI - ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/Mock -) - -set(PROJECT_LIBRARIES - ModelAPI - ModelHighAPI - ConstructionAPI -) - -set(PACKAGE_NAME "ConstructionAPI") -set(TARGET_NAME "Test${PACKAGE_NAME}") - -add_executable(${TARGET_NAME} ${PROJECT_SOURCES}) -target_link_libraries(${TARGET_NAME} ${PROJECT_LIBRARIES} ${GTEST_LIBRARY}) - -GTEST_ADD_TESTS(${CMAKE_BINARY_DIR}/bin/${TARGET_NAME} "" ${PROJECT_SOURCES}) diff --git a/src/ConstructionAPI/Test/TestPoint.cpp b/src/ConstructionAPI/Test/TestPoint.cpp deleted file mode 100644 index b053d5f6c..000000000 --- a/src/ConstructionAPI/Test/TestPoint.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRefOfCopy; -using ::testing::Test; - -// TODO(spo): should be common function -void null_deleter(void *) {} - -class ConstructionAPI_Point_Constructor_Test : public Test { -public: - MockEvents_Listener aErrorListener; - MockModelAPI_AttributeDouble aMockAttributeDouble; - MockModelAPI_Data aMockData; - MockModelAPI_Feature aMockFeature; - MockModelAPI_Document aMockDocument; - - ConstructionAPI_Point_Constructor_Test() { - ON_CALL(aMockDocument, addFeature(_, _)) - .WillByDefault(Return(std::shared_ptr(&aMockFeature, &null_deleter))); - - ON_CALL(aMockFeature, getKind()) - .WillByDefault(ReturnRefOfCopy(std::string("Point"))); - - ON_CALL(aMockFeature, data()) - .WillByDefault(Return(std::shared_ptr(&aMockData, &null_deleter))); - - ON_CALL(aMockData, real(_)) - .WillByDefault(Return(std::shared_ptr(&aMockAttributeDouble, &null_deleter))); - - Events_Loop::loop()->registerListener(&aErrorListener, Events_Error::errorID()); - } - - ~ConstructionAPI_Point_Constructor_Test() { - Events_Loop::loop()->removeListener(&aErrorListener); - } - - void testInitializeFeature() { - EXPECT_CALL(aMockFeature, getKind()); - - EXPECT_CALL(aMockFeature, data()) - .Times(3); - - EXPECT_CALL(aMockData, real("x")); - EXPECT_CALL(aMockData, real("y")); - EXPECT_CALL(aMockData, real("z")); - } - - void testSetAttributes() { - EXPECT_CALL(aMockAttributeDouble, setValue(10)); - EXPECT_CALL(aMockAttributeDouble, setText("20")); - EXPECT_CALL(aMockAttributeDouble, setText("x + 30")); - - EXPECT_CALL(aMockFeature, execute()); - } -}; - -TEST_F(ConstructionAPI_Point_Constructor_Test, GetEmptyFeature_SendException) { - FeaturePtr aFeature; - - EXPECT_CALL(aErrorListener, processEvent(_)); - - ConstructionAPI_Point aPoint(aFeature); -} - -TEST_F(ConstructionAPI_Point_Constructor_Test, GetEmptyFeatureAndValues_SendException) { - FeaturePtr aFeature; - - EXPECT_CALL(aErrorListener, processEvent(_)); - - ConstructionAPI_Point aPoint(aFeature, 10, "20", std::string("x + 30")); -} - -TEST_F(ConstructionAPI_Point_Constructor_Test, GetWrongFeature_SendException) { - FeaturePtr aFeature(&aMockFeature, &null_deleter); - - ON_CALL(aMockFeature, getKind()) - .WillByDefault(ReturnRefOfCopy(std::string("WrongKind"))); - - EXPECT_CALL(aMockFeature, getKind()); - EXPECT_CALL(aErrorListener, processEvent(_)); - - ConstructionAPI_Point aPoint(aFeature); -} - - -TEST_F(ConstructionAPI_Point_Constructor_Test, GetFeature) { - FeaturePtr aFeature(&aMockFeature, &null_deleter); - - testInitializeFeature(); - - ConstructionAPI_Point aPoint(aFeature); -} - -TEST_F(ConstructionAPI_Point_Constructor_Test, GetFeatureAndValues) { - FeaturePtr aFeature(&aMockFeature, &null_deleter); - - testInitializeFeature(); - testSetAttributes(); - - ConstructionAPI_Point aPoint(aFeature, 10, "20", std::string("x + 30")); -} - - -TEST_F(ConstructionAPI_Point_Constructor_Test, addPoint) { - DocumentPtr aDocument(&aMockDocument, &null_deleter); - - EXPECT_CALL(aMockDocument, addFeature("Point", true)); - - testInitializeFeature(); - testSetAttributes(); - - PointPtr aPoint = addPoint(aDocument, 10, "20", std::string("x + 30")); -} diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index ec80ab7cf..7b450e5c5 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -80,5 +80,3 @@ ADD_UNIT_TESTS( TestInteger.py TestRefAttr.py ) - -# ADD_SUBDIRECTORY (Test) diff --git a/src/ModelHighAPI/Test/CMakeLists.txt b/src/ModelHighAPI/Test/CMakeLists.txt deleted file mode 100644 index b99ca948e..000000000 --- a/src/ModelHighAPI/Test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -include(GTest) - -set(PROJECT_SOURCES - TestDouble.cpp - TestSelection.cpp -) - -include_directories( - ${PROJECT_SOURCE_DIR}/src/ModelHighAPI - ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/Mock -) - -set(PROJECT_LIBRARIES - ModelHighAPI -) - -set(PACKAGE_NAME "ModelHighAPI") -set(TARGET_NAME "Test${PACKAGE_NAME}") - -add_executable(${TARGET_NAME} ${PROJECT_SOURCES}) -target_link_libraries(${TARGET_NAME} ${PROJECT_LIBRARIES} ${GTEST_LIBRARY}) - -GTEST_ADD_TESTS(${CMAKE_BINARY_DIR}/bin/${TARGET_NAME} "" ${PROJECT_SOURCES}) diff --git a/src/ModelHighAPI/Test/TestDouble.cpp b/src/ModelHighAPI/Test/TestDouble.cpp deleted file mode 100644 index dcba7f35d..000000000 --- a/src/ModelHighAPI/Test/TestDouble.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#include - -#include - -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRefOfCopy; -using ::testing::Test; - -// TODO(spo): should be common function -static void null_deleter(void *) {} - -class HighModelAPI_Double_Test : public Test { -public: - MockModelAPI_AttributeDouble aMockAttributeDouble; - std::shared_ptr anAttributeDouble; - - HighModelAPI_Double_Test() { - anAttributeDouble = std::shared_ptr(&aMockAttributeDouble, &null_deleter); - } - - ~HighModelAPI_Double_Test() { - } -}; - -TEST_F(HighModelAPI_Double_Test, Default) { - ModelHighAPI_Double aValue; - - EXPECT_CALL(aMockAttributeDouble, setValue(0.)); - - aValue.fillAttribute(anAttributeDouble); -} - -TEST_F(HighModelAPI_Double_Test, Double) { - ModelHighAPI_Double aValue(100.5); - - EXPECT_CALL(aMockAttributeDouble, setValue(100.5)); - - aValue.fillAttribute(anAttributeDouble); -} - -TEST_F(HighModelAPI_Double_Test, Char) { - ModelHighAPI_Double aValue("20"); - - EXPECT_CALL(aMockAttributeDouble, setText("20")); - - aValue.fillAttribute(anAttributeDouble); -} - -TEST_F(HighModelAPI_Double_Test, String) { - ModelHighAPI_Double aValue(std::string("x + 30")); - - EXPECT_CALL(aMockAttributeDouble, setText("x + 30")); - - aValue.fillAttribute(anAttributeDouble); -} diff --git a/src/ModelHighAPI/Test/TestSelection.cpp b/src/ModelHighAPI/Test/TestSelection.cpp deleted file mode 100644 index 11ac67e59..000000000 --- a/src/ModelHighAPI/Test/TestSelection.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -#include - -#include - -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRefOfCopy; -using ::testing::Test; - -// TODO(spo): should be common function -static void null_deleter(void *) {} - -class HighModelAPI_Selection_Test : public Test { -public: - MockModelAPI_AttributeSelection aMockAttributeSelection; - std::shared_ptr anAttributeSelection; - - HighModelAPI_Selection_Test() { - anAttributeSelection = std::shared_ptr(&aMockAttributeSelection, &null_deleter); - } - - ~HighModelAPI_Selection_Test() { - } -}; - -TEST_F(HighModelAPI_Selection_Test, Default) { - ModelHighAPI_Selection aValue; - - EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false)); - - aValue.fillAttribute(anAttributeSelection); -} - -TEST_F(HighModelAPI_Selection_Test, ResultAndSubShape) { - std::shared_ptr aResult; - std::shared_ptr aShape; - ModelHighAPI_Selection aValue(aResult, aShape); - - EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false)); - - aValue.fillAttribute(anAttributeSelection); -} - -TEST_F(HighModelAPI_Selection_Test, TypeAndSubShapeName) { - ModelHighAPI_Selection aValue("Type", "SubShapeName"); - - EXPECT_CALL(aMockAttributeSelection, selectSubShape("Type", "SubShapeName")); - - aValue.fillAttribute(anAttributeSelection); -}