From d33c8fcf4fdb8b2f1adbcb2dcbe62c16945462ba Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sun, 6 Mar 2011 14:14:07 +0000 Subject: [PATCH] Enable the unit test for tmp_server_list. It involves the tmp_connect class since it has access to the class, not really clean, but marked for unit tests only. --- src/gui/dialogs/mp_connect.cpp | 5 +++++ src/gui/dialogs/mp_connect.hpp | 9 +++++++++ src/tests/gui/test_gui2.cpp | 24 +++++++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/gui/dialogs/mp_connect.cpp b/src/gui/dialogs/mp_connect.cpp index bea22ed0081..37099c93690 100644 --- a/src/gui/dialogs/mp_connect.cpp +++ b/src/gui/dialogs/mp_connect.cpp @@ -181,5 +181,10 @@ void tmp_connect::pre_show(CVideo& video, twindow& window) } +tdialog* tmp_connect::mp_server_list_for_unit_test() +{ + return new tmp_server_list(); +} + } // namespace gui2 diff --git a/src/gui/dialogs/mp_connect.hpp b/src/gui/dialogs/mp_connect.hpp index b7b886551c6..1ab13ca5d92 100644 --- a/src/gui/dialogs/mp_connect.hpp +++ b/src/gui/dialogs/mp_connect.hpp @@ -22,6 +22,8 @@ namespace gui2 { class tmp_connect : public tdialog { + /** The unit test needs to be able to test the tmp_connect dialog. */ + friend tdialog* unit_test_mp_server_list(); public: tmp_connect(); @@ -35,6 +37,13 @@ private: /** The host name of the selected servef. */ tfield_text* host_name_; + + /** + * The unit test needs to be able to test the tmp_connect dialog. + * + * @returns A newly allocated tmp_server_list. + */ + static tdialog* mp_server_list_for_unit_test(); }; } // namespace gui2 diff --git a/src/tests/gui/test_gui2.cpp b/src/tests/gui/test_gui2.cpp index 210193326e8..38504eaad4a 100644 --- a/src/tests/gui/test_gui2.cpp +++ b/src/tests/gui/test_gui2.cpp @@ -84,7 +84,15 @@ std::string unit_test_mark_as_tested(const tdialog& dialog) return dialog.window_id(); } -}// namespace gui2 + +class tmp_server_list; + +tdialog* unit_test_mp_server_list() +{ + return tmp_connect::mp_server_list_for_unit_test(); +} + +} // namespace gui2 namespace { @@ -225,7 +233,7 @@ BOOST_AUTO_TEST_CASE(test_gui2) test(); test(); test(); -// test(); /** @todo ENABLE */ + test(); test(); test(); // test(); /** @todo ENABLE */ @@ -250,9 +258,6 @@ BOOST_AUTO_TEST_CASE(test_gui2) list.erase( std::remove(list.begin(), list.end(), "unit_attack") , list.end()); - list.erase( - std::remove(list.begin(), list.end(), "mp_server_list") - , list.end()); list.erase( std::remove(list.begin(), list.end(), "tooltip_large") , list.end()); @@ -501,6 +506,15 @@ struct twrapper } }; +template<> +struct twrapper +{ + static gui2::tdialog* create() + { + return gui2::unit_test_mp_server_list(); + } +}; + template<> struct twrapper {