Skip to content

Commit

Permalink
Add more tests for Menu::getUserChoice method.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 3, 2024
1 parent 3e67763 commit 04ef508
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions test/MenuTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ TEST_CASE("Menu usage", "[Menu]")
REQUIRE(choice == UserChoice::LEVEL_2);
}

SECTION("getUserChoice down, aup and accept in level menu")
SECTION("getUserChoice up being on first item in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{{InputAction::UP, InputAction::ACCEPT}, {}, {}};
UserChoice choice{menu.getUserChoice(input)};
REQUIRE(choice == UserChoice::LEVEL_1);
}

SECTION("getUserChoice down, up and accept in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{
Expand All @@ -114,7 +122,7 @@ TEST_CASE("Menu usage", "[Menu]")
REQUIRE(choice == UserChoice::LEVEL_1);
}

SECTION("getUserChoice use mouse to pick item in level menu")
SECTION("getUserChoice use mouse to pick last item in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{{InputAction::MOUSE_MOVE, InputAction::ACCEPT},
Expand All @@ -123,4 +131,26 @@ TEST_CASE("Menu usage", "[Menu]")
UserChoice choice{menu.getUserChoice(input)};
REQUIRE(choice == UserChoice::BACK);
}

SECTION("getUserChoice down being on last item in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{
{InputAction::MOUSE_MOVE, InputAction::DOWN, InputAction::ACCEPT},
{},
{Config::getInstance().getBoardWidth() / 2, 400}};
UserChoice choice{menu.getUserChoice(input)};
REQUIRE(choice == UserChoice::BACK);
}

SECTION("getUserChoice click outside items in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{{InputAction::DOWN, InputAction::MOUSE_MOVE,
InputAction::CLICK, InputAction::ACCEPT},
{},
{0, 0}};
UserChoice choice{menu.getUserChoice(input)};
REQUIRE(choice == UserChoice::LEVEL_2);
}
}

0 comments on commit 04ef508

Please sign in to comment.