Ensure initial value of generic wxSpinCtrl is always valid

Under MSW creating a wxSpinCtrl with a range of, say, 1..10 and the
default initial value of 0 sets its initial value to 1 (i.e. the closest
valid value) as expected, but the generic version still set it to the
invalid value of 0, which was unexpected, inconsistent and not useful.

Fix the generic version to follow MSW behaviour now and add a test
checking for this.
This commit is contained in:
Vadim Zeitlin
2021-08-17 22:05:49 +02:00
parent b66656fbec
commit ac1fa83c20
3 changed files with 31 additions and 7 deletions

View File

@@ -124,6 +124,17 @@ TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Init4", "[spinctrl]")
CHECK(m_spin->GetValue() == 99);
}
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::InitOutOfRange", "[spinctrl]")
{
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
wxDefaultPosition, wxDefaultSize, 0,
10, 20, 0);
// Recreate the control with another "initial" outside of the valid range:
// it shouldn't be taken into account.
CHECK(m_spin->GetValue() == 10);
}
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::NoEventsInCtor", "[spinctrl]")
{
// Verify that creating the control does not generate any events. This is