]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/events/propagation.cpp
Don't reset bullet number and outline number when applying style sheet.
[wxWidgets.git] / tests / events / propagation.cpp
index 7ec1e50dd3860a0af4d32c49eb7fcd9496b2e539..bbc7428be649889d75c139972d332c152502f9d8 100644 (file)
@@ -178,6 +178,7 @@ private:
         CPPUNIT_TEST( TwoHandlers );
         CPPUNIT_TEST( WindowWithoutHandler );
         CPPUNIT_TEST( WindowWithHandler );
+        CPPUNIT_TEST( ForwardEvent );
         CPPUNIT_TEST( ScrollWindowWithoutHandler );
         CPPUNIT_TEST( ScrollWindowWithHandler );
     CPPUNIT_TEST_SUITE_END();
@@ -186,6 +187,7 @@ private:
     void TwoHandlers();
     void WindowWithoutHandler();
     void WindowWithHandler();
+    void ForwardEvent();
     void ScrollWindowWithoutHandler();
     void ScrollWindowWithHandler();
 
@@ -262,6 +264,48 @@ void EventPropagationTestCase::WindowWithHandler()
     CPPUNIT_ASSERT_EQUAL( "oa2o1cpA", g_str );
 }
 
+void EventPropagationTestCase::ForwardEvent()
+{
+    // The idea of this test is to check that the events explicitly forwarded
+    // to another event handler still get pre/post-processed as usual as this
+    // used to be broken by the fixes trying to avoid duplicate processing.
+    TestWindow * const win = new TestWindow(wxTheApp->GetTopWindow(), 'w');
+    wxON_BLOCK_EXIT_OBJ0( *win, wxWindow::Destroy );
+
+    TestEvtHandler h1('1');
+    win->PushEventHandler(&h1);
+    wxON_BLOCK_EXIT_OBJ1( *win, wxWindow::PopEventHandler, false );
+
+    class ForwardEvtHandler : public wxEvtHandler
+    {
+    public:
+        ForwardEvtHandler(wxEvtHandler& h) : m_h(&h) { }
+
+        virtual bool ProcessEvent(wxEvent& event)
+        {
+            g_str += 'f';
+
+            return m_h->ProcessEvent(event);
+        }
+
+    private:
+        wxEvtHandler *m_h;
+    } f(h1);
+
+    // First send the event directly to f.
+    wxCommandEvent event1(TEST_EVT);
+    f.ProcessEvent(event1);
+    CPPUNIT_ASSERT_EQUAL( "foa1wA", g_str );
+    g_str.clear();
+
+    // And then also test sending it to f indirectly.
+    wxCommandEvent event2(TEST_EVT);
+    TestEvtHandler h2('2');
+    h2.SetNextHandler(&f);
+    h2.ProcessEvent(event2);
+    CPPUNIT_ASSERT_EQUAL( "oa2fo1wAA", g_str );
+}
+
 void EventPropagationTestCase::ScrollWindowWithoutHandler()
 {
     TestWindow * const parent = new TestWindow(wxTheApp->GetTopWindow(), 'p');
@@ -269,10 +313,11 @@ void EventPropagationTestCase::ScrollWindowWithoutHandler()
 
     TestScrollWindow * const win = new TestScrollWindow(parent);
 
+#ifndef __WXOSX__
     wxPaintEvent event(win->GetId());
     win->ProcessWindowEvent(event);
     CPPUNIT_ASSERT_EQUAL( "PD", g_str );
-
+#endif
     g_str.clear();
     wxCommandEvent eventCmd(TEST_EVT);
     win->HandleWindowEvent(eventCmd);
@@ -286,6 +331,7 @@ void EventPropagationTestCase::ScrollWindowWithHandler()
 
     TestScrollWindow * const win = new TestScrollWindow(parent);
 
+#ifndef __WXOSX__
     TestPaintEvtHandler h('h');
     win->PushEventHandler(&h);
     wxON_BLOCK_EXIT_OBJ1( *win, wxWindow::PopEventHandler, false );
@@ -293,6 +339,7 @@ void EventPropagationTestCase::ScrollWindowWithHandler()
     wxPaintEvent event(win->GetId());
     win->ProcessWindowEvent(event);
     CPPUNIT_ASSERT_EQUAL( "ohPD", g_str );
+#endif
 
     g_str.clear();
     wxCommandEvent eventCmd(TEST_EVT);