From e247a0910b0ca68d44f132d80799e0b6e90e1de9 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 7 Sep 2016 14:14:29 +0300 Subject: [PATCH] Unit test for ConnectorAPI/ConnectorAPI_Connector.cpp --- src/ConnectorAPI/CMakeLists.txt | 9 +++++++ src/ConnectorAPI/ConnectorAPI_Connector.cpp | 1 - src/ConnectorAPI/Test/TestExportToGEOM.py | 27 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/ConnectorAPI/Test/TestExportToGEOM.py diff --git a/src/ConnectorAPI/CMakeLists.txt b/src/ConnectorAPI/CMakeLists.txt index c1dfd5b86..e4ab055ce 100644 --- a/src/ConnectorAPI/CMakeLists.txt +++ b/src/ConnectorAPI/CMakeLists.txt @@ -67,3 +67,12 @@ ENDIF(WIN32) INSTALL(TARGETS _ConnectorAPI DESTINATION ${SHAPER_INSTALL_SWIG}) INSTALL(TARGETS ConnectorAPI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ConnectorAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) + +# Tests +IF(${HAVE_SALOME}) + INCLUDE(UnitTest) + + ADD_UNIT_TESTS( + TestExportToGEOM.py + ) +ENDIF(${HAVE_SALOME}) diff --git a/src/ConnectorAPI/ConnectorAPI_Connector.cpp b/src/ConnectorAPI/ConnectorAPI_Connector.cpp index 1aa191693..7662f4197 100644 --- a/src/ConnectorAPI/ConnectorAPI_Connector.cpp +++ b/src/ConnectorAPI/ConnectorAPI_Connector.cpp @@ -14,5 +14,4 @@ void exportToGEOM(const std::shared_ptr & thePart) { // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature("ExportToGEOM"); - aFeature->execute(); } diff --git a/src/ConnectorAPI/Test/TestExportToGEOM.py b/src/ConnectorAPI/Test/TestExportToGEOM.py new file mode 100644 index 000000000..9dd2af283 --- /dev/null +++ b/src/ConnectorAPI/Test/TestExportToGEOM.py @@ -0,0 +1,27 @@ +import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50) +SketchLine_2 = Sketch_1.addLine(0, 50, 50, 50) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(50, 50, 50, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(50, 0, 0, 0) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()[0]) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result()[0], 50) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result()[0], 50) +SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result()[0], SketchLine_3.result()[0]) +SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result()[0], SketchLine_4.result()[0]) +SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result()[0], SketchLine_4.result()[0]) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) +model.end() + +model.exportToGEOM(Part_1_doc) -- 2.39.2