]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Tests for Build plug-in features. V_2.3.0
authordbv <dbv@opencascade.com>
Fri, 6 May 2016 16:35:01 +0000 (19:35 +0300)
committerdbv <dbv@opencascade.com>
Fri, 6 May 2016 16:35:19 +0000 (19:35 +0300)
src/BuildPlugin/CMakeLists.txt
src/BuildPlugin/Test/TestEdge.py [new file with mode: 0644]
src/BuildPlugin/Test/TestFace.py [new file with mode: 0644]
src/BuildPlugin/Test/TestVertex.py [new file with mode: 0644]
src/BuildPlugin/Test/TestWire.py [new file with mode: 0644]

index 8c3b62d88b8676c16215faa9bac3bd987b465ea5..97e9633ad3986dfaafa8dfbb82058739a4e76d28 100644 (file)
@@ -62,4 +62,7 @@ INSTALL(TARGETS BuildPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Build)
 
-# ADD_UNIT_TESTS()
+ADD_UNIT_TESTS(TestVertex.py
+               TestEdge.py
+               TestWire.py
+               TestFace.py)
diff --git a/src/BuildPlugin/Test/TestEdge.py b/src/BuildPlugin/Test/TestEdge.py
new file mode 100644 (file)
index 0000000..5c5ebb5
--- /dev/null
@@ -0,0 +1,56 @@
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+import random
+
+def createLine(theSketchFeature):
+    aSketchLineFeature = theSketchFeature.addFeature("SketchLine")
+    aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+    aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+    aSketchLineStartPoint.setValue(random.uniform(0, 100), random.uniform(0, 100))
+    aSketchLineEndPoint.setValue(random.uniform(0, 100), random.uniform(0, 100))
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+for i in range(aNumOfLines):
+    createLine(aSketchFeature)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create edges
+aSession.startOperation()
+anEdgeFeature = aPart.addFeature("Edge")
+aBaseObjectsList = anEdgeFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+    aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+    aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(anEdgeFeature.results()) == aNumOfLines)
diff --git a/src/BuildPlugin/Test/TestFace.py b/src/BuildPlugin/Test/TestFace.py
new file mode 100644 (file)
index 0000000..9cf158a
--- /dev/null
@@ -0,0 +1,65 @@
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 0)
+aSketchLineEndPoint.setValue(0, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 50)
+aSketchLineEndPoint.setValue(50, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 50)
+aSketchLineEndPoint.setValue(50, 0)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 0)
+aSketchLineEndPoint.setValue(0, 0)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create face
+aSession.startOperation()
+aFaceFeature = aPart.addFeature("Face")
+aBaseObjectsList = aFaceFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+    aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+    aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(aFaceFeature.results()) > 0)
diff --git a/src/BuildPlugin/Test/TestVertex.py b/src/BuildPlugin/Test/TestVertex.py
new file mode 100644 (file)
index 0000000..cc2da79
--- /dev/null
@@ -0,0 +1,57 @@
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+import random
+
+def createPoint(theSketchFeature):
+    aSketchPointFeature = theSketchFeature.addFeature("SketchPoint")
+    aPointCoordindates = geomDataAPI_Point2D(aSketchPointFeature.attribute("PointCoordindates"))
+    aPointCoordindates.setValue(random.uniform(0, 100), random.uniform(0, 100))
+    return aSketchPointFeature
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create points
+aNumOfPoints = 10
+aPoints = []
+for i in range(aNumOfPoints):
+    aSession.startOperation()
+    aSketchPointFeature = createPoint(aSketchFeature)
+    aSession.finishOperation()
+    aPoints.append(aSketchPointFeature.firstResult().shape())
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+
+# Create vertices
+aSession.startOperation()
+aVertexFeature = aPart.addFeature("Vertex")
+aBaseObjectsList = aVertexFeature.selectionList("base_objects")
+
+for aPoint in aPoints:
+    aBaseObjectsList.append(aSketchResult, aPoint)
+aSession.finishOperation()
+
+# Test results
+assert (len(aVertexFeature.results()) == aNumOfPoints)
diff --git a/src/BuildPlugin/Test/TestWire.py b/src/BuildPlugin/Test/TestWire.py
new file mode 100644 (file)
index 0000000..f5d2098
--- /dev/null
@@ -0,0 +1,65 @@
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 0)
+aSketchLineEndPoint.setValue(0, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 50)
+aSketchLineEndPoint.setValue(50, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 50)
+aSketchLineEndPoint.setValue(50, 0)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 0)
+aSketchLineEndPoint.setValue(0, 0)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create wire
+aSession.startOperation()
+aWireFeature = aPart.addFeature("Wire")
+aBaseObjectsList = aWireFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+    aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+    aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(aWireFeature.results()) > 0)