Skip to content

Commit

Permalink
#5761: Add unit test checking the Copy command against a single selec…
Browse files Browse the repository at this point in the history
…ted face
  • Loading branch information
codereader committed Apr 3, 2022
1 parent 9e33286 commit 784a3e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion radiant/ui/statusbar/StatusBarManager.cpp
Expand Up @@ -109,7 +109,7 @@ void StatusBarManager::addTextElement(const std::string& name, const std::string

if (pos == StandardPosition::Commands)
{
textPanel->SetMinSize(wxSize(150, -1));
textPanel->SetMinSize(wxSize(250, -1));
}

if (!description.empty())
Expand Down
3 changes: 2 additions & 1 deletion radiantcore/selection/clipboard/Clipboard.cpp
Expand Up @@ -46,7 +46,7 @@ void copy(const cmd::ArgumentList& args)

if (GlobalSelectionSystem().countSelected() == 0)
{
map::OperationMessage::Send(_("Cannot copy, nothing selected"));
map::OperationMessage::Send(_("Nothing copied"));
return;
}

Expand All @@ -65,6 +65,7 @@ void copy(const cmd::ArgumentList& args)
else
{
algorithm::pickShaderFromSelection(args);
map::OperationMessage::Send(_("Face Texture copied to Clipboard"));
}
}

Expand Down
35 changes: 35 additions & 0 deletions test/Selection.cpp
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>
#include "ishaders.h"
#include "imap.h"
#include "ishaderclipboard.h"
#include "ifilter.h"
#include "ilightnode.h"
#include "ibrush.h"
Expand Down Expand Up @@ -532,4 +533,38 @@ TEST_F(ClipboardTest, CopyNonEmptySelection)
algorithm::assertStringIsMapxFile(GlobalClipboard().getString());
}

TEST_F(ClipboardTest, CopyFaceSelection)
{
// Create a brush and select a single face
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brush = algorithm::createCubicBrush(worldspawn, { 0, 0 ,0 }, "textures/common/caulk");

render::View view(true);
algorithm::constructCameraView(view, brush->worldAABB(), Vector3(0, 0, -1), Vector3(-90, 0, 0));

auto rectangle = selection::Rectangle::ConstructFromPoint(Vector2(0, 0), Vector2(8.0 / algorithm::DeviceWidth, 8.0 / algorithm::DeviceHeight));
ConstructSelectionTest(view, rectangle);

SelectionVolume test(view);
GlobalSelectionSystem().selectPoint(test, selection::SelectionSystem::eToggle, true);

EXPECT_EQ(GlobalSelectionSystem().getSelectedFaceCount(), 1) << "One face should be selected now";

// Monitor radiant to catch the messages
CommandFailureHelper helper;
MapOperationMonitor operationMonitor;

GlobalShaderClipboard().clear();
EXPECT_NE(GlobalShaderClipboard().getShaderName(), "textures/common/caulk");

// This should do nothing, and it should not throw any execution failures neither
GlobalCommandSystem().executeCommand("Copy");

EXPECT_FALSE(helper.messageReceived()) << "Command execution should not have failed";
EXPECT_TRUE(operationMonitor.messageReceived()) << "Command should have sent out an OperationMessage";

// Check the shader clipboard, it should contain the material name
EXPECT_EQ(GlobalShaderClipboard().getShaderName(), "textures/common/caulk") << "Shaderclipboard should contain the material name now";
}

}

0 comments on commit 784a3e0

Please sign in to comment.