| 1328 | } |
| 1329 | |
| 1330 | void checkBehaviourDiscardingUnsavedChanges(const std::string& testProjectPath, std::function<void()> action, bool expectUnmodifiedMapAfterAction = true) |
| 1331 | { |
| 1332 | std::string modRelativePath = "maps/altar.map"; |
| 1333 | GlobalCommandSystem().executeCommand("OpenMap", modRelativePath); |
| 1334 | |
| 1335 | fs::path mapPath = testProjectPath + modRelativePath; |
| 1336 | auto sizeBefore = fs::file_size(mapPath); |
| 1337 | |
| 1338 | // Create a brush to mark the map as modified |
| 1339 | algorithm::createCubicBrush(GlobalMapModule().findOrInsertWorldspawn()); |
| 1340 | EXPECT_TRUE(GlobalMapModule().isModified()) << "Map was not marked as modified after brush creation"; |
| 1341 | |
| 1342 | // Discard the changes |
| 1343 | FileSaveConfirmationHelper helper(radiant::FileSaveConfirmation::Action::DiscardChanges); |
| 1344 | |
| 1345 | // Performing the action must ask for save, since the file has been changed |
| 1346 | action(); |
| 1347 | |
| 1348 | EXPECT_TRUE(helper.messageReceived()) << "Map must ask for save"; |
| 1349 | EXPECT_EQ(fs::file_size(mapPath), sizeBefore) << "File size has changed after discarding"; |
| 1350 | |
| 1351 | // In some scenario like app shutdown the map modified flag is not cleared |
| 1352 | if (expectUnmodifiedMapAfterAction) |
| 1353 | { |
| 1354 | EXPECT_FALSE(GlobalMapModule().isModified()) << "Map should be unmodified again"; |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | void checkBehaviourSavingUnsavedChanges(const std::string& fullMapPath, std::function<void()> action) |
| 1359 | { |
no test coverage detected