Skip to content

Commit

Permalink
#5732: Add unit test covering GridSnapRequest.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 27, 2021
1 parent d1bc331 commit 09d43a7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/Grid.cpp
Expand Up @@ -2,7 +2,9 @@

#include "igrid.h"
#include "icommandsystem.h"
#include "iradiant.h"
#include <sigc++/connection.h>
#include "messages/GridSnapRequest.h"

namespace test
{
Expand Down Expand Up @@ -136,4 +138,21 @@ TEST_F(GridTest, SetGridSizeByCmd)
checkGridSizeByCmd(grid::getStringForSize(GRID_256), grid::Space::World, 256.0f);
}

TEST_F(GridTest, GridSnapMessageIsSent)
{
bool messageReceived = false;

auto handler = GlobalRadiantCore().getMessageBus().addListener(
radiant::IMessage::Type::GridSnapRequest,
radiant::TypeListener<selection::GridSnapRequest>(
[&](selection::GridSnapRequest& msg) { messageReceived = true; }));

// Fire the command, this should send out the request
GlobalCommandSystem().executeCommand("SnapToGrid");

EXPECT_TRUE(messageReceived) << "No message received during SnapToGrid";

GlobalRadiantCore().getMessageBus().removeListener(handler);
}

}

0 comments on commit 09d43a7

Please sign in to comment.