]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/spinctrltest.cpp
Create wxStaticBoxSizer elements as children of wxStaticBox in XRC.
[wxWidgets.git] / tests / controls / spinctrltest.cpp
index 498ac203d4c909d52f1a9ec4389b4f608dc5b6ca..5b677f7571db60f389bc7c3c3f590b11fb5d7882 100644 (file)
@@ -33,12 +33,14 @@ public:
 
 private:
     CPPUNIT_TEST_SUITE( SpinCtrlTestCase );
+        CPPUNIT_TEST( Initial );
         WXUISIM_TEST( Arrows );
         WXUISIM_TEST( Wrap );
         CPPUNIT_TEST( Range );
         CPPUNIT_TEST( Value );
     CPPUNIT_TEST_SUITE_END();
 
+    void Initial();
     void Arrows();
     void Wrap();
     void Range();
@@ -65,13 +67,32 @@ void SpinCtrlTestCase::tearDown()
     wxDELETE(m_spin);
 }
 
+void SpinCtrlTestCase::Initial()
+{
+    // Initial value is defined by "initial" argument which is 0 by default.
+    CPPUNIT_ASSERT_EQUAL( 0, m_spin->GetValue() );
+
+    wxWindow* const parent = m_spin->GetParent();
+
+    // Recreate the control with another "initial" to check this.
+    delete m_spin;
+    m_spin = new wxSpinCtrl(parent, wxID_ANY, "",
+                            wxDefaultPosition, wxDefaultSize, 0,
+                            0, 100, 17);
+    CPPUNIT_ASSERT_EQUAL( 17, m_spin->GetValue() );
+
+    // But if the text string is specified, it takes precedence.
+    delete m_spin;
+    m_spin = new wxSpinCtrl(parent, wxID_ANY, "99",
+                            wxDefaultPosition, wxDefaultSize, 0,
+                            0, 100, 17);
+    CPPUNIT_ASSERT_EQUAL( 99, m_spin->GetValue() );
+}
+
 void SpinCtrlTestCase::Arrows()
 {
 #if wxUSE_UIACTIONSIMULATOR
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
-    EventCounter count(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED);
+    EventCounter updated(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED);
 
     wxUIActionSimulator sim;
 
@@ -81,14 +102,15 @@ void SpinCtrlTestCase::Arrows()
 
     wxYield();
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
+    CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
     CPPUNIT_ASSERT_EQUAL(1, m_spin->GetValue());
+    updated.Clear();
 
     sim.Char(WXK_DOWN);
 
     wxYield();
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
+    CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
     CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue());
 #endif
 }