X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6d9407fec40d21e8442e8affdc3dd23a9a9b1aa0..b5fe7ca67bf3121959a0b5a59afd00c1708f2f03:/tests/test.cpp diff --git a/tests/test.cpp b/tests/test.cpp index cc84f27925..00d746b2f8 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -92,6 +92,24 @@ public: virtual int OnRun(); virtual int OnExit(); + // used by events propagation test + virtual int FilterEvent(wxEvent& event); + virtual bool ProcessEvent(wxEvent& event); + + void SetFilterEventFunc(FilterEventFunc f) { m_filterEventFunc = f; } + void SetProcessEventFunc(ProcessEventFunc f) { m_processEventFunc = f; } + +#ifdef __WXDEBUG__ + virtual void OnAssertFailure(const wxChar *, + int, + const wxChar *, + const wxChar *, + const wxChar *) + { + throw TestAssertFailure(); + } +#endif // __WXDEBUG__ + private: void List(Test *test, const string& parent = "") const; @@ -101,6 +119,10 @@ private: bool m_detail; bool m_timing; vector m_registries; + + // event handling hooks + FilterEventFunc m_filterEventFunc; + ProcessEventFunc m_processEventFunc; }; IMPLEMENT_APP_CONSOLE(TestApp) @@ -109,6 +131,8 @@ TestApp::TestApp() : m_list(false), m_longlist(false) { + m_filterEventFunc = NULL; + m_processEventFunc = NULL; } // Init @@ -174,6 +198,33 @@ bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser) return TestAppBase::OnCmdLineParsed(parser); } +// Event handling +int TestApp::FilterEvent(wxEvent& event) +{ + if ( m_filterEventFunc ) + return (*m_filterEventFunc)(event); + + return TestAppBase::FilterEvent(event); +} + +bool TestApp::ProcessEvent(wxEvent& event) +{ + if ( m_processEventFunc ) + return (*m_processEventFunc)(event); + + return TestAppBase::ProcessEvent(event); +} + +extern void SetFilterEventFunc(FilterEventFunc func) +{ + wxGetApp().SetFilterEventFunc(func); +} + +extern void SetProcessEventFunc(ProcessEventFunc func) +{ + wxGetApp().SetProcessEventFunc(func); +} + // Run // int TestApp::OnRun()