From 8a023b458542aa70e8adb7f973b39a37b5cc4902 Mon Sep 17 00:00:00 2001 From: codereader Date: Mon, 24 May 2021 16:45:34 +0200 Subject: [PATCH] #5623: Extend unit tests to check if the action can be successfully applied --- test/MapMerging.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/MapMerging.cpp b/test/MapMerging.cpp index 703c7c3a3d..ba86883e1a 100644 --- a/test/MapMerging.cpp +++ b/test/MapMerging.cpp @@ -416,6 +416,7 @@ TEST_F(MapMergeTest, MergeActionsForMissingEntities) auto result = performComparison("maps/fingerprinting.mapx", _context.getTestProjectPath() + "maps/fingerprinting_2.mapx"); auto operation = MergeOperation::CreateFromComparisonResult(*result); + // light_3 auto action = findAction(operation, [](const std::shared_ptr& action) { auto sourceEntity = Node_getEntity(action->getSourceNodeToAdd()); @@ -424,6 +425,16 @@ TEST_F(MapMergeTest, MergeActionsForMissingEntities) EXPECT_TRUE(action) << "No merge action found for missing entity"; + // Check pre-requisites and apply the action + auto entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "light_3"); + EXPECT_FALSE(entityNode); + + action->applyChanges(); + + entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "light_3"); + EXPECT_TRUE(entityNode); + + // func_static_2 action = findAction(operation, [](const std::shared_ptr& action) { auto sourceEntity = Node_getEntity(action->getSourceNodeToAdd()); @@ -431,6 +442,18 @@ TEST_F(MapMergeTest, MergeActionsForMissingEntities) }); EXPECT_TRUE(action) << "No merge action found for missing entity"; + + // Check pre-requisites and apply the action + entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "func_static_2"); + EXPECT_FALSE(entityNode); + + action->applyChanges(); + + entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "func_static_2"); + EXPECT_TRUE(entityNode); + + // Assume the child primitives have been added too + EXPECT_TRUE(scene::hasChildPrimitives(entityNode)); } TEST_F(MapMergeTest, MergeActionsForRemovedEntities) @@ -445,6 +468,15 @@ TEST_F(MapMergeTest, MergeActionsForRemovedEntities) }); EXPECT_TRUE(action) << "No merge action found for removed entity"; + + // Check pre-requisites and apply the action + auto entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "info_player_start_1"); + EXPECT_TRUE(entityNode); + + action->applyChanges(); + + entityNode = algorithm::getEntityByName(result->getBaseRootNode(), "info_player_start_1"); + EXPECT_FALSE(entityNode); } TEST_F(MapMergeTest, MergeActionsForAddedKeyValues)