X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestConstraintLength.py;h=ac1345d4dfb1c7a381ce3f4cf23e027bc8d4d695;hb=cfe4bcc5b3ebf08f0f4f36a0df4067728f1a080a;hp=87a388a65021fb5eaf48bd593810e67ceafbe5ab;hpb=f60865d3a392bb23530a2f59532c4701d318e0d6;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestConstraintLength.py b/src/SketchPlugin/Test/TestConstraintLength.py index 87a388a65..ac1345d4d 100644 --- a/src/SketchPlugin/Test/TestConstraintLength.py +++ b/src/SketchPlugin/Test/TestConstraintLength.py @@ -11,6 +11,9 @@ """ from GeomDataAPI import * from ModelAPI import * +import math +from salome.shaper import model + #========================================================================= # Initialization of the test #========================================================================= @@ -42,6 +45,7 @@ aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint")) aLineAStartPoint.setValue(0., 25.) aLineAEndPoint.setValue(100., 25.) aSession.finishOperation() +assert (model.dof(aSketchFeature) == 4) #========================================================================= # Make a constraint to keep the length #========================================================================= @@ -60,6 +64,7 @@ aLengthConstraint.execute() aSession.finishOperation() assert (aLength.isInitialized()) assert (refattrA.isInitialized()) +assert (model.dof(aSketchFeature) == 3) #========================================================================= # Check values and move one constrainted object #========================================================================= @@ -73,10 +78,11 @@ aSession.startOperation() aLineAStartPoint.setValue(aLineAStartPoint.x() + deltaX, aLineAStartPoint.y()) aSession.finishOperation() +assert (model.dof(aSketchFeature) == 3) assert (aLineAStartPoint.y() == 25) assert (aLineAEndPoint.y() == 25) # length of the line is the same -assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 100) +assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 100) < 1.e-10) #========================================================================= # Change the length value of the constraint #========================================================================= @@ -84,7 +90,8 @@ aSession.startOperation() aLength.setValue(140.) aLengthConstraint.execute() aSession.finishOperation() -assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 140) +assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 140) < 1.e-10) +assert (model.dof(aSketchFeature) == 3) #========================================================================= # TODO: improve test # 1. remove constraint, move line's start point to @@ -93,3 +100,5 @@ assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 140) #========================================================================= # End of test #========================================================================= + +assert(model.checkPythonDump())