From cdb7053034c3f1f9721355032daf012e3052956c Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 23 Jul 2018 00:02:50 -0500 Subject: [PATCH] Properly assign properties during the test setup and bind event. --- src/GUI/OptionsGroup/UI_Color.cpp | 4 +++- src/test/GUI/test_field_colorpicker.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/GUI/OptionsGroup/UI_Color.cpp b/src/GUI/OptionsGroup/UI_Color.cpp index 9577b9dcd..0e9d95467 100644 --- a/src/GUI/OptionsGroup/UI_Color.cpp +++ b/src/GUI/OptionsGroup/UI_Color.cpp @@ -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(this->_picker); - + + this->_picker->Bind(wxEVT_COLOURPICKER_CHANGED, [this](wxColourPickerEvent& e) { this->_on_change(""); e.Skip(); }); + } void UI_Color::set_value(boost::any value) { diff --git a/src/test/GUI/test_field_colorpicker.cpp b/src/test/GUI/test_field_colorpicker.cpp index f09a413f6..a0616f452 100644 --- a/src/test/GUI/test_field_colorpicker.cpp +++ b/src/test/GUI/test_field_colorpicker.cpp @@ -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(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);