UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_mapstatistics.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #include "test_shared.h"
27 #include "../client/client.h"
28 #include "../client/cl_shared.h"
29 #include "../client/cl_lua.h"
30 #include "../client/renderer/r_state.h"
31 #include "../client/ui/ui_main.h"
32 #include "../common/routing.h"
33 #include "../server/server.h"
34 #include "../server/sv_rma.h"
35 
36 class MapDefStatsTest: public ::testing::Test {
37 protected:
38  static void SetUpTestCase() {
39  TEST_Init();
40 
41  sv_genericPool = Mem_CreatePool("mapdef-test");
42  com_networkPool = Mem_CreatePool("Network");
43  vid_imagePool = Mem_CreatePool("Vid: Image system");
44  sv_dumpmapassembly = Cvar_Get("sv_dumpassembly", "0");
45  sv_public = Cvar_Get("sv_public", "0");
46  port = Cvar_Get("testport", "27909");
47  masterserver_url = Cvar_Get("masterserver_test", "http://localhost");
48 
49  cl_genericPool = Mem_CreatePool("Client: Generic");
50 
52  R_FontInit();
53  CL_InitLua();
54  UI_Init();
55 
56  OBJZERO(cls);
57  Com_ParseScripts(false);
58  }
59 
60  static void TearDownTestCase() {
61  TEST_Shutdown();
62  NET_Shutdown();
63  }
64 };
65 
70 TEST_F(MapDefStatsTest, DISABLED_MapDefStatistic)
71 {
72  const char* filterId = TEST_GetStringProperty("mapdef-id");
73  const mapDef_t* md;
74 
75  ASSERT_TRUE(csi.numMDs > 0);
76 
77  MapDef_Foreach(md) {
78  if (md->mapTheme[0] == '.')
79  continue;
80  if (filterId && !Q_streq(filterId, md->id))
81  continue;
82 
83  const char* asmName = (const char*)LIST_GetByIdx(md->params, 0);
84  SV_PrintAssemblyStats(md->mapTheme, asmName);
85  }
86 }
87 
static void SetUpTestCase()
void UI_Init(void)
Definition: ui_main.cpp:278
void NET_Shutdown(void)
Definition: net.cpp:337
char * id
Definition: q_shared.h:463
int numMDs
Definition: q_shared.h:572
TEST_F(MapDefStatsTest, DISABLED_MapDefStatistic)
This test cycles through the list of map definitions found in the maps.ufo script and collects some p...
void * LIST_GetByIdx(linkedList_t *list, int index)
Get an entry of a linked list by its index in the list.
Definition: list.cpp:362
csi_t csi
Definition: common.cpp:39
memPool_t * sv_genericPool
Definition: sv_main.cpp:55
void Com_ParseScripts(bool onlyServer)
Definition: scripts.cpp:3641
gltexunit_t texunits[MAX_GL_TEXUNITS]
Definition: r_state.h:114
cvar_t * masterserver_url
Definition: common.cpp:57
memPool_t * cl_genericPool
Definition: cl_main.cpp:86
client_static_t cls
Definition: cl_main.cpp:83
static void TearDownTestCase()
gltexunit_t * active_texunit
Definition: r_state.h:117
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition: cvar.cpp:342
#define OBJZERO(obj)
Definition: shared.h:178
void TEST_Shutdown(void)
Definition: test_shared.cpp:34
void CL_InitLua(void)
Initializes the ui-lua interfacing environment.
Definition: cl_lua.cpp:126
#define Mem_CreatePool(name)
Definition: mem.h:32
char * mapTheme
Definition: q_shared.h:464
memPool_t * com_networkPool
Definition: common.cpp:74
cvar_t * sv_public
Definition: sv_main.cpp:52
const char * TEST_GetStringProperty(const char *name)
void TEST_Init(void)
Definition: test_shared.cpp:72
cvar_t * port
Definition: common.cpp:58
memPool_t * vid_imagePool
Definition: cl_main.cpp:88
rstate_t r_state
Definition: r_main.cpp:48
#define MapDef_Foreach(var)
Definition: q_shared.h:505
#define Q_streq(a, b)
Definition: shared.h:136
cvar_t * sv_dumpmapassembly
Definition: sv_main.cpp:47
void SV_PrintAssemblyStats(const char *mapTheme, const char *asmName)
Definition: sv_rma.cpp:2229
void R_FontInit(void)
Definition: r_font.cpp:722
linkedList_t * params
Definition: q_shared.h:465