Skip to content

Commit

Permalink
Fix GameUI flag value regression introduced by a78659e
Browse files Browse the repository at this point in the history
Added more strong unittests on that part to prevent future regression
  • Loading branch information
nerzhul committed May 29, 2018
1 parent 67ed56b commit 75aa41c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/client/gameui.cpp
Expand Up @@ -189,8 +189,6 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
void GameUI::initFlags()
{
m_flags = GameUI::Flags();
m_flags.show_chat = true;
m_flags.show_hud = true;
m_flags.show_debug = g_settings->getBool("show_debug");
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/gameui.h
Expand Up @@ -54,9 +54,9 @@ class GameUI
{
bool show_chat = true;
bool show_hud = true;
bool show_minimap = true;
bool show_minimap = false;
bool show_debug = true;
bool show_profiler_graph = true;
bool show_profiler_graph = false;
};

void init();
Expand Down
9 changes: 9 additions & 0 deletions src/unittest/test_gameui.cpp
Expand Up @@ -48,9 +48,18 @@ void TestGameUI::runTests(IGameDef *gamedef)
void TestGameUI::testInit()
{
GameUI gui{};
// Ensure flags on GameUI init
UASSERT(gui.getFlags().show_chat)
UASSERT(gui.getFlags().show_hud)
UASSERT(!gui.getFlags().show_minimap)
UASSERT(!gui.getFlags().show_profiler_graph)

// And after the initFlags init stage
gui.initFlags();
UASSERT(gui.getFlags().show_chat)
UASSERT(gui.getFlags().show_hud)
UASSERT(!gui.getFlags().show_minimap)
UASSERT(!gui.getFlags().show_profiler_graph)

// @TODO verify if we can create non UI nulldevice to test this function
// gui.init();
Expand Down

0 comments on commit 75aa41c

Please sign in to comment.