Skip to content

Commit

Permalink
#6115: Add unit test covering the faulty behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 2, 2022
1 parent 00e53b9 commit 2e9bf87
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/LayerManipulation.cpp
Expand Up @@ -3,6 +3,7 @@

#include "imap.h"
#include "ilayer.h"
#include "ifilter.h"
#include "scenelib.h"
#include "algorithm/Primitives.h"
#include "os/file.h"
Expand Down Expand Up @@ -933,4 +934,38 @@ TEST_F(LayerTest, SettingParentLayerMarksMapAsModified)
EXPECT_TRUE(GlobalMapModule().isModified());
}

// #6115: Selecting and deselecting a filtered child brush through layers leaves the brush selected
TEST_F(LayerTest, SelectFilteredChildPrimitive)
{
loadMap("selecting_filtered_items_with_layers.mapx");

auto& layerManager = GlobalMapModule().getRoot()->getLayerManager();
auto caulkLayerId = layerManager.getLayerID("Caulk");

auto func_static_1 = algorithm::getEntityByName(GlobalMapModule().getRoot(), "func_static_1");
auto childPrimitive = algorithm::findFirstBrushWithMaterial(func_static_1, "textures/common/caulk");

EXPECT_EQ(childPrimitive->getLayers(), scene::LayerList{ caulkLayerId }) << "Unexpected layer setup";
EXPECT_TRUE(childPrimitive->visible()) << "The brush should be visible after map load";

// Activate the filter hiding the caulk brush
GlobalFilterSystem().setFilterState("Caulk", true);

EXPECT_FALSE(childPrimitive->visible()) << "The filter should have hidden the brush";

// Now select the layer, this should set the brush to visible
// because the parent entity selection implies a forced-visible state on the brush
layerManager.setSelected(caulkLayerId, true);

EXPECT_TRUE(childPrimitive->visible()) << "Selecting the layer should set the brush to visible";

EXPECT_TRUE(Node_isSelected(func_static_1)) << "Selecting the layer should have selected func_static_1";
EXPECT_TRUE(Node_isSelected(childPrimitive)) << "Selecting the layer selected the brush since it was forced visible";

layerManager.setSelected(caulkLayerId, false);

EXPECT_FALSE(Node_isSelected(func_static_1)) << "De-selecting the layer should have de-selected func_static_1";
EXPECT_FALSE(Node_isSelected(childPrimitive)) << "De-selecting the layer shouldn't leave the brush selected";
}

}

0 comments on commit 2e9bf87

Please sign in to comment.