Add tests for missing dialogs
This commit is contained in:
parent
136f5a864f
commit
381200979a
4 changed files with 88 additions and 19 deletions
|
@ -226,7 +226,7 @@ void editor_controller::custom_tods_dialog()
|
|||
|
||||
std::vector<time_of_day> schedule = context_manager_->get_map_context().get_time_manager()->times();
|
||||
|
||||
if(!gui2::tcustom_tod::execute(&(gui()), schedule, gui().video())) {
|
||||
if(!gui2::tcustom_tod::execute(gui(), schedule)) {
|
||||
adjust_resetter.reset();
|
||||
} else {
|
||||
// TODO save the new tod here
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace gui2
|
|||
|
||||
REGISTER_DIALOG(custom_tod)
|
||||
|
||||
tcustom_tod::tcustom_tod(editor::editor_display* display,
|
||||
tcustom_tod::tcustom_tod(display& display,
|
||||
const std::vector<time_of_day>& tods)
|
||||
: tods_(tods)
|
||||
, current_tod_(0)
|
||||
|
@ -115,7 +115,7 @@ void tcustom_tod::select_file(const std::string& filename,
|
|||
}
|
||||
|
||||
int res = dialogs::show_file_chooser_dialog(
|
||||
display_->video(), dn, _("Choose File"));
|
||||
display_.video(), dn, _("Choose File"));
|
||||
if(res == 0) {
|
||||
if(attribute == "image") {
|
||||
tods_[current_tod_].image = dn;
|
||||
|
@ -173,10 +173,6 @@ void tcustom_tod::update_tod_display(twindow& window)
|
|||
tod_green_field_->get_value(),
|
||||
tod_blue_field_->get_value());
|
||||
|
||||
if(!display_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent a floating slice of window appearing alone over the
|
||||
// theme UI sidebar after redrawing tiles and before we have a
|
||||
// chance to redraw the rest of this window.
|
||||
|
@ -192,10 +188,10 @@ void tcustom_tod::update_tod_display(twindow& window)
|
|||
// redraw_everything() instead.
|
||||
|
||||
// invalidate all tiles so they are redrawn with the new ToD tint next
|
||||
display_->invalidate_all();
|
||||
display_.invalidate_all();
|
||||
|
||||
// redraw tiles
|
||||
display_->draw(false);
|
||||
display_.draw(false);
|
||||
|
||||
window.invalidate_layout();
|
||||
}
|
||||
|
|
|
@ -42,14 +42,12 @@ class ttext_box;
|
|||
class tcustom_tod : public tdialog
|
||||
{
|
||||
public:
|
||||
tcustom_tod(editor::editor_display* display,
|
||||
tcustom_tod(display& display,
|
||||
const std::vector<time_of_day>& tods);
|
||||
|
||||
static bool execute(editor::editor_display* display,
|
||||
const std::vector<time_of_day>& tods,
|
||||
CVideo& video)
|
||||
static bool execute(display& display, const std::vector<time_of_day>& tods)
|
||||
{
|
||||
return tcustom_tod(display, tods).show(video);
|
||||
return tcustom_tod(display, tods).show(display.video());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -108,11 +106,8 @@ private:
|
|||
|
||||
/**
|
||||
* The display to update when the ToD changes.
|
||||
*
|
||||
* The pointer may be nullptr, in the unit tests, but normally it should be a
|
||||
* pointer to a valid object.
|
||||
*/
|
||||
editor::editor_display* display_;
|
||||
display& display_;
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -36,9 +36,14 @@
|
|||
#include "gui/dialogs/campaign_selection.hpp"
|
||||
#include "gui/dialogs/campaign_settings.hpp"
|
||||
#include "gui/dialogs/chat_log.hpp"
|
||||
#include "gui/dialogs/core_selection.hpp"
|
||||
#include "gui/dialogs/debug_clock.hpp"
|
||||
#include "gui/dialogs/edit_label.hpp"
|
||||
#include "gui/dialogs/edit_text.hpp"
|
||||
#include "gui/dialogs/editor/custom_tod.hpp"
|
||||
#include "gui/dialogs/editor/edit_side.hpp"
|
||||
#include "gui/dialogs/editor/edit_label.hpp"
|
||||
#include "gui/dialogs/editor/edit_scenario.hpp"
|
||||
#include "gui/dialogs/editor/generate_map.hpp"
|
||||
#include "gui/dialogs/editor/new_map.hpp"
|
||||
#include "gui/dialogs/editor/resize_map.hpp"
|
||||
|
@ -428,7 +433,11 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
test<gui2::twml_message_right>();
|
||||
test<gui2::tmp_alerts_options>();
|
||||
test<gui2::tadvanced_graphics_options>();
|
||||
|
||||
test<gui2::tcustom_tod>();
|
||||
test<gui2::teditor_edit_label>();
|
||||
test<gui2::teditor_edit_side>();
|
||||
test<gui2::teditor_edit_scenario>();
|
||||
test<gui2::tcore_selection>();
|
||||
//test<gui2::tlua_interpreter>(& lua_kernel_base());
|
||||
|
||||
/* The tpopup classes. */
|
||||
|
@ -472,6 +481,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
"unit_list",
|
||||
"game_stats",
|
||||
"unit_advance",
|
||||
"mp_host_game_prompt",
|
||||
"mp_create_game"
|
||||
};
|
||||
std::sort(list.begin(), list.end());
|
||||
|
@ -579,6 +589,34 @@ struct twrapper<gui2::tchat_log>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::tcore_selection>
|
||||
{
|
||||
std::vector<config> cores;
|
||||
twrapper()
|
||||
{
|
||||
cores.resize(1);
|
||||
}
|
||||
gui2::tcore_selection* create()
|
||||
{
|
||||
return new gui2::tcore_selection(cores, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::tcustom_tod>
|
||||
{
|
||||
std::vector<time_of_day> times;
|
||||
twrapper()
|
||||
{
|
||||
times.resize(1);
|
||||
}
|
||||
gui2::tcustom_tod* create()
|
||||
{
|
||||
return new gui2::tcustom_tod(test_utils::get_fake_display(-1, -1), times);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::tedit_label>
|
||||
{
|
||||
|
@ -600,6 +638,46 @@ struct twrapper<gui2::tedit_text>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::teditor_edit_label>
|
||||
{
|
||||
std::string label = "Label text to modify";
|
||||
std::string category = "test";
|
||||
bool immutable = false, fog = false, shroud = false;
|
||||
SDL_Color color;
|
||||
gui2::teditor_edit_label* create()
|
||||
{
|
||||
return new gui2::teditor_edit_label(label, immutable, fog, shroud, color, category);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::teditor_edit_scenario>
|
||||
{
|
||||
std::string id, name, descr;
|
||||
int turns, xp_mod;
|
||||
bool defeat_enemies, random_start;
|
||||
gui2::teditor_edit_scenario* create()
|
||||
{
|
||||
return new gui2::teditor_edit_scenario(id, name, descr, turns, xp_mod, defeat_enemies, random_start);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::teditor_edit_side>
|
||||
{
|
||||
std::string name, user_name;
|
||||
int gold, income, village, support;
|
||||
bool no_leader, hidden, fog, shroud;
|
||||
team::CONTROLLER controller;
|
||||
team::SHARE_VISION share_vision;
|
||||
gui2::teditor_edit_side* create()
|
||||
{
|
||||
return new gui2::
|
||||
teditor_edit_side(1, name, user_name, gold, income, village, support, fog, shroud, share_vision, controller, no_leader, hidden);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::tformula_debugger>
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue