GameUI refactor (part 1/X): GameUI object creation + GameUIFlags move to GameUI
[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 };
35
36 static TestGameUI g_test_instance;
37
38 void TestGameUI::runTests(IGameDef *gamedef)
39 {
40         TEST(testInit);
41         TEST(testFlagSetters);
42 }
43
44 void TestGameUI::testInit()
45 {
46         GameUI gui{};
47         gui.initFlags();
48         UASSERT(gui.getFlags().show_chat)
49         UASSERT(gui.getFlags().show_hud)
50 }
51
52 void TestGameUI::testFlagSetters()
53 {
54         GameUI gui;
55         gui.showMinimap(true);
56         UASSERT(gui.getFlags().show_minimap);
57
58         gui.showMinimap(false);
59         UASSERT(!gui.getFlags().show_minimap);
60 }