17 #define GETTEXT_DOMAIN "wesnoth-lib"
134 #include <boost/test/unit_test.hpp>
136 #include <functional>
144 , dummy_args({
"wesnoth",
"--noaddons"})
201 T* create() {
return new T(); }
204 typedef std::pair<unsigned, unsigned>
resolution;
205 typedef std::vector<std::pair<unsigned, unsigned>> resolution_list;
208 void test_resolutions(
const resolution_list& resolutions)
213 dialog_tester<T> ctor;
214 const std::unique_ptr<modal_dialog> dlg(ctor.create());
215 BOOST_REQUIRE_MESSAGE(dlg.get(),
"Failed to create a dialog.");
220 std::string exception;
224 exception =
"gui2::layout_exception_width_modified";
226 exception =
"gui2::layout_exception_width_resize_failed";
228 exception =
"gui2::layout_exception_height_resize_failed";
230 exception =
e.dev_message;
231 }
catch(
const std::exception&
e) {
232 exception =
e.what();
236 BOOST_CHECK_MESSAGE(exception.empty(),
241 <<
"\nException caught: " << exception <<
'.');
246 void test_popup_resolutions(
const resolution_list& resolutions)
248 bool interact =
false;
249 for(
int i = 0;
i < 2; ++
i) {
257 dialog_tester<T> ctor;
258 const std::unique_ptr<modeless_dialog> dlg(ctor.create());
259 BOOST_REQUIRE_MESSAGE(dlg.get(),
"Failed to create a dialog.");
264 std::string exception;
268 BOOST_REQUIRE_NE(window,
static_cast<void*
>(
nullptr));
271 exception =
"gui2::layout_exception_width_modified";
273 exception =
"gui2::layout_exception_width_resize_failed";
275 exception =
"gui2::layout_exception_height_resize_failed";
277 exception =
e.dev_message;
278 }
catch(
const std::exception&
e) {
279 exception =
e.what();
283 BOOST_CHECK_MESSAGE(exception.empty(),
288 <<
"\nException caught: " << exception <<
'.');
296 #pragma warning(push)
297 #pragma warning(disable: 4702)
299 void test_tip_resolutions(
const resolution_list& resolutions
300 ,
const std::string&
id)
307 std::string exception;
310 ,
"Test message for a tooltip."
315 exception =
"gui2::layout_exception_width_modified";
317 exception =
"gui2::layout_exception_width_resize_failed";
319 exception =
"gui2::layout_exception_height_resize_failed";
321 exception =
e.dev_message;
322 }
catch(
const std::exception&
e) {
323 exception =
e.what();
327 BOOST_CHECK_MESSAGE(exception.empty(),
328 "Test for tip '" <<
id
332 <<
"\nException caught: " << exception <<
'.');
339 const resolution_list& get_gui_resolutions()
341 static resolution_list result {
358 test_resolutions<T>(get_gui_resolutions());
370 for(std::size_t
i = 0;
i < 2; ++
i) {
372 test_popup_resolutions<T>(get_gui_resolutions());
378 void test_tip(
const std::string&
id)
382 for(std::size_t
i = 0;
i < 2; ++
i) {
384 test_tip_resolutions(get_gui_resolutions(),
id);
400 test<addon_connect>();
404 test<addon_license_prompt>();
408 test<campaign_difficulty>();
416 test<editor_choose_addon>();
424 test<core_selection>();
432 test<depcheck_confirm_change>();
436 test<depcheck_select_new>();
444 test<editor_edit_pbl>();
448 test<editor_edit_pbl_translation>();
456 test<editor_edit_label>();
460 test<editor_edit_side>();
464 test<editor_edit_scenario>();
468 test<editor_generate_map>();
472 test<editor_new_map>();
476 test<editor_resize_map>();
480 test<faction_select>();
488 test<folder_create>();
492 test<formula_debugger>();
496 test<game_cache_options>();
504 test<game_version>();
512 test<game_save_message>();
516 test<game_save_oos>();
520 test<generator_settings>();
528 test<install_dependencies>();
532 test<language_selection>();
540 test<lobby_player_info>();
544 test<log_settings>();
552 test<mp_alerts_options>();
560 test<mp_join_game_password_prompt>();
568 test<mp_method_selection>();
576 test<simple_item_selector>();
580 test<screenshot_notification>();
584 test<select_orb_colors>();
588 test<statistics_dialog>();
592 test<surrender_quit>();
600 test<transient_message>();
612 test<wml_message_left>();
616 test<wml_message_right>();
620 test<wml_message_double>();
624 test<achievements_dialog>();
628 test<mp_match_history>();
632 test_popup<debug_clock>();
636 test_tip(
"tooltip_large");
644 test<tod_new_schedule>();
649 test<editor_edit_unit>();
657 std::set<std::string> omitted {
672 "addon_uninstall_list",
675 "network_transmission",
676 "synched_choice_wait",
678 "preferences_dialog",
683 "mp_host_game_prompt",
691 "attack_predictions",
697 "gamestate_inspector",
699 "sp_options_configure",
700 "campaign_selection",
706 for(
const std::string&
item : widgets_tested)
708 widget_list.erase(
item);
710 BOOST_CHECK_EQUAL(omitted.count(
item), 0);
712 for(
const std::string&
item : omitted)
714 widget_list.erase(
item);
718 BOOST_CHECK_EQUAL(widget_list.size(), 0);
719 for(
const std::string&
id : widget_list) {
720 PLAIN_LOG <<
"Window '" <<
id <<
"' registered but not tested.";
729 message dlg(
"title",
"message",
true,
false,
false);
732 BOOST_CHECK(
e.user_message ==
_(
"Failed to show a dialog, which doesn't fit on the screen."));
737 BOOST_ERROR(
"Didn't catch the wanted exception, instead caught nothing.");
740 BOOST_AUTO_TEST_SUITE_END()
757 std::string host_name =
"host_name";
767 std::string license_terms = R
"(Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ante nibh, dignissim ullamcorper tristique eget, condimentum sit amet enim. Aenean dictum pulvinar lacinia. Etiam eleifend, leo sed efficitur consectetur, augue nulla ornare lectus, vitae molestie lacus risus vitae libero. Quisque odio nunc, porttitor eget fermentum sit amet, faucibus eu risus. Praesent sit amet lacus tortor. Suspendisse volutpat quam vitae ipsum fermentum, in vulputate metus egestas. Nulla id consequat ex. Nulla ac dignissim nisl, nec euismod lectus. Duis vitae dolor ornare, convallis justo in, porta dui.
769 Sed faucibus nibh sit amet ligula porta, non malesuada nibh tristique. Maecenas aliquam diam non eros convallis mattis. Proin rhoncus condimentum leo, sed condimentum magna. Phasellus cursus condimentum lacus, sed sodales lacus. Sed pharetra dictum metus, eget dictum nibh lobortis imperdiet. Nunc tempus sollicitudin bibendum. In porttitor interdum orci. Curabitur vitae nibh vestibulum, condimentum lectus quis, condimentum dui. In quis cursus nisl. Maecenas semper neque eu ipsum aliquam, id porta ligula lacinia. Integer sed blandit ex, eu accumsan magna.)";
806 dialog_tester() : state(
config {
"campaign_type",
"scenario"}),
ng(state)
822 dialog_tester() : vcfg(cfg), r(rbase) {}
840 struct dialog_tester<
prompt>
852 std::vector<config> cores;
866 std::vector<time_of_day> times;
881 std::string
label =
"Label text to modify";
882 bool team_only =
false;
892 std::string text =
"text to modify";
895 return new edit_text(
"title",
"label", text);
902 std::string
label =
"Label text to modify";
903 std::string category =
"test";
904 bool immutable =
false,
fog =
false,
shroud =
false;
938 std::string
id, name, descr;
939 int turns = 0, xp_mod = 50;
940 bool defeat_enemies =
false, random_start =
false;
952 dialog_tester() :
info(
t) {}
992 std::string title =
"Title";
993 std::string filename =
"filename";
1004 std::string title =
"Title";
1005 std::string filename =
"filename";
1006 std::string
message =
"message";
1017 bool ignore_all =
false;
1018 std::string title =
"Title";
1019 std::string filename =
"filename";
1020 std::string
message =
"message";
1041 std::string
id =
"";
1056 dialog_tester() : connection(
"",
""), li()
1061 return new mp_lobby(li, connection, selected_game);
1069 dialog_tester() : connection(
"",
"")
1079 void add_chat_message(
const std::time_t&,
1080 const std::string&,
int,
const std::string&,
1082 void send_chat_message(
const std::string&,
bool) {}
1084 void clear_messages() {}
1091 fake_chat_handler ch;
1096 : connection(
"",
"")
1120 return new message(
"Title",
"Message",
false,
false,
false);
1128 dialog_tester() : state(
config {
"campaign_type",
"multiplayer"})
1150 std::string report_text;
1157 static std::vector<std::string> depcheck_mods {
"mod_one",
"some other",
"more"};
1182 return new mp_login(
"wesnoth.org",
"label",
true);
1207 static theme_info make_theme(
const std::string& name)
1215 static std::vector<theme_info> themes;
1221 std::vector<theme_info> dialog_tester<theme_list>::themes {make_theme(
"classic"), make_theme(
"new"), make_theme(
"more"), make_theme(
"themes")};
1226 std::vector<std::unique_ptr<map_generator>> map_generators;
1230 if(
i[
"scenario_generation"] ==
"default") {
1231 auto generator_cfg =
i.optional_child(
"generator");
1232 if (generator_cfg) {
1239 BOOST_REQUIRE_MESSAGE(result,
"Failed to create a dialog.");
1281 std::string folder_name;
1300 std::vector<std::string> args;
1303 dialog_tester() : opts(args),
game(opts) {}
1313 static std::vector<std::string> files;
1316 return new wml_error(
"Summary",
"Post summary", files,
"Details");
1319 std::vector<std::string> dialog_tester<wml_error>::files {
"some",
"files",
"here"};
1351 config era_cfg, side_cfg;
1352 std::vector<const config*> eras;
1356 : era_cfg(), side_cfg(), eras(1, &era_cfg)
1357 , flg(eras, side_cfg, false, false, false)
1370 dialog_tester() :
data(cfg) {}
1383 dialog_tester() : create_eng(state)
1384 , config_eng(create_eng.get_state()) {}
1397 dialog_tester() :
t() , stats_record(), stats(stats_record) {}
1417 std::string
id =
"id";
1418 std::string name =
"name";
1438 movetype[
"name"] =
"Test Movetype";
1441 movetype.add_child(
"movement_costs");
Add-ons (campaignd) client class.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
Singleton class to manage game config file caching.
void add_define(const std::string &define)
Add a entry to preproc defines map.
static config_cache & instance()
Get reference to the singleton object.
void clear_defines()
Clear stored defines map to default values.
void get_config(const std::string &path, config &cfg, abstract_validator *validator=nullptr)
Gets a config object from given path.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
static game_config_view wrap(const config &cfg)
This shows the dialog to provide a password when uploading an add-on.
This shows the dialog for managing addons and connecting to the addon server.
Shows the list of addons on the server available for installation.
The campaign mode difficulty menu.
This shows the dialog which allows the user to choose which campaign to play.
This shows the dialog which allows the user to choose which core to play.
This shows the dialog to modify tod schedules.
Asks the user to confirm a change required to proceed.
Offers a list of compatible items if a currently selected one is incompatible.
Dialog for editing gamemap labels.
Dialog for renaming units in-game.
Dialog for adding a translation while editing an add-on's _server.pbl.
Dialog for editing gamemap labels.
Dialog for adding a translation while editing an add-on's _server.pbl.
Dialog for editing an add-on's _server.pbl.
Dialog for editing gamemap scenarios.
Dialog for editing gamemap sides.
Dialog that allows user to create custom unit types.
The dialog for selecting which random generator to use in the editor.
This shows the dialog to resize the current map.
Dialog for providing the name of a new folder to create.
This shows the dialog to select and load a savegame file.
This shows the dialog to create a savegame file.
Main class to show messages to the user.
Abstract base class for all modal dialogs.
virtual const std::string & window_id() const =0
The ID of the window to build.
bool show(const unsigned auto_close_time=0)
Shows the window.
The popup class shows windows that are shown non-modal.
virtual const std::string & window_id() const
The ID of the window to build.
Dialog for entering a password for joining a password-protected MP game.
This shows the dialog to log in to the MP server.
This shows a dialog to report players on the multiplayer server.
Dialog for getting a single text value from the player.
Notification dialog used after saving a game or map screenshot to display information about it for th...
A simple one-column listbox with OK and Cancel buttons.
This shows the dialog to confirm surrender and/or quitting the game.
Dialog for selecting a GUI theme.
This class implements the title screen.
Dialog that takes new schedule ID and name from the player.
Shows a transient message.
WML preprocessor/parser error report dialog.
Shows a dialog with two portraits, one on each side.
Shows a dialog with the portrait on the left side.
Shows a dialog with the portrait on the right side.
base class of top level items, the only item which needs to store the final canvases to draw on.
void draw()
Draws the window.
The basic "size" of the unit - flying, small land, large land, etc.
This class represents the collective information the client has about the players and games on the se...
FLG stands for faction, leader and gender.
static std::shared_ptr< save_index_class > default_saves_dir()
Returns an instance for managing saves in filesystem::get_saves_dir()
This class stores all the data for a single 'side' (in game nomenclature).
A variable-expanding proxy for the config class.
A class that represents a TCP/IP connection to the wesnothd server.
Networked add-ons (campaignd) client interface.
Declarations for File-IO.
static std::string _(const char *str)
std::string label
What to show in the filter's drop-down list.
std::string id
Text to match against addon_info.tags()
std::map< std::string, addon_info > addons_list
bool load_language_list()
Defines the exception classes for the layout algorithm.
map_generator * create_map_generator(const std::string &name, const config &cfg, const config *vars)
Various uncategorised dialogs.
void point(int x, int y)
Draw a single point.
bool delete_file(const std::string &filename)
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
void write_file(const std::string &fname, const std::string &data, std::ios_base::openmode mode)
Throws io_exception if an error occurs.
Game configuration data as global variables.
void load_config(const config &v)
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
void remove()
Removes a tip.
std::string get_modal_dialog_id(const modal_dialog &dialog)
std::string get_modeless_dialog_id(const modeless_dialog &dialog)
std::set< std::string > & registered_window_types()
Returns the list of registered windows.
bool new_widgets
Do we wish to use the new library or not.
std::pair< std::string, unsigned > item
const std::vector< std::string > items
void send_to_server(const config &data)
Attempts to send given data to server if a connection is open.
std::string password(const std::string &server, const std::string &login)
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
std::vector< std::string > split(const config_attribute_value &val)
This file contains the settings handling of the widget library.
The basic class for representing 8-bit RGB or RGBA colour values.
The paths manager is responsible for recording the various paths that binary files may be located at.
Exception thrown when the height resizing has failed.
Exception thrown when the width has been modified during resizing.
Exception thrown when the width resizing has failed.
This class represents the information a client has about another player.
static config main_config
std::unique_ptr< game_config_manager > config_manager
std::vector< std::string > dummy_args
static const std::string widgets_file
Helper class, don't construct this directly.
BOOST_AUTO_TEST_CASE(modal_dialog_test_addon_auth)
BOOST_FIXTURE_TEST_SUITE(test_map_location, MLFixture)
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...