]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/slidertest.cpp
implementing delayed freezing, fixes #12865
[wxWidgets.git] / tests / controls / slidertest.cpp
index 536166c8fcfaa06bf28a8ed1e150f099b101d0b6..ce18bab183e877a71478babf7fa4d9d37e6e7459 100644 (file)
@@ -39,6 +39,9 @@ private:
         CPPUNIT_TEST( Value );
         CPPUNIT_TEST( Range );
         WXUISIM_TEST( Thumb );
+        CPPUNIT_TEST( PseudoTest_Inversed );
+        CPPUNIT_TEST( Value );
+        CPPUNIT_TEST( Range );
     CPPUNIT_TEST_SUITE_END();
 
     void PageUpDown();
@@ -47,21 +50,33 @@ private:
     void Value();
     void Range();
     void Thumb();
+    void PseudoTest_Inversed() { ms_inversed = true; }
+
+    static bool ms_inversed;
 
     wxSlider* m_slider;
 
     DECLARE_NO_COPY_CLASS(SliderTestCase)
 };
 
+bool SliderTestCase::ms_inversed = false;
+
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( SliderTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SliderTestCase, "SliderTestCase" );
 
 void SliderTestCase::setUp()
 {
-    m_slider = new wxSlider(wxTheApp->GetTopWindow(), wxID_ANY, 50, 0, 100);
+    long style = wxSL_HORIZONTAL;
+
+    if ( ms_inversed )
+        style |= wxSL_INVERSE;
+
+    m_slider = new wxSlider(wxTheApp->GetTopWindow(), wxID_ANY, 50, 0, 100,
+                            wxDefaultPosition, wxDefaultSize,
+                            style);
 }
 
 void SliderTestCase::tearDown()
@@ -72,11 +87,8 @@ void SliderTestCase::tearDown()
 void SliderTestCase::PageUpDown()
 {
 #if wxUSE_UIACTIONSIMULATOR
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
-    EventCounter count(m_slider, wxEVT_SCROLL_PAGEUP);
-    EventCounter count1(m_slider, wxEVT_SCROLL_PAGEDOWN);
+    EventCounter pageup(m_slider, wxEVT_SCROLL_PAGEUP);
+    EventCounter pagedown(m_slider, wxEVT_SCROLL_PAGEDOWN);
 
     wxUIActionSimulator sim;
 
@@ -87,19 +99,16 @@ void SliderTestCase::PageUpDown()
 
     wxYield();
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEUP));
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEDOWN));
+    CPPUNIT_ASSERT_EQUAL(1, pageup.GetCount());
+    CPPUNIT_ASSERT_EQUAL(1, pagedown.GetCount());
 #endif
 }
 
 void SliderTestCase::LineUpDown()
 {
 #if wxUSE_UIACTIONSIMULATOR
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
-    EventCounter count(m_slider, wxEVT_SCROLL_LINEUP);
-    EventCounter count1(m_slider, wxEVT_SCROLL_LINEDOWN);
+    EventCounter lineup(m_slider, wxEVT_SCROLL_LINEUP);
+    EventCounter linedown(m_slider, wxEVT_SCROLL_LINEDOWN);
 
     wxUIActionSimulator sim;
 
@@ -110,8 +119,8 @@ void SliderTestCase::LineUpDown()
 
     wxYield();
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEUP));
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEDOWN));
+    CPPUNIT_ASSERT_EQUAL(1, lineup.GetCount());
+    CPPUNIT_ASSERT_EQUAL(1, linedown.GetCount());
 #endif
 }
 
@@ -163,6 +172,11 @@ void SliderTestCase::Range()
     CPPUNIT_ASSERT_EQUAL(0, m_slider->GetMin());
     CPPUNIT_ASSERT_EQUAL(100, m_slider->GetMax());
 
+    // Changing range shouldn't change the value.
+    m_slider->SetValue(17);
+    m_slider->SetRange(0, 200);
+    CPPUNIT_ASSERT_EQUAL(17, m_slider->GetValue());
+
     //Test negative ranges
     m_slider->SetRange(-50, 0);
 
@@ -173,12 +187,9 @@ void SliderTestCase::Range()
 void SliderTestCase::Thumb()
 {
 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
-    EventCounter count(m_slider, wxEVT_SCROLL_THUMBTRACK);
-    EventCounter count1(m_slider, wxEVT_SCROLL_THUMBRELEASE);
-    EventCounter count2(m_slider, wxEVT_SCROLL_CHANGED);
+    EventCounter track(m_slider, wxEVT_SCROLL_THUMBTRACK);
+    EventCounter release(m_slider, wxEVT_SCROLL_THUMBRELEASE);
+    EventCounter changed(m_slider, wxEVT_SCROLL_CHANGED);
 
     wxUIActionSimulator sim;
 
@@ -196,10 +207,10 @@ void SliderTestCase::Thumb()
     sim.MouseUp();
     wxYield();
 
-    CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_SCROLL_THUMBTRACK) != 0);
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_THUMBRELEASE));
+    CPPUNIT_ASSERT(track.GetCount() != 0);
+    CPPUNIT_ASSERT_EQUAL(1, release.GetCount());
 #ifdef __WXMSW__
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_CHANGED));
+    CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
 #endif
 #endif
 }