X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModelAPI%2FTest%2FTestUndoRedo.py;h=9e3216c945728ffb40623101774ff09d64232a04;hb=97917d3698f5a2f7fc9596e7c755ff8f6751e373;hp=26f54acb57863f07827cc21a36449d08221d9668;hpb=758a57d77b6fa3a0485fa3378a1280c7e87a74aa;p=modules%2Fshaper.git diff --git a/src/ModelAPI/Test/TestUndoRedo.py b/src/ModelAPI/Test/TestUndoRedo.py index 26f54acb5..9e3216c94 100644 --- a/src/ModelAPI/Test/TestUndoRedo.py +++ b/src/ModelAPI/Test/TestUndoRedo.py @@ -1,32 +1,54 @@ -from ModelAPI import * -aSession = ModelAPI_Session.get() -aDoc = aSession.moduleDocument() -assert(not aSession.canUndo()) -assert(not aSession.canRedo()) - -aSession.startOperation() -aFeature = aDoc.addFeature("Point") -# Since validators are introduced we have to initialize all -# the feature's attributes -aFeature.real("x").setValue(1.) -aFeature.real("y").setValue(-1.) -aFeature.real("z").setValue(0.) -aFeatureName = aFeature.name() -assert(aFeatureName == "Point_1") - -aFeature.execute() -aSession.finishOperation() - -assert(aDoc.size("Construction") == 1) -assert(aSession.canUndo()) -assert(not aSession.canRedo()) - -aSession.undo() -assert(aDoc.size("Construction") == 0) -assert(not aSession.canUndo()) -assert(aSession.canRedo()) - -aSession.redo() -assert(aDoc.size("Construction") == 1) -assert(aSession.canUndo()) -assert(not aSession.canRedo()) +# Copyright (C) 2014-2019 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())