15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/test/unit_test.hpp>
28 #include <boost/scoped_ptr.hpp>
29 #include <boost/assign.hpp>
55 boost::scoped_ptr<saved_game> state;
56 boost::scoped_ptr<rand_rng::mt_rng> rng;
75 state->classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;
76 config_manager->load_game_config_for_game(state->classification());
78 state->mp_settings().mp_era =
"era_default";
79 state->mp_settings().name =
"multiplayer_The_Freelands";
80 state->mp_settings().use_map_settings =
true;
81 state->mp_settings().saved_game =
false;
84 game_config().find_child(
"multiplayer",
"id", state->mp_settings().name));
86 state->mp_settings().num_turns = state->get_starting_pos()[
"turns"];
107 return connect_engine;
116 side_cfg.
append(defaults);
131 state->mp_settings().use_map_settings =
true;
132 state->mp_settings().saved_game =
false;
133 boost::scoped_ptr<test_connect_engine>
140 side[
"recruit"] =
"Elvish Archer";
144 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"],
"Elvish Archer" );
148 side[
"faction"] =
"Custom";
151 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
152 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"].empty(), true );
156 side[
"faction"] =
"Random";
159 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Random" );
163 side[
"faction"] =
"Rebels";
166 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Rebels" );
170 side[
"faction"] =
"ThisFactionDoesNotExist";
172 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
173 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Random" );
177 side[
"recruit"] =
"Elvish Archer";
178 side[
"faction"] =
"Undead";
186 side[
"previous_recruits"] =
"Elvish Archer";
189 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
190 BOOST_CHECK_EQUAL( side_engine->new_config()[
"previous_recruits"],
195 side[
"type"] =
"Shadow";
197 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
198 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Shadow" );
199 BOOST_CHECK_EQUAL( side_engine->new_config()[
"type"],
"Shadow" );
203 side[
"type"] =
"ThisUnitDoesNotExist";
205 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
206 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
210 side[
"faction"] =
"Custom";
212 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
213 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"random" );
217 side[
"faction"] =
"Random";
219 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
220 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
224 side[
"faction"] =
"Undead";
226 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
227 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"random" );
231 side[
"id"] =
"LeaderID";
232 side[
"type"] =
"Elvish Archer";
234 unit[
"id"] =
"LeaderID";
235 unit[
"type"] =
"Elvish Ranger";
237 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
238 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Elvish Ranger" );
242 side[
"type"] =
"random";
244 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
248 side[
"type"] =
"Elvish Archer";
250 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 3 );
251 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
255 side[
"type"] =
"Swordsman";
257 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
258 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
262 side[
"type"] =
"Elvish Druid";
264 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
265 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"female" );
269 side[
"type"] =
"White Mage";
270 side[
"gender"] =
"female";
273 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"female" );
277 side[
"type"] =
"Troll";
278 side[
"gender"] =
"female";
280 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
281 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
285 side[
"type"] =
"White Mage";
286 side[
"gender"] =
"random";
289 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
293 side[
"no_leader"] =
true;
295 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
296 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
300 side[
"faction"] =
"Random";
302 side_engine->resolve_random(*rng);
303 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
304 BOOST_CHECK( side_engine->flg().current_leader() !=
"random" &&
305 side_engine->flg().current_leader() !=
"null");
306 BOOST_CHECK( side_engine->flg().current_gender() !=
"random" &&
307 side_engine->flg().current_gender() !=
"null");
311 side[
"faction"] =
"Random";
312 side[
"type"] =
"Troll";
314 side_engine->resolve_random(*rng);
315 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
316 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Troll" );
317 BOOST_CHECK( side_engine->flg().current_gender() !=
"random" &&
318 side_engine->flg().current_gender() !=
"null" );
322 side[
"faction"] =
"Random";
323 side[
"type"] =
"White Mage";
324 side[
"gender"] =
"male";
326 side_engine->resolve_random(*rng);
327 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
328 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"White Mage" );
329 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
333 side[
"type"] =
"random";
335 side_engine->resolve_random(*rng);
336 BOOST_CHECK( side_engine->flg().current_leader() !=
"random" );
342 state->mp_settings().use_map_settings =
false;
343 state->mp_settings().saved_game =
false;
344 boost::scoped_ptr<test_connect_engine>
351 side[
"recruit"] =
"Elvish Archer";
353 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
358 side[
"faction"] =
"Custom";
360 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
361 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
362 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"].empty(), true );
366 side[
"previous_recruits"] =
"Elvish Archer";
368 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
369 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
370 BOOST_CHECK_EQUAL( side_engine->new_config()[
"previous_recruits"],
375 side[
"type"] =
"Goblin Impaler";
377 side_engine->flg().set_current_faction(
"Rebels");
378 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
382 side[
"faction"] =
"Custom";
383 side[
"type"] =
"Swordsman";
385 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
386 const std::vector<std::string>& leaders =
387 side_engine->flg().choosable_leaders();
388 BOOST_CHECK_EQUAL(
std::count(leaders.begin(), leaders.end(),
"Swordsman"),
393 side[
"gender"] =
"female";
395 side_engine->flg().set_current_faction(
"Rebels");
396 side_engine->flg().set_current_leader(
"Elvish Ranger");
397 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
405 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(mp_connect)
void append(const config &cfg)
Append data from another config object to this one.
boost::scoped_ptr< game_config_manager > config_manager
this class is initialized once at game start put all initialization and wipe code in the methods here...
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
BOOST_GLOBAL_FIXTURE(mp_connect_fixture)
Dont reload if the previous defines equal the new defines.
static ng::side_engine * create_side_engine(const config &defaults, test_connect_engine *connect_engine)
void clear_children(const std::string &key)
BOOST_AUTO_TEST_CASE(flg_map_settings)
config & add_child(const std::string &key)
GLuint GLuint GLsizei count
config * current_config()
Game configuration data as global variables.
connect_engine(saved_game &state, const bool first_scenario, mp_campaign_info *campaign_info)
static test_connect_engine * create_test_connect_engine()
std::vector< std::string > dummy_args
const attribute_value * get(const std::string &key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
commandline_options cmdline_opts
hotkey::manager hotkey_manager
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void remove_attributes(T...keys)
A config object defines a single node in a WML file, with access to child nodes.
test_connect_engine(saved_game &gamestate)
GLsizei const GLcharARB ** string