1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

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
This commit is contained in:
Loic Blot 2018-01-04 21:35:26 +01:00 committed by Loïc Blot
parent aab3b18e4b
commit fe510d90c1
4 changed files with 102 additions and 104 deletions

View file

@ -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");
}