+void EvtHandlerTestCase::LegacyConnect()
+{
+ handler.Connect( LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+ handler.Connect( 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+ handler.Connect( 0, 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+
+ handler.Disconnect( LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+ handler.Disconnect( 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+ handler.Disconnect( 0, 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent );
+
+
+ handler.Connect( LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+ handler.Connect( 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+ handler.Connect( 0, 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+
+ handler.Disconnect( LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+ handler.Disconnect( 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+ handler.Disconnect( 0, 0, LegacyEventType, (wxObjectEventFunction)&MyHandler::OnEvent, NULL, &handler );
+}
+
+void EvtHandlerTestCase::DisconnectWildcard()
+{
+ // should be able to disconnect a different handler using "wildcard search"
+ MyHandler sink;
+ wxEvtHandler source;
+ source.Connect(wxEVT_IDLE, wxIdleEventHandler(MyHandler::OnIdle), NULL, &sink);
+ CPPUNIT_ASSERT(source.Disconnect(wxID_ANY, wxEVT_IDLE));
+ // destruction of source and sink here should properly clean up the
+ // wxEventConnectionRef without crashing
+}
+
+void EvtHandlerTestCase::AutoDisconnect()
+{
+ wxEvtHandler source;
+ {
+ MyHandler sink;
+ source.Connect(wxEVT_IDLE, wxIdleEventHandler(MyHandler::OnIdle), NULL, &sink);
+ // mismatched event type, so nothing should be disconnected
+ CPPUNIT_ASSERT(!source.Disconnect(wxEVT_THREAD, wxIdleEventHandler(MyHandler::OnIdle), NULL, &sink));
+ }
+ // destruction of sink should have automatically disconnected it, so
+ // there should be nothing to disconnect anymore
+ CPPUNIT_ASSERT(!source.Disconnect(wxID_ANY, wxEVT_IDLE));
+}
+
+#ifdef wxHAS_EVENT_BIND
+
+void EvtHandlerTestCase::BindFunction()
+{
+ // function tests
+ handler.Bind( MyEventType, GlobalOnMyEvent );
+ g_called.Reset();
+ handler.ProcessEvent(e);
+ CPPUNIT_ASSERT( g_called.function );
+ handler.Unbind( MyEventType, GlobalOnMyEvent );
+ g_called.Reset();
+ handler.ProcessEvent(e);
+ CPPUNIT_ASSERT( !g_called.function ); // check that it was disconnected
+
+ handler.Bind( MyEventType, GlobalOnMyEvent, 0 );
+ handler.Unbind( MyEventType, GlobalOnMyEvent, 0 );
+
+ handler.Bind( MyEventType, GlobalOnMyEvent, 0, 0 );
+ handler.Unbind( MyEventType, GlobalOnMyEvent, 0, 0 );
+}
+
+void EvtHandlerTestCase::BindStaticMethod()
+{
+ // static method tests (this is same as functions but still test it just in
+ // case we hit some strange compiler bugs)
+ handler.Bind( MyEventType, &MyHandler::StaticOnMyEvent );