Skip to content

Commit

Permalink
Tests for redrawing menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 3, 2024
1 parent 04ef508 commit bb2009e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/MenuTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "FakeDisplay.h"
#include "src/InputAction.h"
#include "src/ResourceType.h"
#include "src/UserChoice.h"
#include "test/FakeInput.h"

Expand Down Expand Up @@ -153,4 +154,33 @@ TEST_CASE("Menu usage", "[Menu]")
UserChoice choice{menu.getUserChoice(input)};
REQUIRE(choice == UserChoice::LEVEL_2);
}

SECTION("getUserChoice timer event with redrawing in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{{InputAction::TIMER, InputAction::ACCEPT}, {}, {}};
display.resetChangedAreas();
menu.getUserChoice(input);
std::vector<FakeDisplay::ChangedArea> changed{
display.getChangedAreas()};
REQUIRE(changed.size() == 5);
REQUIRE(changed[0].type_ == ResourceType::MENU_ITEM_SELECTED);
REQUIRE(changed[4].type_ == ResourceType::MENU_ITEM);
}

SECTION("getUserChoice hovering on last item with redrawing in level menu")
{
menu.refresh(UserChoice::LEVEL_MENU);
FakeInput input{
{InputAction::MOUSE_MOVE, InputAction::TIMER, InputAction::ACCEPT},
{},
{Config::getInstance().getBoardWidth() / 2, 400}};
display.resetChangedAreas();
menu.getUserChoice(input);
std::vector<FakeDisplay::ChangedArea> changed{
display.getChangedAreas()};
REQUIRE(changed.size() == 5);
REQUIRE(changed[0].type_ == ResourceType::MENU_ITEM);
REQUIRE(changed[4].type_ == ResourceType::MENU_ITEM_SELECTED);
}
}

0 comments on commit bb2009e

Please sign in to comment.