From fe510d90c15d9bec3a8c1dafc7b1730b11a9f6bd Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 4 Jan 2018 21:35:26 +0100 Subject: GameUI refactor (part 4/X): Move Game::guitext_status, Game::m_statustext, GameRunData::statustext_time to GameUI class Other enhancements: * Simplify setStatusText to showStatusText, as it shows the label too (preventing almost every setStatusText to call setStatusTextTime(0) * Add unittests --- src/unittest/test_gameui.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/unittest') diff --git a/src/unittest/test_gameui.cpp b/src/unittest/test_gameui.cpp index d52977469..9bc9d8cf5 100644 --- a/src/unittest/test_gameui.cpp +++ b/src/unittest/test_gameui.cpp @@ -31,6 +31,8 @@ public: void testInit(); void testFlagSetters(); + void testInfoText(); + void testStatusText(); }; static TestGameUI g_test_instance; @@ -39,6 +41,8 @@ void TestGameUI::runTests(IGameDef *gamedef) { TEST(testInit); TEST(testFlagSetters); + TEST(testInfoText); + TEST(testStatusText); } void TestGameUI::testInit() @@ -61,3 +65,20 @@ void TestGameUI::testFlagSetters() gui.showMinimap(false); UASSERT(!gui.getFlags().show_minimap); } + +void TestGameUI::testStatusText() +{ + GameUI gui{}; + gui.showStatusText(L"test status"); + + UASSERT(gui.m_statustext_time == 0.0f); + UASSERT(gui.m_statustext == L"test status"); +} + +void TestGameUI::testInfoText() +{ + GameUI gui{}; + gui.setInfoText(L"test info"); + + UASSERT(gui.m_infotext == L"test info"); +} -- cgit v1.2.3