File size: 3,127 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | // SPDX-License-Identifier: LGPL-2.1-or-later
#include <gtest/gtest.h>
#include <src/App/InitApplication.h>
#include <App/Document.h>
#include <Mod/Part/App/PrimitiveFeature.h>
class AttachExtensionTest: 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");
}
void TearDown() override
{
App::GetApplication().closeDocument(_docName.c_str());
}
App::Document* getDocument() const
{
return _doc;
}
private:
std::string _docName;
App::Document* _doc = nullptr;
};
TEST_F(AttachExtensionTest, testPlanePlane)
{
auto plane1 = getDocument()->addObject<Part::Plane>("Plane1");
auto plane2 = getDocument()->addObject<Part::Plane>("Plane2");
ASSERT_TRUE(plane1);
ASSERT_TRUE(plane2);
getDocument()->recompute();
plane2->MapReversed.setValue(false);
plane2->AttachmentSupport.setValue(plane1);
plane2->MapPathParameter.setValue(0.0);
plane2->MapMode.setValue("FlatFace");
getDocument()->recompute();
EXPECT_TRUE(true);
}
TEST_F(AttachExtensionTest, testAttacherEngineType)
{
auto plane = getDocument()->addObject<Part::Plane>("Plane");
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngine3D");
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
plane->AttacherEngine.setValue(1L);
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEnginePlane");
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Plane");
plane->AttacherEngine.setValue(2L);
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngineLine");
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Line");
plane->AttacherEngine.setValue(3L);
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEnginePoint");
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Point");
}
TEST_F(AttachExtensionTest, testAttacherTypeEngine)
{
auto plane = getDocument()->addObject<Part::Plane>("Plane");
EXPECT_STREQ(plane->AttacherType.getValue(), "Attacher::AttachEngine3D");
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
plane->AttacherType.setValue("Attacher::AttachEnginePlane");
plane->onExtendedDocumentRestored();
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Plane");
plane->AttacherType.setValue("Attacher::AttachEngineLine");
plane->onExtendedDocumentRestored();
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Line");
plane->AttacherType.setValue("Attacher::AttachEnginePoint");
plane->onExtendedDocumentRestored();
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine Point");
plane->AttacherType.setValue("Attacher::AttachEngine3D");
plane->onExtendedDocumentRestored();
EXPECT_STREQ(plane->AttacherEngine.getValueAsString(), "Engine 3D");
}
|