From 1306f9c5df31811e0d4c7805291bcd5dab4e4d5f Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 21 Mar 2024 16:33:10 +0100 Subject: [PATCH] tests: Test case for issue #13055 --- tests/src/Mod/PartDesign/App/CMakeLists.txt | 1 + tests/src/Mod/PartDesign/App/DatumPlane.cpp | 68 +++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/src/Mod/PartDesign/App/DatumPlane.cpp diff --git a/tests/src/Mod/PartDesign/App/CMakeLists.txt b/tests/src/Mod/PartDesign/App/CMakeLists.txt index 27e741395c..109d7e6842 100644 --- a/tests/src/Mod/PartDesign/App/CMakeLists.txt +++ b/tests/src/Mod/PartDesign/App/CMakeLists.txt @@ -2,5 +2,6 @@ target_sources( PartDesign_tests_run PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/DatumPlane.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ShapeBinder.cpp ) diff --git a/tests/src/Mod/PartDesign/App/DatumPlane.cpp b/tests/src/Mod/PartDesign/App/DatumPlane.cpp new file mode 100644 index 0000000000..8758fedd6a --- /dev/null +++ b/tests/src/Mod/PartDesign/App/DatumPlane.cpp @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include "gtest/gtest.h" +#include "src/App/InitApplication.h" + +#include +#include +#include +#include "Mod/Part/App/Attacher.h" +#include "Mod/PartDesign/App/Body.h" +#include "Mod/PartDesign/App/DatumPlane.h" + +class DatumPlaneTest: 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 = dynamic_cast(_doc->addObject("PartDesign::Body")); + } + + void TearDown() override + { + App::GetApplication().closeDocument(_docName.c_str()); + } + + App::Document* getDocument() const + { + return _doc; + } + + PartDesign::Body* getBody() const + { + return _body; + } + +private: + std::string _docName; + App::Document* _doc = nullptr; + PartDesign::Body* _body = nullptr; +}; + +TEST_F(DatumPlaneTest, attachDatumPlane) +{ + auto datumPlane = getDocument()->addObject("PartDesign::Plane", "Plane"); + ASSERT_TRUE(datumPlane); + getBody()->addObject(datumPlane); + auto origin = getBody()->getOrigin(); + + App::PropertyLinkSubList support; + std::vector objs; + std::vector subs; + objs.push_back(origin->getXY()); + subs.emplace_back(); + support.setValues(objs, subs); + + auto attach = datumPlane->getExtensionByType(); + attach->attacher().setReferences(support); + Attacher::SuggestResult sugr; + attach->attacher().suggestMapModes(sugr); + EXPECT_EQ(sugr.message, Attacher::SuggestResult::srOK); +}