Lua_api.txt: Add chat command params info
[oweals/minetest.git] / src / unittest / test_gameui.cpp
1 /*
2 Minetest
3 Copyright (C) 2018 nerzhul, Loic BLOT <loic.blot@unix-experience.fr>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "test.h"
21
22 #include "client/gameui.h"
23
24 class TestGameUI : public TestBase
25 {
26 public:
27         TestGameUI() { TestManager::registerTestModule(this); }
28         const char *getName() { return "TestGameUI"; }
29
30         void runTests(IGameDef *gamedef);
31
32         void testInit();
33         void testFlagSetters();
34         void testInfoText();
35         void testStatusText();
36 };
37
38 static TestGameUI g_test_instance;
39
40 void TestGameUI::runTests(IGameDef *gamedef)
41 {
42         TEST(testInit);
43         TEST(testFlagSetters);
44         TEST(testInfoText);
45         TEST(testStatusText);
46 }
47
48 void TestGameUI::testInit()
49 {
50         GameUI gui{};
51         gui.initFlags();
52         UASSERT(gui.getFlags().show_chat)
53         UASSERT(gui.getFlags().show_hud)
54
55         // @TODO verify if we can create non UI nulldevice to test this function
56         // gui.init();
57 }
58
59 void TestGameUI::testFlagSetters()
60 {
61         GameUI gui{};
62         gui.showMinimap(true);
63         UASSERT(gui.getFlags().show_minimap);
64
65         gui.showMinimap(false);
66         UASSERT(!gui.getFlags().show_minimap);
67 }
68
69 void TestGameUI::testStatusText()
70 {
71         GameUI gui{};
72         gui.showStatusText(L"test status");
73
74         UASSERT(gui.m_statustext_time == 0.0f);
75         UASSERT(gui.m_statustext == L"test status");
76 }
77
78 void TestGameUI::testInfoText()
79 {
80         GameUI gui{};
81         gui.setInfoText(L"test info");
82
83         UASSERT(gui.m_infotext == L"test info");
84 }