16 #define GETTEXT_DOMAIN "wesnoth-lib"
18 #include <boost/test/unit_test.hpp>
101 static std::vector<std::string>
result =
130 class tmp_server_list;
153 static T*
create() {
return new T(); }
156 typedef std::pair<unsigned, unsigned> tresolution;
157 typedef std::vector<std::pair<unsigned, unsigned> > tresolution_list;
160 void test_resolutions(
const tresolution_list& resolutions)
162 for(
const tresolution&
resolution : resolutions) {
166 BOOST_REQUIRE_MESSAGE(dlg.get(),
"Failed to create a dialog.");
174 exception =
"gui2::tlayout_exception_width_modified";
176 exception =
"gui2::tlayout_exception_width_resize_failed";
178 exception =
"gui2::tlayout_exception_height_resize_failed";
181 }
catch(std::exception& e) {
182 exception = e.what();
184 exception =
"unknown";
186 BOOST_CHECK_MESSAGE(exception.empty(),
191 <<
"\nException caught: " << exception <<
'.');
196 void test_popup_resolutions(
const tresolution_list& resolutions)
198 bool interact =
false;
199 for(
int i = 0;
i < 2; ++
i) {
200 for(
const tresolution&
resolution : resolutions) {
204 BOOST_REQUIRE_MESSAGE(dlg.get(),
"Failed to create a dialog.");
210 dlg->show(video, interact);
212 BOOST_REQUIRE_NE(window, static_cast<void*>(
nullptr));
215 exception =
"gui2::tlayout_exception_width_modified";
217 exception =
"gui2::tlayout_exception_width_resize_failed";
219 exception =
"gui2::tlayout_exception_height_resize_failed";
222 }
catch(std::exception& e) {
223 exception = e.what();
225 exception =
"unknown";
227 BOOST_CHECK_MESSAGE(exception.empty(),
232 <<
"\nException caught: " << exception <<
'.');
240 #pragma warning(push)
241 #pragma warning(disable: 4702)
243 void test_tip_resolutions(
const tresolution_list& resolutions
246 for(
const tresolution&
resolution : resolutions) {
250 std::vector<std::string>& list =
252 list.erase(
std::remove(list.begin(), list.end(),
id), list.end());
266 ,
"Test messsage for a tooltip."
270 exception =
"gui2::tlayout_exception_width_modified";
272 exception =
"gui2::tlayout_exception_width_resize_failed";
274 exception =
"gui2::tlayout_exception_height_resize_failed";
277 }
catch(std::exception& e) {
278 exception = e.what();
280 exception =
"unknown";
282 BOOST_CHECK_MESSAGE(exception.empty(),
283 "Test for tip '" <<
id
287 <<
"\nException caught: " << exception <<
'.');
294 const tresolution_list& get_gui_resolutions()
296 static tresolution_list
result;
298 result.push_back(std::make_pair(800, 600));
299 result.push_back(std::make_pair(1024, 768));
300 result.push_back(std::make_pair(1280, 1024));
301 result.push_back(std::make_pair(1680, 1050));
311 for(
size_t i = 0;
i < 2; ++
i) {
313 test_resolutions<T>(get_gui_resolutions());
325 for(
size_t i = 0;
i < 2; ++
i) {
327 test_popup_resolutions<T>(get_gui_resolutions());
337 for(
size_t i = 0;
i < 2; ++
i) {
339 test_tip_resolutions(get_gui_resolutions(),
id);
365 test<gui2::taddon_connect>();
367 test<gui2::tcampaign_difficulty>();
368 test<gui2::tcampaign_selection>();
369 test<gui2::tcampaign_settings>();
371 test<gui2::tedit_label>();
372 test<gui2::tedit_text>();
373 test<gui2::teditor_generate_map>();
374 test<gui2::teditor_new_map>();
375 test<gui2::teditor_resize_map>();
376 test<gui2::teditor_set_starting_position>();
377 test<gui2::tfolder_create>();
378 test<gui2::tformula_debugger>();
379 test<gui2::tgame_cache_options>();
380 test<gui2::tgame_delete>();
381 test<gui2::tgame_load>();
382 test<gui2::tgame_version>();
383 test<gui2::tgame_save>();
384 test<gui2::tgame_save_message>();
385 test<gui2::tgame_save_oos>();
386 test<gui2::tgamestate_inspector>();
387 test<gui2::tlanguage_selection>();
389 test<gui2::tlobby_main>();
390 test<gui2::tlobby_player_info>();
391 test<gui2::tlogging>();
392 test<gui2::tmessage>();
393 test<gui2::tmp_change_control>();
394 test<gui2::tmp_cmd_wrapper>();
395 test<gui2::tmp_connect>();
396 test<gui2::tmp_create_game>();
397 test<gui2::tmp_create_game_set_password>();
398 test<gui2::tmp_join_game_password_prompt>();
399 test<gui2::tdepcheck_confirm_change>();
400 test<gui2::tdepcheck_select_new>();
401 test<gui2::tmp_login>();
402 test<gui2::tmp_method_selection>();
403 test<gui2::tmp_server_list>();
404 test<gui2::tsimple_item_selector>();
405 test<gui2::tscreenshot_notification>();
406 test<gui2::tselect_orb_colors>();
407 test<gui2::ttheme_list>();
408 test<gui2::ttitle_screen>();
409 test<gui2::ttransient_message>();
411 test<gui2::tunit_create>();
413 test<gui2::twml_error>();
414 test<gui2::twml_message_left>();
415 test<gui2::twml_message_right>();
416 test<gui2::tmp_alerts_options>();
417 test<gui2::tadvanced_graphics_options>();
422 test_popup<gui2::tdebug_clock>();
425 test_tip(
"tooltip_large");
434 std::remove(list.begin(), list.end(),
"unit_attack")
447 std::remove(list.begin(), list.end(),
"lua_interpreter")
456 std::remove(list.begin(), list.end(),
"label_settings")
463 list.erase(
std::remove(list.begin(), list.end(),
"addon_description"), list.end());
464 list.erase(
std::remove(list.begin(), list.end(),
"addon_filter_options"), list.end());
465 list.erase(
std::remove(list.begin(), list.end(),
"addon_uninstall_list"), list.end());
466 list.erase(
std::remove(list.begin(), list.end(),
"addon_list"), list.end());
467 list.erase(
std::remove(list.begin(), list.end(),
"loadscreen"), list.end());
468 list.erase(
std::remove(list.begin(), list.end(),
"network_transmission"), list.end());
469 list.erase(
std::remove(list.begin(), list.end(),
"synced_choice_wait"), list.end());
470 list.erase(
std::remove(list.begin(), list.end(),
"drop_down_list"), list.end());
471 list.erase(
std::remove(list.begin(), list.end(),
"preferences"), list.end());
472 list.erase(
std::remove(list.begin(), list.end(),
"unit_recruit"), list.end());
475 BOOST_CHECK_EQUAL(list.size(), 0);
477 std::cerr <<
"Window '" <<
id <<
"' registered but not tested.\n";
490 "which doesn't fit on the screen."));
494 BOOST_ERROR(
"Didn't catch the wanted exception.");
500 struct twrapper<
gui2::taddon_connect>
510 struct twrapper<
gui2::taddon_list>
521 struct twrapper<
gui2::tcampaign_difficulty>
532 struct twrapper<
gui2::tcampaign_selection>
544 struct twrapper<
gui2::tcampaign_settings>
556 struct twrapper<
gui2::tchat_log>
568 struct twrapper<
gui2::tedit_label>
573 static bool team_only =
false;
579 struct twrapper<
gui2::tedit_text>
589 struct twrapper<
gui2::tformula_debugger>
599 struct twrapper<
gui2::tgame_load>
611 struct twrapper<
gui2::tgame_version>
621 struct twrapper<
gui2::tgame_save>
633 struct twrapper<
gui2::tgame_save_message>
646 struct twrapper<
gui2::tgame_save_oos>
650 static bool ignore_all =
false;
660 struct twrapper<
gui2::tgamestate_inspector>
674 struct twesnothd_connection_init
692 struct twrapper<
gui2::tlobby_main>
698 static twesnothd_connection_init wesnothd_connection_init(wesnothd_connection);
699 static lobby_info li(game_config, wesnothd_connection);
714 struct twrapper<
gui2::tlobby_player_info>
719 static fake_chat_handler ch;
722 static twesnothd_connection_init wesnothd_connection_init(wesnothd_connection);
729 struct twrapper<
gui2::tlogging>
738 struct twrapper<
gui2::tmessage>
747 struct twrapper<
gui2::tmp_change_control>
756 struct twrapper<
gui2::tmp_cmd_wrapper>
765 struct twrapper<
gui2::tmp_create_game>
774 struct twrapper<
gui2::tmp_create_game_set_password>
784 struct twrapper<
gui2::tmp_join_game_password_prompt>
794 struct twrapper<
gui2::tdepcheck_confirm_change>
798 static std::vector<std::string> mods = {
"mod_one",
"some other",
"more"};
804 struct twrapper<
gui2::tdepcheck_select_new>
808 static std::vector<std::string> mods = {
"mod_one",
"some other",
"more"};
814 struct twrapper<
gui2::tmp_login>
823 struct twrapper<
gui2::tsimple_item_selector>
829 , std::vector<std::string>()
836 struct twrapper<
gui2::tscreenshot_notification>
845 struct twrapper<
gui2::tselect_orb_colors>
854 struct twrapper<
gui2::ttheme_list>
866 static std::vector<theme_info> themes = {make_theme(
"classic"),
867 make_theme(
"new"), make_theme(
"more"), make_theme(
"themes")};
873 struct twrapper<
gui2::teditor_generate_map>
878 BOOST_REQUIRE_MESSAGE(result,
"Failed to create a dialog.");
880 std::vector<map_generator*> map_generators;
882 if(
i[
"scenario_generation"] ==
"default") {
883 const config &generator_cfg =
i.child(
"generator");
885 map_generators.push_back(
897 struct twrapper<
gui2::teditor_new_map>
908 struct twrapper<
gui2::teditor_set_starting_position>
912 static std::vector<map_location>
locations;
919 struct twrapper<
gui2::teditor_resize_map>
923 static int width = 0;
927 static bool copy =
false;
937 struct twrapper<
gui2::tfolder_create>
947 struct twrapper<
gui2::tmp_server_list>
956 struct twrapper<
gui2::ttransient_message>
965 struct twrapper<
gui2::twml_error>
969 static std::vector<std::string> files = {
"some",
"files",
"here"};
975 struct twrapper<
gui2::twml_message_left>
984 struct twrapper<
gui2::twml_message_right>
bool new_widgets
Do we wish to use the new library or not.
child_itors child_range(const std::string &key)
Defines the exception classes for the layout algorithm.
std::string unit_test_mark_as_tested(const tdialog &dialog)
static config_cache & instance()
Get reference to the singleton object.
twindow * unit_test_window(const tpopup &dialog)
void set_map_generators(std::vector< map_generator * > mg)
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
bool show(CVideo &video, const unsigned auto_close_time=0)
Shows the window.
virtual void send_to_server(const config &cfg)=0
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
std::string unit_test_mark_popup_as_tested(const tpopup &dialog)
Main class to show messages to the user.
The paths manager is responsible for recording the various paths that binary files may be located at...
This class represents the collective information the client has about the players and games on the se...
Shows a transient message.
static std::vector< std::string > get_registered_window_list()
Returns a copy of the list of registered windows.
const std::vector< std::string > items
This class represents the information a client has about another player.
void load_config(const config &v)
std::string user_message
The message for the user explaining what went wrong.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
static UNUSEDNOWARN std::string _(const char *str)
virtual void send_chat_message(const std::string &message, bool allies_only=false)=0
std::size_t poll()
Handle all pending asynchonous events and return.
A class that represents a TCP/IP connection to the wesnothd server.
void draw()
Draws the window.
WML preprocessor/parser error report dialog.
Abstract base class for all dialogs.
The dialog for selecting which random generator to use in the editor.
std::string dev_message
The message for developers telling which problem was triggered, this shouldn't be translated...
void get_config(const std::string &path, config &cfg)
Gets a config object from given path.
std::pair< int, int > resolution()
Exception thrown when the width has been modified during resizing.
Exception thrown when the width resizing has failed.
GLsizei const GLint * locations
map_generator * create_map_generator(const std::string &name, const config &cfg)
void show(CVideo &video, const std::string &window_id, const t_string &message, const tpoint &mouse)
Shows a tip.
BOOST_AUTO_TEST_CASE(test_gui2)
tdialog * unit_test_mp_server_list()
void clear_defines()
Clear stored defines map to default values.
Game configuration data as global variables.
virtual void add_chat_message(const time_t &time, const std::string &speaker, int side, const std::string &message, MESSAGE_TYPE type=MESSAGE_PRIVATE)=0
bool load_language_list()
static tdialog * mp_server_list_for_unit_test()
The unit test needs to be able to test the tmp_connect dialog.
Shows a dialog with the portrait on the left side.
Shows a dialog with the portrait on the right side.
Declarations for File-IO.
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
GLuint const GLchar * name
game_classification & classification()
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...
A variable-expanding proxy for the config class.
CVideo & video()
Gets the underlying screen object.
Shows the list of addons on the server.
GLsizei GLenum GLuint GLuint GLsizei char * message
std::vector< std::string > & unit_test_registered_window_list()
const std::string remove
remove directive
GLint GLint GLint GLint GLint GLint GLsizei width
virtual const std::string & window_id() const =0
The id of the window to build.
A config object defines a single node in a WML file, with access to child nodes.
Helper class, don't construct this directly.
Exception thrown when the height resizing has failed.
void add_define(const std::string &define)
Add a entry to preproc defines map.
GLsizei const GLcharARB ** string
Singleton class to manage game config file caching.