]> git.saurik.com Git - wxWidgets.git/commitdiff
Use correct line numbers in assert failures in event propagation test.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 4 May 2013 23:59:40 +0000 (23:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 4 May 2013 23:59:40 +0000 (23:59 +0000)
Replace the calls to CheckMenuEvent() helper with ASSERT_MENU_EVENT_RESULT()
macro to allow passing the correct line number to cppunit assertion function,
otherwise the line number of CheckMenuEvent() was always used in case of
failure.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73924 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/events/propagation.cpp

index 14457f7464b858ef9ec11c23769f93163e797dde..d13e8eb5328bff7786e0901da69b118dc83116ce 100644 (file)
@@ -364,7 +364,12 @@ void EventPropagationTestCase::ScrollWindowWithHandler()
 
 // Helper for checking that the menu event processing resulted in the expected
 // output from the handlers.
-void CheckMenuEvent(wxMenu* menu, const char* expected)
+//
+// Notice that this is supposed to be used with ASSERT_MENU_EVENT_RESULT()
+// macro to make the file name and line number of the caller appear in the
+// failure messages.
+void
+CheckMenuEvent(wxMenu* menu, const char* result, CppUnit::SourceLine sourceLine)
 {
     g_str.clear();
 
@@ -373,9 +378,12 @@ void CheckMenuEvent(wxMenu* menu, const char* expected)
     // wxMenuBase::SendEvent() from their respective menu event handlers.
     menu->SendEvent(wxID_NEW);
 
-    CPPUNIT_ASSERT_EQUAL( expected, g_str );
+    CPPUNIT_NS::assertEquals( result, g_str, sourceLine, "" );
 }
 
+#define ASSERT_MENU_EVENT_RESULT(menu, result) \
+    CheckMenuEvent((menu), (result), CPPUNIT_SOURCELINE())
+
 void EventPropagationTestCase::MenuEvent()
 {
     // Create a minimal menu bar.
@@ -389,7 +397,7 @@ void EventPropagationTestCase::MenuEvent()
     wxON_BLOCK_EXIT_OBJ1( *frame, wxFrame::SetMenuBar, (wxMenuBar*)NULL );
 
     // Check that wxApp gets the event exactly once.
-    CheckMenuEvent( menu, "aA" );
+    ASSERT_MENU_EVENT_RESULT( menu, "aA" );
 
 
     // Check that the menu event handler is called.
@@ -397,7 +405,7 @@ void EventPropagationTestCase::MenuEvent()
     menu->SetNextHandler(&hm);
     wxON_BLOCK_EXIT_OBJ1( *menu,
                           wxEvtHandler::SetNextHandler, (wxEvtHandler*)NULL );
-    CheckMenuEvent( menu, "aomA" );
+    ASSERT_MENU_EVENT_RESULT( menu, "aomA" );
 
 
     // Test that the event handler associated with the menu bar gets the event.
@@ -405,7 +413,7 @@ void EventPropagationTestCase::MenuEvent()
     mb->PushEventHandler(&hb);
     wxON_BLOCK_EXIT_OBJ1( *mb, wxWindow::PopEventHandler, false );
 
-    CheckMenuEvent( menu, "aomobA" );
+    ASSERT_MENU_EVENT_RESULT( menu, "aomobA" );
 
 
     // Also test that the window to which the menu belongs gets the event.
@@ -413,5 +421,5 @@ void EventPropagationTestCase::MenuEvent()
     frame->PushEventHandler(&hw);
     wxON_BLOCK_EXIT_OBJ1( *frame, wxWindow::PopEventHandler, false );
 
-    CheckMenuEvent( menu, "aomobowA" );
+    ASSERT_MENU_EVENT_RESULT( menu, "aomobowA" );
 }