Properly assign properties during the test setup and bind event.

This commit is contained in:
Joseph Lenox 2018-07-23 00:02:50 -05:00
parent dc48ebea78
commit cdb7053034
2 changed files with 7 additions and 2 deletions

View File

@ -10,7 +10,9 @@ UI_Color::UI_Color(wxWindow* parent, Slic3r::ConfigOptionDef _opt ) : UI_Window(
}
this->_picker = new wxColourPickerCtrl(parent, wxID_ANY, default_color, wxDefaultPosition, this->_default_size());
this->window = dynamic_cast<wxWindow*>(this->_picker);
this->_picker->Bind(wxEVT_COLOURPICKER_CHANGED, [this](wxColourPickerEvent& e) { this->_on_change(""); e.Skip(); });
}
void UI_Color::set_value(boost::any value) {

View File

@ -14,7 +14,7 @@
#include "ConfigBase.hpp"
using namespace std::string_literals;
SCENARIO( "UI_ColorPick: default values from options and basic accessor methods") {
SCENARIO("UI_Color: default values from options and basic accessor methods") {
wxTestableFrame* old = dynamic_cast<wxTestableFrame*>(wxTheApp->GetTopWindow());
old->Destroy();
wxTheApp->SetTopWindow(new wxTestableFrame());
@ -25,7 +25,10 @@ SCENARIO( "UI_ColorPick: default values from options and basic accessor methods"
auto event_count {0};
auto changefunc {[&event_count] (const std::string& opt_id, const std::string& color) { event_count++; }};
GIVEN("A Color Picker") {
simple_option.default_value = default_color;
auto test_field {Slic3r::GUI::UI_Color(wxTheApp->GetTopWindow(), simple_option)};
test_field.on_change = changefunc;
WHEN("Object is constructed with default_value of '#FFFF00'.") {
THEN("get_string() returns '#FFFF00'") {
REQUIRE(test_field.get_string() == "#FFFF00"s);