From: mpv Date: Tue, 11 Dec 2018 12:36:06 +0000 (+0300) Subject: Added test for open/save document of the model session X-Git-Tag: End2018~78 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c96bffd906d920ec218762045d208d54834be7ba;p=modules%2Fshaper.git Added test for open/save document of the model session --- diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index ea2521010..3d3724794 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -55,7 +55,7 @@ static Model_Session* myImpl = new Model_Session(); -// t oredirect all calls to the root document +// to redirect all calls to the root document #define ROOT_DOC std::dynamic_pointer_cast(moduleDocument()) bool Model_Session::load(const char* theFileName) @@ -114,7 +114,7 @@ void Model_Session::abortOperation() myOperationAttachedToNext = false; } setCheckTransactions(true); - // here the update mechanism may work after abort, so, supress the warnings about + // here the update mechanism may work after abort, so, suppress the warnings about // modifications outside of the transactions bool aWasCheck = myCheckTransactions; myCheckTransactions = false; @@ -294,7 +294,7 @@ void Model_Session::setActiveDocument( std::shared_ptr aPrevious = myCurrentDoc; myCurrentDoc = theDoc; if (theDoc.get() && theSendSignal) { - // this must be before the synchronisation call because features in PartSet lower than this + // this must be before the synchronization call because features in PartSet lower than this // part feature must be disabled and don't recomputed anymore (issue 1156, // translation feature is failed on activation of Part 2) if (isOperation()) { // do it only in transaction, not on opening of document @@ -306,7 +306,7 @@ void Model_Session::setActiveDocument( } } } - // syncronize the document: it may be just opened or opened but removed before + // synchronize the document: it may be just opened or opened but removed before std::shared_ptr aDoc = std::dynamic_pointer_cast(theDoc); if (aDoc.get()) { bool aWasChecked = myCheckTransactions; @@ -320,7 +320,7 @@ void Model_Session::setActiveDocument( new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED))); Events_Loop::loop()->send(aMsg); } - // make the current state correct and synchronised in the module and sub-documents + // make the current state correct and synchronized in the module and sub-documents if (isOperation()) { // do it only in transaction, not on opening of document if (myCurrentDoc == moduleDocument()) { // make the current feature the latest in root, in previous root current become also last @@ -619,7 +619,7 @@ void Model_Session::blockAutoUpdate(const bool theBlock) } if (!isOperation) { finishOperation(); - // append this transaction to the previous one: ne don't need this separated operation in list + // append this transaction to the previous one: don't need this separated operation in list ROOT_DOC->appendTransactionToPrevious(); } } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index ed4a75d73..22b949c54 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -232,4 +232,5 @@ ADD_UNIT_TESTS(TestConstants.py TestGeomNamingSketchPlane.py TestGeomNamingBoxWithFillet.py TestContainerSelector.py + TestSaveOpen.py ) diff --git a/src/ModelAPI/Test/TestSaveOpen.py b/src/ModelAPI/Test/TestSaveOpen.py new file mode 100644 index 000000000..5bc57a292 --- /dev/null +++ b/src/ModelAPI/Test/TestSaveOpen.py @@ -0,0 +1,50 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Point_2 = model.addPoint(partSet, 1, 2, 3) +Point_name = Point_2.name() +model.end() + +# check save document in a current folder +aSession = ModelAPI_Session.get() +aFiles = StringList() +aSession.save(".", aFiles) +assert(len(aFiles) == 1) + +# check open of the same document +assert(aSession.load(".") == False) # error because this document is already opened + +# close the current document +aSession.closeAll() + +# open again: it must be correct now +assert(aSession.load(".")) + +# check the created point is opened +partSet = model.moduleDocument() +assert(partSet.size("Features") == 1) +assert(partSet.object("Features", 0).data().name() == Point_name) diff --git a/src/Selector/Selector_NExplode.cpp b/src/Selector/Selector_NExplode.cpp index 98b3dd42e..33552c40d 100644 --- a/src/Selector/Selector_NExplode.cpp +++ b/src/Selector/Selector_NExplode.cpp @@ -107,6 +107,8 @@ bool CompareShapes::operator() (const TopoDS_Shape& theShape1, else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { // equal values possible on shapes such as two halves of a sphere and // a membrane inside the sphere +// LCOV_EXCL_START + // this part of code is taken from GEOM module, but can not reproduce in SHAPER Bnd_Box box1,box2; BRepBndLib::Add(theShape1, box1); if (!box1.IsVoid()) { @@ -126,7 +128,8 @@ bool CompareShapes::operator() (const TopoDS_Shape& theShape1, } } } - } else // compare adresses if shapes are geometrically equal +// LCOV_EXCL_START + } else // compare addresses if shapes are geometrically equal return theShape1.TShape().get() > theShape2.TShape().get(); }