]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/bookctrlbasetest.cpp
Don't ignore child process output if it exits with -1 exit code.
[wxWidgets.git] / tests / controls / bookctrlbasetest.cpp
index 41ddeb282810ea4ec04fafd802e33942dd8e1aad..acd787f6fad5e90a0ab6d5e5ae80569d724f498e 100644 (file)
@@ -17,8 +17,6 @@
 #include "wx/artprov.h"
 #include "wx/imaglist.h"
 #include "wx/bookctrl.h"
-#include "wx/toolbook.h"
-#include "wx/toolbar.h"
 #include "bookctrlbasetest.h"
 #include "testableframe.h"
 
@@ -35,11 +33,7 @@ void BookCtrlBaseTestCase::AddPanels()
 
     base->AssignImageList(m_list);
 
-    //We need to realize the toolbar if we ware running the wxToolbook tests
-    wxToolbook *book = wxDynamicCast(base, wxToolbook);
-
-    if(book)
-        book->GetToolBar()->Realize();
+    Realize();
 
     m_panel1 = new wxPanel(base);
     m_panel2 = new wxPanel(base);
@@ -96,61 +90,64 @@ void BookCtrlBaseTestCase::PageManagement()
 
     base->InsertPage(0, new wxPanel(base), "New Panel", true, 0);
 
-    //We need to realize the toolbar if we ware running the wxToolbook tests
-    wxToolbook *book = wxDynamicCast(base, wxToolbook);
-
-    if(book)
-        book->GetToolBar()->Realize();
+    Realize();
 
     CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
     CPPUNIT_ASSERT_EQUAL(4, base->GetPageCount());
 
+    // Change the selection to verify that deleting a page before the currently
+    // selected one correctly updates the selection.
+    base->SetSelection(2);
+    CPPUNIT_ASSERT_EQUAL(2, base->GetSelection());
+
     base->DeletePage(1);
 
     CPPUNIT_ASSERT_EQUAL(3, base->GetPageCount());
+    CPPUNIT_ASSERT_EQUAL(1, base->GetSelection());
 
     base->RemovePage(0);
 
     CPPUNIT_ASSERT_EQUAL(2, base->GetPageCount());
+    CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
 
     base->DeleteAllPages();
 
     CPPUNIT_ASSERT_EQUAL(0, base->GetPageCount());
-
-    AddPanels();
+    CPPUNIT_ASSERT_EQUAL(-1, base->GetSelection());
 }
 
 void BookCtrlBaseTestCase::ChangeEvents()
 {
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
     wxBookCtrlBase * const base = GetBase();
 
     base->SetSelection(0);
 
-    EventCounter count(base, GetChangingEvent());
-    EventCounter count1(base, GetChangedEvent());
+    EventCounter changing(base, GetChangingEvent());
+    EventCounter changed(base, GetChangedEvent());
 
     base->SetSelection(1);
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
+    CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
+    CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
 
+    changed.Clear();
+    changing.Clear();
     base->ChangeSelection(2);
 
-    CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangingEvent()));
-    CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangedEvent()));
+    CPPUNIT_ASSERT_EQUAL(0, changing.GetCount());
+    CPPUNIT_ASSERT_EQUAL(0, changed.GetCount());
 
     base->AdvanceSelection();
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
+    CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
+    CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
 
+    changed.Clear();
+    changing.Clear();
     base->AdvanceSelection(false);
 
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
-    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
+    CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
+    CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
 }
 
 void BookCtrlBaseTestCase::Image()