MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / TEST_F

Function TEST_F

tests/src/Mod/Material/App/TestMaterialCards.cpp:71–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71TEST_F(TestMaterialCards, TestCopy)
72{
73 ASSERT_NE(_modelManager, nullptr);
74 ASSERT_TRUE(_library);
75 // FAIL() << "Test library " << _library->getDirectoryPath().toStdString() << "\n";
76
77 auto testMaterial = _materialManager->getMaterial(_testMaterialUUID);
78 auto newMaterial = std::make_shared<Materials::Material>(*testMaterial);
79
80 EXPECT_EQ(testMaterial->getUUID(), _testMaterialUUID);
81 EXPECT_EQ(newMaterial->getUUID(), _testMaterialUUID);
82
83 // Save the material
84 _materialManager->saveMaterial(_library,
85 newMaterial,
86 QStringLiteral("/Test Material2.FCMat"),
87 false, // overwrite
88 true, // saveAsCopy
89 false); // saveInherited
90 EXPECT_EQ(newMaterial->getUUID(), _testMaterialUUID);
91 EXPECT_EQ(newMaterial->getName(), QStringLiteral("Test Material2"));
92
93 // Save it when it already exists throwing an error
94 EXPECT_THROW(_materialManager->saveMaterial(_library,
95 newMaterial,
96 QStringLiteral("/Test Material2.FCMat"),
97 false, // overwrite
98 true, // saveAsCopy
99 false) // saveInherited
100 , Materials::MaterialExists);
101 EXPECT_EQ(newMaterial->getUUID(), _testMaterialUUID);
102 EXPECT_EQ(newMaterial->getName(), QStringLiteral("Test Material2"));
103
104 // Overwrite the existing file
105 _materialManager->saveMaterial(_library,
106 newMaterial,
107 QStringLiteral("/Test Material2.FCMat"),
108 true, // overwrite
109 true, // saveAsCopy
110 false);// saveInherited
111 EXPECT_EQ(newMaterial->getUUID(), _testMaterialUUID);
112 EXPECT_EQ(newMaterial->getName(), QStringLiteral("Test Material2"));
113
114 // Save to a new file, inheritance mode
115 _materialManager->saveMaterial(_library,
116 newMaterial,
117 QStringLiteral("/Test Material3.FCMat"),
118 false, // overwrite
119 true, // saveAsCopy
120 true);// saveInherited
121 EXPECT_EQ(newMaterial->getUUID(), _testMaterialUUID);
122 EXPECT_EQ(newMaterial->getName(), QStringLiteral("Test Material3"));
123
124 // Save to a new file, inheritance mode. no copy
125 _materialManager->saveMaterial(_library,
126 newMaterial,
127 QStringLiteral("/Test Material4.FCMat"),
128 false, // overwrite

Callers

nothing calls this directly

Calls 8

getMaterialValueMethod · 0.80
getPhysicalPropertyMethod · 0.80
getMaterialMethod · 0.45
getUUIDMethod · 0.45
saveMaterialMethod · 0.45
getNameMethod · 0.45
hasPhysicalPropertyMethod · 0.45
columnsMethod · 0.45

Tested by

no test coverage detected