Salome HOME
11ac67e5941da4f9e0ec64349f1ea8c56e5acbbe
[modules/shaper.git] / src / ModelHighAPI / Test / TestSelection.cpp
1 #include <gtest/gtest.h>
2 #include <gmock/gmock.h>
3
4 #include <ModelHighAPI_Selection.h>
5
6 #include <MockModelAPI_AttributeSelection.h>
7
8 using ::testing::_;
9 using ::testing::Return;
10 using ::testing::ReturnRefOfCopy;
11 using ::testing::Test;
12
13 // TODO(spo): should be common function
14 static void null_deleter(void *) {}
15
16 class HighModelAPI_Selection_Test : public Test {
17 public:
18   MockModelAPI_AttributeSelection aMockAttributeSelection;
19   std::shared_ptr<ModelAPI_AttributeSelection> anAttributeSelection;
20
21   HighModelAPI_Selection_Test() {
22     anAttributeSelection = std::shared_ptr<ModelAPI_AttributeSelection>(&aMockAttributeSelection, &null_deleter);
23   }
24
25   ~HighModelAPI_Selection_Test() {
26   }
27 };
28
29 TEST_F(HighModelAPI_Selection_Test, Default) {
30   ModelHighAPI_Selection aValue;
31
32   EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false));
33
34   aValue.fillAttribute(anAttributeSelection);
35 }
36
37 TEST_F(HighModelAPI_Selection_Test, ResultAndSubShape) {
38   std::shared_ptr<ModelAPI_Result> aResult;
39   std::shared_ptr<GeomAPI_Shape> aShape;
40   ModelHighAPI_Selection aValue(aResult, aShape);
41
42   EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false));
43
44   aValue.fillAttribute(anAttributeSelection);
45 }
46
47 TEST_F(HighModelAPI_Selection_Test, TypeAndSubShapeName) {
48   ModelHighAPI_Selection aValue("Type", "SubShapeName");
49
50   EXPECT_CALL(aMockAttributeSelection, selectSubShape("Type", "SubShapeName"));
51
52   aValue.fillAttribute(anAttributeSelection);
53 }