Skip to content

Commit

Permalink
#5382: First working test
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 6, 2020
1 parent 92d8b41 commit 07a9e83
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions test/PatchWelding.cpp
Expand Up @@ -17,29 +17,40 @@ inline scene::INodePtr findPatchWithNumber(const std::string& number)
return algorithm::findFirstPatchWithMaterial(worldspawn, "textures/numbers/" + number);
}

// Patch 1 = 3x3, Patch 4 = 3x3 to the right
TEST_F(PatchWeldingTest, WeldPatches1And4)
namespace
{
loadMap("weld_patches.mapx");

auto patch1 = findPatchWithNumber("1");
auto patch4 = findPatchWithNumber("4");
void performPatchWeldingTest(const std::string& number1, const std::string& number2, int expectedRows, int expectedCols)
{
auto firstPatch = findPatchWithNumber(number1);
auto secondPatch = findPatchWithNumber(number2);

Node_setSelected(patch1, true);
Node_setSelected(patch4, true);
Node_setSelected(firstPatch, true);
Node_setSelected(secondPatch, true);

GlobalCommandSystem().executeCommand("WeldSelectedPatches");

// Only one patch selected
EXPECT_EQ(GlobalSelectionSystem().countSelected(), 1);

// Two patches removed from the scene
EXPECT_FALSE(patch1->getParent());
EXPECT_FALSE(patch4->getParent());
EXPECT_FALSE(firstPatch->getParent());
EXPECT_FALSE(secondPatch->getParent());

auto merged = std::dynamic_pointer_cast<IPatchNode>(GlobalSelectionSystem().ultimateSelected());
EXPECT_EQ(merged->getPatch().getWidth(), 3);
EXPECT_EQ(merged->getPatch().getWidth(), 5);
EXPECT_EQ(merged->getPatch().getHeight(), expectedRows);
EXPECT_EQ(merged->getPatch().getWidth(), expectedCols);
}

}

// Patch 1 = 3x3, Patch 4 = 3x3 to the right
TEST_F(PatchWeldingTest, WeldPatches1And4)
{
loadMap("weld_patches.mapx");

// Welding patches 1 and 4 should produce a 3 x 5 patch
performPatchWeldingTest("1", "4", 3, 5);
}

}

0 comments on commit 07a9e83

Please sign in to comment.