| 69 | }; |
| 70 | |
| 71 | TEST_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 |
nothing calls this directly
no test coverage detected