| | |
| |
|
| | #include <gtest/gtest.h> |
| | #include "src/App/InitApplication.h" |
| |
|
| | #include <App/Application.h> |
| | #include <App/Document.h> |
| | #include "Mod/Part/App/FeaturePartBox.h" |
| | #include "Mod/PartDesign/App/Body.h" |
| | #include "Mod/PartDesign/App/ShapeBinder.h" |
| |
|
| | |
| |
|
| | class ShapeBinderTest: public ::testing::Test |
| | { |
| | protected: |
| | static void SetUpTestSuite() |
| | { |
| | tests::initApplication(); |
| | } |
| |
|
| | void SetUp() override |
| | { |
| | _docName = App::GetApplication().getUniqueDocumentName("test"); |
| | _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser"); |
| | _body = _doc->addObject<PartDesign::Body>(); |
| | _box = _doc->addObject<Part::Box>(); |
| | _box->Length.setValue(1); |
| | _box->Width.setValue(2); |
| | _box->Height.setValue(3); |
| | _box->Placement.setValue( |
| | Base::Placement(Base::Vector3d(), Base::Rotation(), Base::Vector3d()) |
| | ); |
| | |
| | |
| | _binder = _doc->addObject<PartDesign::ShapeBinder>("ShapeBinderFoo"); |
| | _subbinder = _doc->addObject<PartDesign::SubShapeBinder>("SubShapeBinderBar"); |
| | _binder->Shape.setValue(_box->Shape.getShape()); |
| | _subbinder->setLinks({{_box, {"Face1", "Face2"}}}, false); |
| | _body->addObject(_binder); |
| | _body->addObject(_subbinder); |
| | } |
| |
|
| | void TearDown() override |
| | { |
| | App::GetApplication().closeDocument(_docName.c_str()); |
| | } |
| |
|
| | |
| |
|
| | App::Document* _doc = nullptr; |
| | std::string _docName = ""; |
| | Part::Box* _box = nullptr; |
| | PartDesign::Body* _body = nullptr; |
| | PartDesign::ShapeBinder* _binder = nullptr; |
| | PartDesign::SubShapeBinder* _subbinder = nullptr; |
| |
|
| | |
| | }; |
| |
|
| | TEST_F(ShapeBinderTest, shapeBinderExists) |
| | { |
| | |
| | |
| | auto binder = _doc->getObject("ShapeBinderFoo"); |
| | |
| | EXPECT_NE(binder, nullptr); |
| | |
| | } |
| |
|
| | TEST_F(ShapeBinderTest, subShapeBinderExists) |
| | { |
| | |
| | |
| | auto subbinder = _doc->getObject("SubShapeBinderBar"); |
| | |
| | EXPECT_NE(subbinder, nullptr); |
| | |
| | } |
| |
|
| | |
| |
|