Skip to content

Commit

Permalink
#5408: Set up a test featuring two unrelated scene graphs. The test f…
Browse files Browse the repository at this point in the history
…ails since the main scene undo command affects the second scene.
  • Loading branch information
codereader committed Oct 24, 2021
1 parent 0a891f9 commit 4f67673
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/UndoRedo.cpp
Expand Up @@ -4,12 +4,14 @@
#include "ibrush.h"
#include "ieclass.h"
#include "ientity.h"
#include "iscenegraphfactory.h"
#include "imap.h"
#include "icommandsystem.h"
#include "math/Matrix4.h"
#include "algorithm/Scene.h"
#include "algorithm/Primitives.h"
#include "scenelib.h"
#include "scene/BasicRootNode.h"
#include "testutil/FileSelectionHelper.h"

namespace test
Expand Down Expand Up @@ -636,4 +638,41 @@ TEST_F(UndoTest, MapChangeTracking)
EXPECT_FALSE(GlobalMapModule().isModified()) << "Map should be unmodified after saving";
}

// Changing a second scene should not mark the main scene as modified
TEST_F(UndoTest, TwoSceneGraphs)
{
// Load a map, it is unmodified
GlobalCommandSystem().executeCommand("OpenMap", cmd::Argument("maps/entityinspector.map"));
EXPECT_FALSE(GlobalMapModule().isModified()) << "Map should be unmodified after loading";

auto scene = GlobalSceneGraphFactory().createSceneGraph();
auto rootNode = std::make_shared<scene::BasicRootNode>();
scene->setRoot(rootNode);

// Crete the host entity
auto materialName = "textures/numbers/12";
auto entity = GlobalEntityModule().createEntity(GlobalEntityClassManager().findClass("func_static"));
scene::addNodeToContainer(entity, rootNode);

{
// Create an brush in an Undoable operation
UndoableCommand cmd("createBrush");
algorithm::createCubicBrush(entity, Vector3(0,0,0), materialName);
}

EXPECT_TRUE(algorithm::findFirstBrushWithMaterial(entity, materialName)) << "Failed to find the brush";

// This should not have affected the main scene
EXPECT_FALSE(GlobalMapModule().isModified()) << "Map should be unmodified after loading";

// Undoing the main scene should not affect the secondary scene
GlobalUndoSystem().undo();

// Still no change in the main map
EXPECT_FALSE(GlobalMapModule().isModified()) << "Map should be unmodified (no undo should be possible)";

// The brush should still be present in the second scene
EXPECT_TRUE(algorithm::findFirstBrushWithMaterial(entity, materialName)) << "Failed to find the brush";
}

}

0 comments on commit 4f67673

Please sign in to comment.