diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9cf0fdcdc2..57d2e20de3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,6 +7,7 @@ add_executable(drtest FileTypes.cpp HeadlessOpenGLContext.cpp ImageLoading.cpp + LayerManipulation.cpp MapExport.cpp MapSavingLoading.cpp Materials.cpp diff --git a/test/LayerManipulation.cpp b/test/LayerManipulation.cpp new file mode 100644 index 0000000000..483d8249a2 --- /dev/null +++ b/test/LayerManipulation.cpp @@ -0,0 +1,51 @@ +#include "RadiantTest.h" + +#include "imap.h" +#include "ilayer.h" +#include "algorithm/Scene.h" + +namespace test +{ + +using LayerTest = RadiantTest; + +TEST_F(LayerTest, CreateLayerMarksMapAsModified) +{ + loadMap("general_purpose.mapx"); + + EXPECT_FALSE(GlobalMapModule().isModified()); + + GlobalMapModule().getRoot()->getLayerManager().createLayer("Testlayer"); + + EXPECT_TRUE(GlobalMapModule().isModified()); +} + +TEST_F(LayerTest, RenameLayerMarksMapAsModified) +{ + loadMap("general_purpose.mapx"); + + auto& layerManager = GlobalMapModule().getRoot()->getLayerManager(); + + EXPECT_FALSE(GlobalMapModule().isModified()); + EXPECT_NE(layerManager.getLayerID("Second Layer"), -1); + + layerManager.renameLayer(layerManager.getLayerID("Second Layer"), "Renamed Layer"); + + EXPECT_TRUE(GlobalMapModule().isModified()); +} + +TEST_F(LayerTest, DeleteLayerMarksMapAsModified) +{ + loadMap("general_purpose.mapx"); + + auto& layerManager = GlobalMapModule().getRoot()->getLayerManager(); + + EXPECT_FALSE(GlobalMapModule().isModified()); + EXPECT_NE(layerManager.getLayerID("Second Layer"), -1); + + layerManager.deleteLayer("Second Layer"); + + EXPECT_TRUE(GlobalMapModule().isModified()); +} + +} diff --git a/test/resources/tdm/maps/general_purpose.mapx b/test/resources/tdm/maps/general_purpose.mapx new file mode 100644 index 0000000000..9f164a86b8 --- /dev/null +++ b/test/resources/tdm/maps/general_purpose.mapx @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/msvc/Tests/Tests.vcxproj b/tools/msvc/Tests/Tests.vcxproj index 768819fc61..8e0d5a5ead 100644 --- a/tools/msvc/Tests/Tests.vcxproj +++ b/tools/msvc/Tests/Tests.vcxproj @@ -76,6 +76,7 @@ + diff --git a/tools/msvc/Tests/Tests.vcxproj.filters b/tools/msvc/Tests/Tests.vcxproj.filters index b0a38dc687..884b4d814c 100644 --- a/tools/msvc/Tests/Tests.vcxproj.filters +++ b/tools/msvc/Tests/Tests.vcxproj.filters @@ -34,6 +34,7 @@ +