The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_gui2.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 // In this domain since it compares a shared string from this domain.
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
18 #include <boost/test/unit_test.hpp>
19 
20 #include "config_cache.hpp"
21 #include "filesystem.hpp"
22 #include "formula/debugger.hpp"
23 #include "gettext.hpp"
24 #include "game_classification.hpp"
25 #include "game_config.hpp"
26 #include "game_display.hpp"
35 #include "gui/dialogs/chat_log.hpp"
56 #include "gui/dialogs/logging.hpp"
58 #include "gui/dialogs/message.hpp"
75 #include "gui/dialogs/tip.hpp"
82 #include "gui/widgets/settings.hpp"
83 #include "gui/widgets/window.hpp"
84 #include "language.hpp"
87 #include "saved_game.hpp"
88 //#include "scripting/lua_kernel_base.hpp"
89 #include "video.hpp"
90 #include "wesnothd_connection.hpp"
91 #include "wml_exception.hpp"
92 
93 #include "utils/functional.hpp"
94 
95 #include <memory>
96 
97 namespace gui2 {
98 
99 std::vector<std::string>& unit_test_registered_window_list()
100 {
101  static std::vector<std::string> result =
103 
104  return result;
105 }
106 
108 {
109  std::vector<std::string>& list = unit_test_registered_window_list();
110  list.erase(
111  std::remove(list.begin(), list.end(), dialog.window_id())
112  , list.end());
113  return dialog.window_id();
114 }
115 
117 {
118  std::vector<std::string>& list = unit_test_registered_window_list();
119  list.erase(
120  std::remove(list.begin(), list.end(), dialog.window_id())
121  , list.end());
122  return dialog.window_id();
123 }
124 
126 {
127  return dialog.window_;
128 }
129 
130 class tmp_server_list;
131 
133 {
135 }
136 
137 } // namespace gui2
138 
139 namespace {
140 
141  /** The main config, which contains the entire WML tree. */
142  config main_config;
143 
144  /**
145  * Helper class to generate a dialog.
146  *
147  * This class makes sure the dialog is properly created and initialized.
148  * The specialized versions are at the end of this file.
149  */
150  template<class T>
151  struct twrapper
152  {
153  static T* create() { return new T(); }
154  };
155 
156  typedef std::pair<unsigned, unsigned> tresolution;
157  typedef std::vector<std::pair<unsigned, unsigned> > tresolution_list;
158 
159  template<class T>
160  void test_resolutions(const tresolution_list& resolutions)
161  {
162  for(const tresolution& resolution : resolutions) {
164 
165  boost::scoped_ptr<gui2::tdialog> dlg(twrapper<T>::create());
166  BOOST_REQUIRE_MESSAGE(dlg.get(), "Failed to create a dialog.");
167 
168  const std::string id = gui2::unit_test_mark_as_tested(*(dlg.get()));
169 
170  std::string exception;
171  try {
172  dlg->show(video, 1);
174  exception = "gui2::tlayout_exception_width_modified";
176  exception = "gui2::tlayout_exception_width_resize_failed";
178  exception = "gui2::tlayout_exception_height_resize_failed";
179  } catch(twml_exception& e) {
180  exception = e.dev_message;
181  } catch(std::exception& e) {
182  exception = e.what();
183  } catch(...) {
184  exception = "unknown";
185  }
186  BOOST_CHECK_MESSAGE(exception.empty(),
187  "Test for '" << id
188  << "' Failed\nnew widgets = " << gui2::new_widgets
189  << " resolution = " << resolution.first
190  << 'x' << resolution.second
191  << "\nException caught: " << exception << '.');
192  }
193  }
194 
195  template<class T>
196  void test_popup_resolutions(const tresolution_list& resolutions)
197  {
198  bool interact = false;
199  for(int i = 0; i < 2; ++i) {
200  for(const tresolution& resolution : resolutions) {
202 
203  boost::scoped_ptr<gui2::tpopup> dlg(twrapper<T>::create());
204  BOOST_REQUIRE_MESSAGE(dlg.get(), "Failed to create a dialog.");
205 
206  const std::string id = gui2::unit_test_mark_popup_as_tested(*(dlg.get()));
207 
208  std::string exception;
209  try {
210  dlg->show(video, interact);
211  gui2::twindow* window = gui2::unit_test_window((*dlg.get()));
212  BOOST_REQUIRE_NE(window, static_cast<void*>(nullptr));
213  window->draw();
215  exception = "gui2::tlayout_exception_width_modified";
217  exception = "gui2::tlayout_exception_width_resize_failed";
219  exception = "gui2::tlayout_exception_height_resize_failed";
220  } catch(twml_exception& e) {
221  exception = e.dev_message;
222  } catch(std::exception& e) {
223  exception = e.what();
224  } catch(...) {
225  exception = "unknown";
226  }
227  BOOST_CHECK_MESSAGE(exception.empty(),
228  "Test for '" << id
229  << "' Failed\nnew widgets = " << gui2::new_widgets
230  << " resolution = " << resolution.first
231  << 'x' << resolution.second
232  << "\nException caught: " << exception << '.');
233  }
234 
235  interact = true;
236  }
237  }
238 
239 #ifdef _MSC_VER
240 #pragma warning(push)
241 #pragma warning(disable: 4702)
242 #endif
243  void test_tip_resolutions(const tresolution_list& resolutions
244  , const std::string& id)
245  {
246  for(const tresolution& resolution : resolutions) {
247 
248  //CVideo& video = test_utils::get_fake_display(resolution.first, resolution.second).video();
249 
250  std::vector<std::string>& list =
252  list.erase(std::remove(list.begin(), list.end(), id), list.end());
253 
254  std::string exception;
255  try {
256 /**
257  * @todo The code crashes for some unknown reason when this code is disabled.
258  * The backtrace however doesn't show this path, in fact the crash occurs
259  * before this code is used. So not entirely sure whether it's a compiler bug
260  * or a part of the static initialization fiasco. Need to test with different
261  * compilers and try to find the cause.
262  */
263 #if 0
264  gui2::tip::show(video
265  , id
266  , "Test messsage for a tooltip."
267  , gui2::tpoint(0, 0));
268 #endif
270  exception = "gui2::tlayout_exception_width_modified";
272  exception = "gui2::tlayout_exception_width_resize_failed";
274  exception = "gui2::tlayout_exception_height_resize_failed";
275  } catch(twml_exception& e) {
276  exception = e.dev_message;
277  } catch(std::exception& e) {
278  exception = e.what();
279  } catch(...) {
280  exception = "unknown";
281  }
282  BOOST_CHECK_MESSAGE(exception.empty(),
283  "Test for tip '" << id
284  << "' Failed\nnew widgets = " << gui2::new_widgets
285  << " resolution = " << resolution.first
286  << 'x' << resolution.second
287  << "\nException caught: " << exception << '.');
288  }
289  }
290 #ifdef _MSC_VER
291 #pragma warning(pop)
292 #endif
293 
294 const tresolution_list& get_gui_resolutions()
295 {
296  static tresolution_list result;
297  if(result.empty()) {
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));
302  }
303  return result;
304 }
305 
306 template<class T>
307 void test()
308 {
309  gui2::new_widgets = false;
310 
311  for(size_t i = 0; i < 2; ++i) {
312 
313  test_resolutions<T>(get_gui_resolutions());
314 
315  break; // FIXME: New widgets break
316  gui2::new_widgets = true;
317  }
318 }
319 
320 template<class T>
321 void test_popup()
322 {
323  gui2::new_widgets = false;
324 
325  for(size_t i = 0; i < 2; ++i) {
326 
327  test_popup_resolutions<T>(get_gui_resolutions());
328 
329  gui2::new_widgets = true;
330  }
331 }
332 
333 void test_tip(const std::string& id)
334 {
335  gui2::new_widgets = false;
336 
337  for(size_t i = 0; i < 2; ++i) {
338 
339  test_tip_resolutions(get_gui_resolutions(), id);
340 
341  gui2::new_widgets = true;
342  }
343 }
344 
345 } // namespace
346 
348 {
349  /**** Initialize the environment. *****/
351 
352  cache.clear_defines();
353  cache.add_define("EDITOR");
354  cache.add_define("MULTIPLAYER");
355  cache.get_config(game_config::path +"/data", main_config);
356 
357  const filesystem::binary_paths_manager bin_paths_manager(main_config);
358 
360  game_config::load_config(main_config.child("game_config"));
361 
362  /**** Run the tests. *****/
363 
364  /* The tdialog classes. */
365  test<gui2::taddon_connect>();
366  //test<gui2::taddon_list>();
367  test<gui2::tcampaign_difficulty>();
368  test<gui2::tcampaign_selection>();
369  test<gui2::tcampaign_settings>();
370 // test<gui2::tchat_log>(); /** @todo ENABLE */
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>();
388  // test<gui2::tloadscreen>(); TODO: enable
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>();
410  //test<gui2::tunit_attack>();
411  test<gui2::tunit_create>();
412  //test<gui2::tunit_recruit>();
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>();
418 
419  //test<gui2::tlua_interpreter>(& lua_kernel_base());
420 
421  /* The tpopup classes. */
422  test_popup<gui2::tdebug_clock>();
423 
424  /* The tooltip classes. */
425  test_tip("tooltip_large");
426 
427  std::vector<std::string>& list = gui2::unit_test_registered_window_list();
428 
429  /*
430  * The unit attack unit test are disabled for now, they calling parameters
431  * don't allow 'nullptr's needs to be fixed.
432  */
433  list.erase(
434  std::remove(list.begin(), list.end(), "unit_attack")
435  , list.end());
436  /*
437  * The chat log unit test are disabled for now, they calling parameters
438  * don't allow 'nullptr's needs to be fixed.
439  */
440  list.erase(
441  std::remove(list.begin(), list.end(), "chat_log")
442  , list.end());
443 
444  // No test for this right now, not sure how to use the test system
445  // for dialog with no default constructor
446  list.erase(
447  std::remove(list.begin(), list.end(), "lua_interpreter")
448  , list.end());
449 
450  /*
451  * Disable label settings dialog test because we need a display_context
452  * object, which we don't have, and it's a lot of work to produce a dummy
453  * one.
454  */
455  list.erase(
456  std::remove(list.begin(), list.end(), "label_settings")
457  , list.end());
458 
459  //Window 'addon_description' registered but not tested.
460  //Window 'addon_filter_options' registered but not tested.
461  //Window 'addon_uninstall_list' registered but not tested.
462  //Window 'network_transmission' registered but not tested.
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());
473 
474  // Test size() instead of empty() to get the number of offenders
475  BOOST_CHECK_EQUAL(list.size(), 0);
476  for(const std::string& id : list) {
477  std::cerr << "Window '" << id << "' registered but not tested.\n";
478  }
479 }
480 
481 BOOST_AUTO_TEST_CASE(test_make_test_fake)
482 {
483  CVideo& video = test_utils::get_fake_display(10, 10).video();
484 
485  try {
486  gui2::tmessage dlg("title", "message", true, false);
487  dlg.show(video, 1);
488  } catch(twml_exception& e) {
489  BOOST_CHECK(e.user_message == _("Failed to show a dialog, "
490  "which doesn't fit on the screen."));
491  return;
492  } catch(...) {
493  }
494  BOOST_ERROR("Didn't catch the wanted exception.");
495 }
496 
497 namespace {
498 
499 template<>
500 struct twrapper<gui2::taddon_connect>
501 {
502  static gui2::taddon_connect* create()
503  {
504  static std::string host_name = "host_name";
505  return new gui2::taddon_connect(host_name, true);
506  }
507 };
508 
509 template<>
510 struct twrapper<gui2::taddon_list>
511 {
512  static gui2::taddon_list* create()
513  {
514  /** @todo Would nice to add one or more dummy addons in the list. */
515  static config cfg;
516  return new gui2::taddon_list(cfg);
517  }
518 };
519 
520 template<>
521 struct twrapper<gui2::tcampaign_difficulty>
522 {
524  {
525  static const config items;
526 
527  return new gui2::tcampaign_difficulty(items);
528  }
529 };
530 
531 template<>
532 struct twrapper<gui2::tcampaign_selection>
533 {
535  {
536  static saved_game state;
538  static ng::create_engine ng(test_utils::get_fake_display(-1, -1).video(), state);
539  return new gui2::tcampaign_selection(ng);
540  }
541 };
542 
543 template<>
544 struct twrapper<gui2::tcampaign_settings>
545 {
547  {
548  static saved_game state;
550  static ng::create_engine ng(test_utils::get_fake_display(-1, -1).video(), state);
551  return new gui2::tcampaign_settings(ng);
552  }
553 };
554 
555 template<>
556 struct twrapper<gui2::tchat_log>
557 {
558  static gui2::tchat_log* create()
559  {
560  static config cfg;
561  static vconfig vcfg(cfg);
562 
563  return new gui2::tchat_log(vcfg, nullptr);
564  }
565 };
566 
567 template<>
568 struct twrapper<gui2::tedit_label>
569 {
570  static gui2::tedit_label* create()
571  {
572  static std::string label = "Label text to modify";
573  static bool team_only = false;
574  return new gui2::tedit_label(label, team_only);
575  }
576 };
577 
578 template<>
579 struct twrapper<gui2::tedit_text>
580 {
581  static gui2::tedit_text* create()
582  {
583  static std::string text = "text to modify";
584  return new gui2::tedit_text("title", "label", text);
585  }
586 };
587 
588 template<>
589 struct twrapper<gui2::tformula_debugger>
590 {
592  {
593  static game_logic::formula_debugger debugger;
594  return new gui2::tformula_debugger(debugger);
595  }
596 };
597 
598 template<>
599 struct twrapper<gui2::tgame_load>
600 {
601  static gui2::tgame_load* create()
602  {
603  /** @todo Would be nice to add real data to the config. */
604  static config cfg;
605  return new gui2::tgame_load(cfg);
606  }
607 
608 };
609 
610 template<>
611 struct twrapper<gui2::tgame_version>
612 {
613  static gui2::tgame_version* create()
614  {
615  return new gui2::tgame_version();
616  }
617 
618 };
619 
620 template<>
621 struct twrapper<gui2::tgame_save>
622 {
623  static gui2::tgame_save* create()
624  {
625  static std::string title = "Title";
626  static std::string filename = "filename";
627  return new gui2::tgame_save(title, filename);
628  }
629 
630 };
631 
632 template<>
633 struct twrapper<gui2::tgame_save_message>
634 {
636  {
637  static std::string title = "Title";
638  static std::string filename = "filename";
639  static std::string message = "message";
640  return new gui2::tgame_save_message(title, filename, message);
641  }
642 
643 };
644 
645 template<>
646 struct twrapper<gui2::tgame_save_oos>
647 {
648  static gui2::tgame_save_oos* create()
649  {
650  static bool ignore_all = false;
651  static std::string title = "Title";
652  static std::string filename = "filename";
653  static std::string message = "message";
654  return new gui2::tgame_save_oos(ignore_all, title, filename, message);
655  }
656 
657 };
658 
659 template<>
660 struct twrapper<gui2::tgamestate_inspector>
661 {
663  {
664  /**
665  * @todo Would be nice to add real data to the vconfig.
666  * It would also involve adding real data to the resources.
667  */
668  static config cfg;
669  static vconfig vcfg(cfg);
670  return new gui2::tgamestate_inspector(vcfg);
671  }
672 
673 };
674 struct twesnothd_connection_init
675 {
676  twesnothd_connection_init(twesnothd_connection& conn)
677  {
678  //Swallow the 'cannot connect' execption so that the wesnothd_connection object doesn't throw while we test the dialog.
679  try
680  {
681  while (true) {
682  conn.poll();
683  }
684  }
685  catch (...)
686  {
687 
688  }
689  }
690 };
691 template<>
692 struct twrapper<gui2::tlobby_main>
693 {
694  static gui2::tlobby_main* create()
695  {
696  static config game_config;
697  static twesnothd_connection wesnothd_connection("", "");
698  static twesnothd_connection_init wesnothd_connection_init(wesnothd_connection);
699  static lobby_info li(game_config, wesnothd_connection);
700  return new gui2::tlobby_main(game_config, li,
701  static_cast<display*>(&test_utils::get_fake_display(-1, -1))->video(), wesnothd_connection);
702  }
703 };
704 
705 class fake_chat_handler : public events::chat_handler {
706  void add_chat_message(const time_t&,
707  const std::string&, int, const std::string&,
708  MESSAGE_TYPE) {}
709  void send_chat_message(const std::string&, bool) {}
710  void send_to_server(const config&) {}
711 };
712 
713 template<>
714 struct twrapper<gui2::tlobby_player_info>
715 {
717  {
718  static config c;
719  static fake_chat_handler ch;
720  static user_info ui(c);
721  static twesnothd_connection wesnothd_connection("", "");
722  static twesnothd_connection_init wesnothd_connection_init(wesnothd_connection);
723  static lobby_info li(c, wesnothd_connection);
724  return new gui2::tlobby_player_info(ch, ui, li);
725  }
726 };
727 
728 template<>
729 struct twrapper<gui2::tlogging>
730 {
731  static gui2::tlogging* create()
732  {
733  return new gui2::tlogging();
734  }
735 };
736 
737 template<>
738 struct twrapper<gui2::tmessage>
739 {
740  static gui2::tmessage* create()
741  {
742  return new gui2::tmessage("Title", "Message", false, false);
743  }
744 };
745 
746 template<>
747 struct twrapper<gui2::tmp_change_control>
748 {
750  {
751  return new gui2::tmp_change_control(nullptr);
752  }
753 };
754 
755 template<>
756 struct twrapper<gui2::tmp_cmd_wrapper>
757 {
758  static gui2::tmp_cmd_wrapper* create()
759  {
760  return new gui2::tmp_cmd_wrapper("foo");
761  }
762 };
763 
764 template<>
765 struct twrapper<gui2::tmp_create_game>
766 {
767  static gui2::tmp_create_game* create()
768  {
769  return new gui2::tmp_create_game(main_config);
770  }
771 };
772 
773 template<>
774 struct twrapper<gui2::tmp_create_game_set_password>
775 {
777  {
778  static std::string password;
779  return new gui2::tmp_create_game_set_password(password);
780  }
781 };
782 
783 template<>
784 struct twrapper<gui2::tmp_join_game_password_prompt>
785 {
787  {
788  static std::string password;
789  return new gui2::tmp_join_game_password_prompt(password);
790  }
791 };
792 
793 template<>
794 struct twrapper<gui2::tdepcheck_confirm_change>
795 {
797  {
798  static std::vector<std::string> mods = {"mod_one", "some other", "more"};
799  return new gui2::tdepcheck_confirm_change(true, mods, "requester");
800  }
801 };
802 
803 template<>
804 struct twrapper<gui2::tdepcheck_select_new>
805 {
807  {
808  static std::vector<std::string> mods = {"mod_one", "some other", "more"};
810  }
811 };
812 
813 template<>
814 struct twrapper<gui2::tmp_login>
815 {
816  static gui2::tmp_login* create()
817  {
818  return new gui2::tmp_login("label", true);
819  }
820 };
821 
822 template<>
823 struct twrapper<gui2::tsimple_item_selector>
824 {
826  {
827  return new gui2::tsimple_item_selector("title"
828  , "message"
829  , std::vector<std::string>()
830  , false
831  , false);
832  }
833 };
834 
835 template<>
836 struct twrapper<gui2::tscreenshot_notification>
837 {
839  {
840  return new gui2::tscreenshot_notification("path");
841  }
842 };
843 
844 template<>
845 struct twrapper<gui2::tselect_orb_colors>
846 {
848  {
849  return new gui2::tselect_orb_colors();
850  }
851 };
852 
853 template<>
854 struct twrapper<gui2::ttheme_list>
855 {
856  static theme_info make_theme(std::string name)
857  {
858  theme_info ti;
859  ti.id = name;
860  ti.name = name;
861  ti.description = name + " this is a description";
862  return ti;
863  }
864  static gui2::ttheme_list* create()
865  {
866  static std::vector<theme_info> themes = {make_theme("classic"),
867  make_theme("new"), make_theme("more"), make_theme("themes")};
868  return new gui2::ttheme_list(themes, 0);
869  }
870 };
871 
872 template<>
873 struct twrapper<gui2::teditor_generate_map>
874 {
876  {
878  BOOST_REQUIRE_MESSAGE(result, "Failed to create a dialog.");
879 
880  std::vector<map_generator*> map_generators;
881  for(const config &i : main_config.child_range("multiplayer")) {
882  if(i["scenario_generation"] == "default") {
883  const config &generator_cfg = i.child("generator");
884  if (generator_cfg) {
885  map_generators.push_back(
886  create_map_generator("", generator_cfg));
887  }
888  }
889  }
890  result->set_map_generators(map_generators);
891 
892  return result;
893  }
894 };
895 
896 template<>
897 struct twrapper<gui2::teditor_new_map>
898 {
899  static gui2::teditor_new_map* create()
900  {
901  static int width;
902  static int height;
903  return new gui2::teditor_new_map(width, height);
904  }
905 };
906 
907 template<>
908 struct twrapper<gui2::teditor_set_starting_position>
909 {
911  {
912  static std::vector<map_location> locations;
913 
914  return new gui2::teditor_set_starting_position(0, 0, locations);
915  }
916 };
917 
918 template<>
919 struct twrapper<gui2::teditor_resize_map>
920 {
922  {
923  static int width = 0;
924  static int height = 0;
925  static gui2::teditor_resize_map::EXPAND_DIRECTION expand_direction =
927  static bool copy = false;
928  return new gui2::teditor_resize_map(
929  width
930  , height
931  , expand_direction
932  , copy);
933  }
934 };
935 
936 template<>
937 struct twrapper<gui2::tfolder_create>
938 {
939  static gui2::tfolder_create* create()
940  {
941  static std::string folder_name;
942  return new gui2::tfolder_create(folder_name);
943  }
944 };
945 
946 template<>
947 struct twrapper<gui2::tmp_server_list>
948 {
949  static gui2::tdialog* create()
950  {
952  }
953 };
954 
955 template<>
956 struct twrapper<gui2::ttransient_message>
957 {
959  {
960  return new gui2::ttransient_message("Title", false, "Message", false, "");
961  }
962 };
963 
964 template<>
965 struct twrapper<gui2::twml_error>
966 {
967  static gui2::twml_error* create()
968  {
969  static std::vector<std::string> files = {"some", "files", "here"};
970  return new gui2::twml_error("Summary", "Post summary", files, "Details");
971  }
972 };
973 
974 template<>
975 struct twrapper<gui2::twml_message_left>
976 {
978  {
979  return new gui2::twml_message_left("Title", "Message", "", false);
980  }
981 };
982 
983 template<>
984 struct twrapper<gui2::twml_message_right>
985 {
987  {
988  return new gui2::twml_message_right("Title", "Message", "", false);
989  }
990 };
991 
992 } // namespace
993 
twindow * window_
The window, used in show.
Definition: popup.hpp:85
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:40
t_string description
Definition: theme.hpp:34
child_itors child_range(const std::string &key)
Definition: config.cpp:613
Defines the exception classes for the layout algorithm.
std::string unit_test_mark_as_tested(const tdialog &dialog)
Definition: test_gui2.cpp:107
static config_cache & instance()
Get reference to the singleton object.
twindow * unit_test_window(const tpopup &dialog)
Definition: test_gui2.cpp:125
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...
static void create(std::string &command, std::string::const_iterator begin)
Definition: window.cpp:24
bool show(CVideo &video, const unsigned auto_close_time=0)
Shows the window.
Definition: dialog.cpp:34
Formula AI debugger.
virtual void send_to_server(const config &cfg)=0
std::string id
Definition: theme.hpp:32
Definition: video.hpp:58
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)
Definition: test_gui2.cpp:116
t_string name
Definition: theme.hpp:33
This file contains the window object, this object is a top level container which has the event manage...
Main class to show messages to the user.
Definition: message.hpp:32
The paths manager is responsible for recording the various paths that binary files may be located at...
Definition: filesystem.hpp:210
This class represents the collective information the client has about the players and games on the se...
Definition: info.hpp:25
Addon connect dialog.
Definition: connect.hpp:26
Shows a transient message.
static std::vector< std::string > get_registered_window_list()
Returns a copy of the list of registered windows.
Definition: settings.cpp:479
const std::vector< std::string > items
-file util.hpp
This class represents the information a client has about another player.
Definition: data.hpp:102
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 ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
virtual void send_chat_message(const std::string &message, bool allies_only=false)=0
GLuint64EXT * result
Definition: glew.h:10727
std::size_t poll()
Handle all pending asynchonous events and return.
A class that represents a TCP/IP connection to the wesnothd server.
GLuint id
Definition: glew.h:1647
virtual const std::string & window_id() const =0
The id of the window to build.
This file contains the settings handling of the widget library.
void draw()
Draws the window.
Definition: window.cpp:738
WML preprocessor/parser error report dialog.
Definition: wml_error.hpp:24
Abstract base class for all dialogs.
Definition: dialog.hpp:121
The popup class shows windows that are shown non-modal.
Definition: popup.hpp:33
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()
std::string path
Exception thrown when the width has been modified during resizing.
Exception thrown when the width resizing has failed.
GLsizei const GLint * locations
Definition: glew.h:11075
map_generator * create_map_generator(const std::string &name, const config &cfg)
Definition: map_create.cpp:31
void show(CVideo &video, const std::string &window_id, const t_string &message, const tpoint &mouse)
Shows a tip.
Definition: tip.cpp:133
BOOST_AUTO_TEST_CASE(test_gui2)
Definition: test_gui2.cpp:347
tdialog * unit_test_mp_server_list()
Definition: test_gui2.cpp:132
void clear_defines()
Clear stored defines map to default values.
Game configuration data as global variables.
Definition: build_info.cpp:38
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
static tcache cache
Definition: minimap.cpp:139
bool load_language_list()
Definition: language.cpp:94
static tdialog * mp_server_list_for_unit_test()
The unit test needs to be able to test the tmp_connect dialog.
Definition: mp_connect.cpp:190
Shows a dialog with the portrait on the left side.
size_t i
Definition: function.cpp:1057
Holds a 2D point.
Definition: point.hpp:24
Shows a dialog with the portrait on the right side.
Declarations for File-IO.
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1220
GLuint const GLchar * name
Definition: glew.h:1782
game_classification & classification()
Definition: saved_game.hpp:54
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...
Definition: config.cpp:658
A variable-expanding proxy for the config class.
Definition: variable.hpp:36
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:202
Shows the list of addons on the server.
Definition: list.hpp:35
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
#define c
Definition: glew.h:12743
std::vector< std::string > & unit_test_registered_window_list()
Definition: test_gui2.cpp:99
const std::string remove
remove directive
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1220
#define e
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.
Definition: config.hpp:83
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
Definition: glew.h:4503
static void test()
Singleton class to manage game config file caching.