Salome HOME
Some minor changes in tests. Now the initialization plugin performs correctly in...
authormpv <mpv@opencascade.com>
Fri, 20 May 2016 13:12:26 +0000 (16:12 +0300)
committermpv <mpv@opencascade.com>
Fri, 20 May 2016 13:12:26 +0000 (16:12 +0300)
src/ConstructionPlugin/Test/TestPointName.py
src/FeaturesPlugin/Test/TestGroup.py
src/Model/Model_AttributeIntArray.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_Session.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/TestResults.py [new file with mode: 0755]
src/ModelAPI/Test/TestUndoRedo.py
src/SketchPlugin/SketchPlugin_SketchEntity.cpp

index df76871f2d02cf6e0488d9e9df9c8fbbdea7a3f8..43a942db002cc648a1d7099ea4ae222ef731e8f2 100644 (file)
@@ -14,7 +14,8 @@ aFeatureName = aFeature.name()
 aFeature.execute()
 aSession.finishOperation()
 
-aFeature1 = aDoc.object("Construction", 0)
+# with index "0" is Origin and then - all default constructions
+aFeature1 = aDoc.object("Construction", 7)
 aFeature1Name = aFeature1.data().name()
 
 assert (aFeatureName == aFeature1Name)
index 382c0241661560c7ab17f5abe7f3ff0d935d75f4..a2ca95ef1fe76a702c61531c304c3f75a00a2368 100644 (file)
@@ -238,6 +238,7 @@ assert(aSelectionListAttr.size() == 1)
 assert(len(aGroupFeature.results()) > 0)
 aGroupResult = aGroupFeature.firstResult()
 assert(aGroupResult)
+assert(aGroupResult.shape())
 #=========================================================================
 # End of test
 #=========================================================================
index b9cb85876640992a1a499fd2791519c6fd491087..c01107332b47d371c7d6f7678bafd0c2aa7ca4a6 100644 (file)
@@ -34,7 +34,7 @@ void Model_AttributeIntArray::setSize(const int theSize)
 {
   if (myArray.IsNull() || !myArray->IsValid()) { // create array if it is not done yet
     if (theSize != 0) { // if size is zero, nothing to do (null array means there is no array)
-      myArray = TDataStd_IntegerArray::Set(myLab, 0, theSize);
+      myArray = TDataStd_IntegerArray::Set(myLab, 0, theSize - 1);
       owner()->data()->sendAttributeUpdated(this);
     }
   } else { // reset the old array
index f84c169b2ca90b6e44937d9dee24920f7a01cbf1..2d025aa88d1b1402f2d7d1f28f677072a7a125c0 100755 (executable)
@@ -8,7 +8,6 @@
 
 #include <Model_Data.h>
 #include <Model_Document.h>
-#include <ModelAPI_AttributeIntArray.h>
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Iterator.hxx>
index 4525cbf4a85c9f64a64616f04c5e4e14f339d471..886bfec9f304b3cdeda9ba47a89d2601dc7c6fad 100644 (file)
@@ -189,6 +189,8 @@ std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
   Handle(Model_Application) anApp = Model_Application::getApplication();
   bool aFirstCall = !anApp->hasRoot();
   if (aFirstCall) {
+    // to be sure that plugins are loaded, even before the first "createFeature" call (in unit tests)
+    LoadPluginsInfo();
     // creation of the root document is always outside of the transaction, so, avoid checking it
     setCheckTransactions(false);
     anApp->createDocument(0); // 0 is a root ID
index fb4db8b550eb191cf4f1048d788f4bba1e1af3e9..90006d1d04dbab4720545aea427eb0b50fe8d9ac 100644 (file)
@@ -127,4 +127,5 @@ INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
 ADD_UNIT_TESTS(TestConstants.py
                TestUndoRedo.py
                TestDocument.py
-               Test1064.py)
+               Test1064.py
+               TestResults.py)
diff --git a/src/ModelAPI/Test/TestResults.py b/src/ModelAPI/Test/TestResults.py
new file mode 100755 (executable)
index 0000000..7ba9cb5
--- /dev/null
@@ -0,0 +1,36 @@
+"""
+      TestResults.py
+      Cover specific working with the data model results
+
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+
+__updated__ = "2016-20-16"
+
+aSession = ModelAPI_Session.get()
+
+#=========================================================================
+# Check getting the initial construction plane by name
+#=========================================================================
+aPartSet = aSession.moduleDocument()
+aSession.startOperation()
+aPlaneX = aPartSet.objectByName("Construction", "YOZ");
+assert(aPlaneX)
+aColors = aPlaneX.data().intArray("Color")
+assert(aColors)
+# default colors, not filled array
+assert(aColors.size() == 0)
+aColors.setSize(3)
+aColors.setValue(0, 100)
+aColors.setValue(1, 200)
+aColors.setValue(2, 250)
+assert(aColors.size() == 3)
+assert(aColors.value(0) == 100)
+assert(aColors.value(1) == 200)
+assert(aColors.value(2) == 250)
+
+aSession.finishOperation()
+
index 26f54acb57863f07827cc21a36449d08221d9668..1df119f97c26d77e4162708edad5e582ba9892e3 100644 (file)
@@ -12,21 +12,22 @@ aFeature.real("x").setValue(1.)
 aFeature.real("y").setValue(-1.)\r
 aFeature.real("z").setValue(0.)\r
 aFeatureName = aFeature.name()\r
-assert(aFeatureName == "Point_1")\r
+# "2" is because Origin is the first point\r
+assert(aFeatureName == "Point_2")\r
 \r
 aFeature.execute()\r
 aSession.finishOperation()\r
 \r
-assert(aDoc.size("Construction") == 1)\r
+assert(aDoc.size("Construction") == 8)\r
 assert(aSession.canUndo())\r
 assert(not aSession.canRedo())\r
 \r
 aSession.undo()\r
-assert(aDoc.size("Construction") == 0)\r
+assert(aDoc.size("Construction") == 7)\r
 assert(not aSession.canUndo())\r
 assert(aSession.canRedo())\r
 \r
 aSession.redo()\r
-assert(aDoc.size("Construction") == 1)\r
+assert(aDoc.size("Construction") == 8)\r
 assert(aSession.canUndo())\r
 assert(not aSession.canRedo())\r
index 3d26d3d9502fa50bcaec9e34919ea85de1999c6c..6b5beb942c7493884fbf9beb0863cafc382296ac 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_AttributeIntArray.h>
 
 SketchPlugin_SketchEntity::SketchPlugin_SketchEntity()
 : SketchPlugin_Feature()