MCPcopy Create free account
hub / github.com/defold/defold / SetUp

Method SetUp

engine/gamesys/src/gamesys/test/test_script_http.cpp:109–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107protected:
108
109 void SetUp() override
110 {
111 char path[1024];
112 dmTestUtil::MakeHostPath(path, sizeof(path), "src/gamesys/test/http/test_http.config.raw");
113
114 dmConfigFile::Result r = dmConfigFile::Load(path, 0, 0, &m_ConfigFile);
115 ASSERT_EQ(dmConfigFile::RESULT_OK, r);
116
117 m_HttpResponseCount = 0;
118
119 WindowCreateParams win_params;
120 WindowCreateParamsInitialize(&win_params);
121 m_Window = dmPlatform::NewWindow();
122 dmPlatform::OpenWindow(m_Window, win_params);
123
124 dmResource::NewFactoryParams params;
125 params.m_MaxResources = 64;
126 params.m_Flags = RESOURCE_FACTORY_FLAGS_RELOAD_SUPPORT;
127
128 m_Factory = dmResource::NewFactory(&params, "build/src/gamesys/test");
129 ASSERT_NE((dmResource::HFactory)0, m_Factory); // Probably a sign that the previous test wasn't properly shut down
130
131 dmScript::ContextParams script_context_params = {};
132 script_context_params.m_ConfigFile = m_ConfigFile;
133 m_ScriptContext = dmScript::NewContext(script_context_params);
134 dmScript::Initialize(m_ScriptContext);
135
136 dmGraphics::InstallAdapter(dmGraphics::ADAPTER_FAMILY_NONE);
137 dmGraphics::ContextParams graphics_context_params;
138 graphics_context_params.m_Window = m_Window;
139 // graphics_context_params.m_JobContext = m_JobContext;
140
141 m_GraphicsContext = dmGraphics::NewContext(graphics_context_params);
142
143 dmRender::RenderContextParams render_params;
144 render_params.m_MaxRenderTypes = 10;
145 render_params.m_MaxInstances = 1000;
146 render_params.m_MaxRenderTargets = 10;
147 render_params.m_ScriptContext = m_ScriptContext;
148 render_params.m_MaxCharacters = 256;
149 render_params.m_MaxBatches = 128;
150 m_RenderContext = dmRender::NewRenderContext(m_GraphicsContext, render_params);
151
152 ExtensionAppParamsInitialize(&m_AppParams);
153 ExtensionParamsInitialize(&m_Params);
154
155 m_Params.m_L = dmScript::GetLuaState(m_ScriptContext);
156 m_Params.m_ConfigFile = m_ConfigFile;
157 m_Params.m_ResourceFactory = m_Factory;
158 ExtensionParamsSetContext(&m_Params, "lua", dmScript::GetLuaState(m_ScriptContext));
159 ExtensionParamsSetContext(&m_Params, "config", m_ConfigFile);
160 ExtensionParamsSetContext(&m_Params, "render", m_RenderContext);
161
162 dmExtension::AppInitialize(&m_AppParams);
163 dmExtension::Initialize(&m_Params);
164
165 L = dmScript::GetLuaState(m_ScriptContext);
166

Callers

nothing calls this directly

Calls 15

MakeHostPathFunction · 0.85
NewFactoryFunction · 0.85
NewRenderContextFunction · 0.85
AppInitializeFunction · 0.85
InitializeScriptLibsFunction · 0.85
NewSocketFunction · 0.85
PushURLFunction · 0.85
lua_gettopFunction · 0.85

Tested by

no test coverage detected