mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 11:53:48 +00:00
Enable tests for tooltips and several previously excluded dialogs
This commit is contained in:
parent
5141021234
commit
39a6726516
@ -67,10 +67,10 @@ REGISTER_DIALOG(chat_log)
|
|||||||
class tchat_log::model
|
class tchat_log::model
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
model(const vconfig& c, replay* r)
|
model(const vconfig& c, const replay& r)
|
||||||
: cfg(c)
|
: cfg(c)
|
||||||
, msg_label(nullptr)
|
, msg_label(nullptr)
|
||||||
, chat_log_history(r->build_chat_log())
|
, chat_log_history(r.build_chat_log())
|
||||||
, page(0)
|
, page(0)
|
||||||
, page_number()
|
, page_number()
|
||||||
, page_label()
|
, page_label()
|
||||||
@ -339,7 +339,7 @@ private:
|
|||||||
class tchat_log::view
|
class tchat_log::view
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
view(const vconfig& cfg, replay* r) : model_(cfg, r), controller_(model_)
|
view(const vconfig& cfg, const replay& r) : model_(cfg, r), controller_(model_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
tchat_log::tchat_log(const vconfig& cfg, replay* r) : view_()
|
tchat_log::tchat_log(const vconfig& cfg, const replay& r) : view_()
|
||||||
{
|
{
|
||||||
LOG_CHAT_LOG << "Entering tchat_log::tchat_log" << std::endl;
|
LOG_CHAT_LOG << "Entering tchat_log::tchat_log" << std::endl;
|
||||||
view_ = std::make_shared<view>(cfg, r);
|
view_ = std::make_shared<view>(cfg, r);
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
class model;
|
class model;
|
||||||
class view;
|
class view;
|
||||||
class controller;
|
class controller;
|
||||||
tchat_log(const vconfig& cfg, replay* replay);
|
tchat_log(const vconfig& cfg, const replay& replay);
|
||||||
|
|
||||||
/** Inherited from tdialog. */
|
/** Inherited from tdialog. */
|
||||||
twindow* build_window(CVideo& video);
|
twindow* build_window(CVideo& video);
|
||||||
|
@ -52,7 +52,7 @@ namespace gui2
|
|||||||
|
|
||||||
REGISTER_DIALOG(game_stats)
|
REGISTER_DIALOG(game_stats)
|
||||||
|
|
||||||
tgame_stats::tgame_stats(game_board& board, const int viewing_team, int& selected_index)
|
tgame_stats::tgame_stats(const display_context& board, const int viewing_team, int& selected_index)
|
||||||
: board_(board)
|
: board_(board)
|
||||||
, viewing_team_(board_.teams()[viewing_team])
|
, viewing_team_(board_.teams()[viewing_team])
|
||||||
, selected_index_(selected_index)
|
, selected_index_(selected_index)
|
||||||
|
@ -34,7 +34,7 @@ namespace gui2
|
|||||||
class tgame_stats : public tdialog
|
class tgame_stats : public tdialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tgame_stats(game_board& board, const int viewing_team, int& selected_index);
|
tgame_stats(const display_context& board, const int viewing_team, int& selected_index);
|
||||||
|
|
||||||
static bool execute(game_board& board, const int viewing_team, int& selected_index, CVideo& video)
|
static bool execute(game_board& board, const int viewing_team, int& selected_index, CVideo& video)
|
||||||
{
|
{
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO: don't like having this
|
// TODO: don't like having this
|
||||||
game_board& board_;
|
const display_context& board_;
|
||||||
|
|
||||||
const team& viewing_team_;
|
const team& viewing_team_;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void menu_handler::show_chat_log()
|
|||||||
{
|
{
|
||||||
config c;
|
config c;
|
||||||
c["name"] = "prototype of chat log";
|
c["name"] = "prototype of chat log";
|
||||||
gui2::tchat_log chat_log_dialog(vconfig(c), resources::recorder);
|
gui2::tchat_log chat_log_dialog(vconfig(c), *resources::recorder);
|
||||||
chat_log_dialog.show(gui_->video());
|
chat_log_dialog.show(gui_->video());
|
||||||
//std::string text = resources::recorder->build_chat_log();
|
//std::string text = resources::recorder->build_chat_log();
|
||||||
//gui::show_dialog(*gui_,nullptr,_("Chat Log"),"",gui::CLOSE_ONLY,nullptr,nullptr,"",&text);
|
//gui::show_dialog(*gui_,nullptr,_("Chat Log"),"",gui::CLOSE_ONLY,nullptr,nullptr,"",&text);
|
||||||
|
@ -368,10 +368,10 @@ void replay::remove_command(int index)
|
|||||||
static std::vector< chat_msg > message_log;
|
static std::vector< chat_msg > message_log;
|
||||||
|
|
||||||
|
|
||||||
const std::vector<chat_msg>& replay::build_chat_log()
|
const std::vector<chat_msg>& replay::build_chat_log() const
|
||||||
{
|
{
|
||||||
message_log.clear();
|
message_log.clear();
|
||||||
std::vector<int>::iterator loc_it;
|
std::vector<int>::const_iterator loc_it;
|
||||||
int last_location = 0;
|
int last_location = 0;
|
||||||
std::back_insert_iterator<std::vector < chat_msg > > chat_log_appender( back_inserter(message_log));
|
std::back_insert_iterator<std::vector < chat_msg > > chat_log_appender( back_inserter(message_log));
|
||||||
for (loc_it = message_locations.begin(); loc_it != message_locations.end(); ++loc_it)
|
for (loc_it = message_locations.begin(); loc_it != message_locations.end(); ++loc_it)
|
||||||
@ -551,7 +551,7 @@ void replay::undo()
|
|||||||
undo_cut(dummy);
|
undo_cut(dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
config &replay::command(int n)
|
config &replay::command(int n) const
|
||||||
{
|
{
|
||||||
config & retv = base_->get_command_at(n);
|
config & retv = base_->get_command_at(n);
|
||||||
assert(retv);
|
assert(retv);
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
bool add_chat_message_location();
|
bool add_chat_message_location();
|
||||||
bool add_chat_message_location(int pos);
|
bool add_chat_message_location(int pos);
|
||||||
void speak(const config& cfg);
|
void speak(const config& cfg);
|
||||||
const std::vector<chat_msg>& build_chat_log();
|
const std::vector<chat_msg>& build_chat_log() const;
|
||||||
|
|
||||||
//get data range will get a range of moves from the replay system.
|
//get data range will get a range of moves from the replay system.
|
||||||
//if data_type is 'ALL_DATA' then it will return all data in this range
|
//if data_type is 'ALL_DATA' then it will return all data in this range
|
||||||
@ -135,7 +135,7 @@ private:
|
|||||||
|
|
||||||
void add_chat_log_entry(const config &speak, std::back_insert_iterator< std::vector<chat_msg> > &i) const;
|
void add_chat_log_entry(const config &speak, std::back_insert_iterator< std::vector<chat_msg> > &i) const;
|
||||||
|
|
||||||
config &command(int);
|
config &command(int) const;
|
||||||
void remove_command(int);
|
void remove_command(int);
|
||||||
/** Adds a new empty command to the command list at the end.
|
/** Adds a new empty command to the command list at the end.
|
||||||
*
|
*
|
||||||
|
@ -99,6 +99,7 @@
|
|||||||
#include "language.hpp"
|
#include "language.hpp"
|
||||||
#include "game_initialization/create_engine.hpp"
|
#include "game_initialization/create_engine.hpp"
|
||||||
#include "tests/utils/fake_display.hpp"
|
#include "tests/utils/fake_display.hpp"
|
||||||
|
#include "replay.hpp"
|
||||||
#include "saved_game.hpp"
|
#include "saved_game.hpp"
|
||||||
//#include "scripting/lua_kernel_base.hpp"
|
//#include "scripting/lua_kernel_base.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp"
|
||||||
@ -262,7 +263,7 @@ namespace {
|
|||||||
{
|
{
|
||||||
for(const tresolution& resolution : resolutions) {
|
for(const tresolution& resolution : resolutions) {
|
||||||
|
|
||||||
//CVideo& video = test_utils::get_fake_display(resolution.first, resolution.second).video();
|
CVideo& video = test_utils::get_fake_display(resolution.first, resolution.second).video();
|
||||||
|
|
||||||
std::vector<std::string>& list =
|
std::vector<std::string>& list =
|
||||||
gui2::unit_test_registered_window_list();
|
gui2::unit_test_registered_window_list();
|
||||||
@ -270,19 +271,10 @@ namespace {
|
|||||||
|
|
||||||
std::string exception;
|
std::string exception;
|
||||||
try {
|
try {
|
||||||
/**
|
|
||||||
* @todo The code crashes for some unknown reason when this code is disabled.
|
|
||||||
* The backtrace however doesn't show this path, in fact the crash occurs
|
|
||||||
* before this code is used. So not entirely sure whether it's a compiler bug
|
|
||||||
* or a part of the static initialization fiasco. Need to test with different
|
|
||||||
* compilers and try to find the cause.
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
gui2::tip::show(video
|
gui2::tip::show(video
|
||||||
, id
|
, id
|
||||||
, "Test messsage for a tooltip."
|
, "Test messsage for a tooltip."
|
||||||
, gui2::tpoint(0, 0));
|
, gui2::tpoint(0, 0));
|
||||||
#endif
|
|
||||||
} catch(gui2::tlayout_exception_width_modified&) {
|
} catch(gui2::tlayout_exception_width_modified&) {
|
||||||
exception = "gui2::tlayout_exception_width_modified";
|
exception = "gui2::tlayout_exception_width_modified";
|
||||||
} catch(gui2::tlayout_exception_width_resize_failed&) {
|
} catch(gui2::tlayout_exception_width_resize_failed&) {
|
||||||
@ -384,7 +376,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
test<gui2::tcampaign_difficulty>();
|
test<gui2::tcampaign_difficulty>();
|
||||||
test<gui2::tcampaign_selection>();
|
test<gui2::tcampaign_selection>();
|
||||||
test<gui2::tcampaign_settings>();
|
test<gui2::tcampaign_settings>();
|
||||||
// test<gui2::tchat_log>(); /** @todo ENABLE */
|
test<gui2::tchat_log>();
|
||||||
test<gui2::tedit_label>();
|
test<gui2::tedit_label>();
|
||||||
test<gui2::tedit_text>();
|
test<gui2::tedit_text>();
|
||||||
test<gui2::teditor_generate_map>();
|
test<gui2::teditor_generate_map>();
|
||||||
@ -401,9 +393,9 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
test<gui2::tgame_save>();
|
test<gui2::tgame_save>();
|
||||||
test<gui2::tgame_save_message>();
|
test<gui2::tgame_save_message>();
|
||||||
test<gui2::tgame_save_oos>();
|
test<gui2::tgame_save_oos>();
|
||||||
//test<gui2::tgame_stats>();
|
test<gui2::tgame_stats>();
|
||||||
test<gui2::tgamestate_inspector>();
|
test<gui2::tgamestate_inspector>();
|
||||||
//test<gui2::tgenerator_settings>();
|
test<gui2::tgenerator_settings>();
|
||||||
test<gui2::tlanguage_selection>();
|
test<gui2::tlanguage_selection>();
|
||||||
// test<gui2::tloadscreen>(); TODO: enable
|
// test<gui2::tloadscreen>(); TODO: enable
|
||||||
test<gui2::tlobby_main>();
|
test<gui2::tlobby_main>();
|
||||||
@ -424,7 +416,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
test<gui2::tsimple_item_selector>();
|
test<gui2::tsimple_item_selector>();
|
||||||
test<gui2::tscreenshot_notification>();
|
test<gui2::tscreenshot_notification>();
|
||||||
test<gui2::tselect_orb_colors>();
|
test<gui2::tselect_orb_colors>();
|
||||||
//test<gui2::tsp_options_configure>();
|
test<gui2::tsp_options_configure>();
|
||||||
test<gui2::ttheme_list>();
|
test<gui2::ttheme_list>();
|
||||||
test<gui2::ttitle_screen>();
|
test<gui2::ttitle_screen>();
|
||||||
test<gui2::ttransient_message>();
|
test<gui2::ttransient_message>();
|
||||||
@ -452,6 +444,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
|
|
||||||
/* The tooltip classes. */
|
/* The tooltip classes. */
|
||||||
test_tip("tooltip_large");
|
test_tip("tooltip_large");
|
||||||
|
test_tip("tooltip");
|
||||||
|
|
||||||
std::vector<std::string>& list = gui2::unit_test_registered_window_list();
|
std::vector<std::string>& list = gui2::unit_test_registered_window_list();
|
||||||
std::vector<std::string> omitted = {
|
std::vector<std::string> omitted = {
|
||||||
@ -460,11 +453,6 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
* don't allow 'nullptr's needs to be fixed.
|
* don't allow 'nullptr's needs to be fixed.
|
||||||
*/
|
*/
|
||||||
"unit_attack",
|
"unit_attack",
|
||||||
/*
|
|
||||||
* The chat log unit test are disabled for now, they calling parameters
|
|
||||||
* don't allow 'nullptr's needs to be fixed.
|
|
||||||
*/
|
|
||||||
"chat_log",
|
|
||||||
// No test for this right now, not sure how to use the test system
|
// No test for this right now, not sure how to use the test system
|
||||||
// for dialog with no default constructor
|
// for dialog with no default constructor
|
||||||
"lua_interpreter",
|
"lua_interpreter",
|
||||||
@ -486,12 +474,9 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||||||
"unit_recruit",
|
"unit_recruit",
|
||||||
"unit_recall",
|
"unit_recall",
|
||||||
"unit_list",
|
"unit_list",
|
||||||
"game_stats",
|
|
||||||
"unit_advance",
|
"unit_advance",
|
||||||
"mp_host_game_prompt",
|
"mp_host_game_prompt",
|
||||||
"mp_create_game",
|
"mp_create_game",
|
||||||
"sp_options_configure",
|
|
||||||
"generator_settings",
|
|
||||||
};
|
};
|
||||||
std::sort(list.begin(), list.end());
|
std::sort(list.begin(), list.end());
|
||||||
std::sort(omitted.begin(), omitted.end());
|
std::sort(omitted.begin(), omitted.end());
|
||||||
@ -591,10 +576,12 @@ struct twrapper<gui2::tchat_log>
|
|||||||
{
|
{
|
||||||
config cfg;
|
config cfg;
|
||||||
vconfig vcfg;
|
vconfig vcfg;
|
||||||
twrapper() : vcfg(cfg) {}
|
replay_recorder_base rbase;
|
||||||
|
replay r;
|
||||||
|
twrapper() : vcfg(cfg), r(rbase) {}
|
||||||
gui2::tchat_log* create()
|
gui2::tchat_log* create()
|
||||||
{
|
{
|
||||||
return new gui2::tchat_log(vcfg, nullptr);
|
return new gui2::tchat_log(vcfg, r);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1100,5 +1087,40 @@ struct twrapper<gui2::tfaction_select>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct twrapper<gui2::tgame_stats>
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
gui2::tgame_stats* create()
|
||||||
|
{
|
||||||
|
const display_context* ctx = editor::get_dummy_display_context();
|
||||||
|
return new gui2::tgame_stats(*ctx, 1, i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct twrapper<gui2::tgenerator_settings>
|
||||||
|
{
|
||||||
|
config cfg;
|
||||||
|
generator_data data;
|
||||||
|
twrapper() : data(cfg) {}
|
||||||
|
gui2::tgenerator_settings* create()
|
||||||
|
{
|
||||||
|
return new gui2::tgenerator_settings(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct twrapper<gui2::tsp_options_configure>
|
||||||
|
{
|
||||||
|
saved_game state;
|
||||||
|
ng::create_engine engine;
|
||||||
|
twrapper() : engine(test_utils::get_fake_display(-1, -1).video(), state) {}
|
||||||
|
gui2::tsp_options_configure* create()
|
||||||
|
{
|
||||||
|
return new gui2::tsp_options_configure(engine);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user