Test that selecting 'single' radio button does not reset others
Add a unit test for the expected behaviour. Closes https://github.com/wxWidgets/wxWidgets/pull/1102
This commit is contained in:
committed by
Vadim Zeitlin
parent
2cf0fcb4fd
commit
5885b2f142
@@ -35,11 +35,13 @@ private:
|
||||
WXUISIM_TEST( Click );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST( Group );
|
||||
CPPUNIT_TEST( Single );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Click();
|
||||
void Value();
|
||||
void Group();
|
||||
void Single();
|
||||
|
||||
wxRadioButton* m_radio;
|
||||
|
||||
@@ -150,4 +152,36 @@ void RadioButtonTestCase::Group()
|
||||
wxDELETE(g2radio1);
|
||||
}
|
||||
|
||||
void RadioButtonTestCase::Single()
|
||||
{
|
||||
//Create a group of 2 buttons, having second button selected
|
||||
wxScopedPtr<wxRadioButton> gradio0(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxRB_GROUP));
|
||||
|
||||
wxScopedPtr<wxRadioButton> gradio1(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton"));
|
||||
|
||||
gradio1->SetValue(true);
|
||||
|
||||
//Create a "single" button (by default it will not be selected)
|
||||
wxScopedPtr<wxRadioButton> sradio(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxRB_SINGLE));
|
||||
|
||||
//Create a non-grouped button and select it
|
||||
wxScopedPtr<wxRadioButton> ngradio(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton"));
|
||||
|
||||
ngradio->SetValue(true);
|
||||
|
||||
//Select the "single" button
|
||||
sradio->SetValue(true);
|
||||
|
||||
CHECK(gradio1->GetValue());
|
||||
CHECK(ngradio->GetValue());
|
||||
}
|
||||
|
||||
#endif //wxUSE_RADIOBTN
|
||||
|
Reference in New Issue
Block a user