X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FTest%2FTestUndoRedo.py;h=921701f555b5863207067c0630f39c358278a2de;hb=30e30f8e0387a716727a054ef5c586038ed86049;hp=74a1315cd9bc5b72ca61fbcf31ac5bf8467de6e2;hpb=0c3a8a03ec5405d00c23a1cf9f20185d979ece1d;p=modules%2Fshaper.git diff --git a/src/ModelAPI/Test/TestUndoRedo.py b/src/ModelAPI/Test/TestUndoRedo.py index 74a1315cd..921701f55 100644 --- a/src/ModelAPI/Test/TestUndoRedo.py +++ b/src/ModelAPI/Test/TestUndoRedo.py @@ -1,26 +1,54 @@ -from ModelAPI import * -plugin_manager = ModelAPI_PluginManager.get() -doc = plugin_manager.rootDocument() -assert(not doc.canUndo()) -assert(not doc.canRedo()) - -doc.startOperation() -feature = doc.addFeature("Point") -feature_name = feature.data().name() -assert(feature_name == "Point_1") - -feature.execute() -doc.finishOperation(); -assert(doc.size("Construction") == 1) -assert(doc.canUndo()) -assert(not doc.canRedo()) - -doc.undo() -assert(doc.size("Construction") == 0) -assert(not doc.canUndo()) -assert(doc.canRedo()) - -doc.redo() -assert(doc.size("Construction") == 1) -assert(doc.canUndo()) -assert(not doc.canRedo()) +# Copyright (C) 2014-2020 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 +# + +from ModelAPI import * +from GeomDataAPI import * + +aSession = ModelAPI_Session.get() +aDoc = aSession.moduleDocument() +assert(not aSession.canUndo()) +assert(not aSession.canRedo()) + +aSession.startOperation() +aFeature = aDoc.addFeature("Point") +geomDataAPI_Point(aFeature.attribute("point3d")).setValue(1., -1., 0.) +aFeature.string("creation_method").setValue("by_xyz") +aFeatureName = aFeature.name() +# "2" is because Origin is the first point +assert(aFeatureName == "Point_2") + +aFeature.execute() +aSession.finishOperation() + +assert(aDoc.size("Construction") == 8) +assert(aSession.canUndo()) +assert(not aSession.canRedo()) + +aSession.undo() +assert(aDoc.size("Construction") == 7) +assert(not aSession.canUndo()) +assert(aSession.canRedo()) + +aSession.redo() +assert(aDoc.size("Construction") == 8) +assert(aSession.canUndo()) +assert(not aSession.canRedo()) + +from salome.shaper import model +assert(model.checkPythonDump())