From f8314f3c20b1c426825481acc1ec3a42106455bf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Nov 2010 17:13:29 +0000 Subject: [PATCH] Don't use standard menu ids in the unit test to avoid Mac problems. wxOSX rearranges the standard menu items such as wxID_EXIT and wxID_ABOUT and, for the former, changes its text to "Quit", so don't use them in the menu unit test which expects to find the items in the menus to which they were added and exactly with the labels used when adding them. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/menu/menu.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/menu/menu.cpp b/tests/menu/menu.cpp index febce87903..961651c518 100644 --- a/tests/menu/menu.cpp +++ b/tests/menu/menu.cpp @@ -33,9 +33,9 @@ namespace enum { - MenuTestCase_Quit = wxID_EXIT, - MenuTestCase_About = wxID_ABOUT, - MenuTestCase_First = 10000 + MenuTestCase_Foo = 10000, + MenuTestCase_Bar, + MenuTestCase_First }; void PopulateMenu(wxMenu* menu, const wxString& name, size_t& itemcount) @@ -137,16 +137,15 @@ void MenuTestCase::CreateFrame() subMenu->AppendSubMenu(subsubMenu, "Subsubmen&u", "Test a subsubmenu"); PopulateMenu(fileMenu, "Filemenu item ", itemcount); - // Add a 'real' item too, for future tests - fileMenu->Append(MenuTestCase_Quit, "E&xit\tAlt-X", "Quit this program"); + + fileMenu->Append(MenuTestCase_Foo, "&Foo\tCtrl-F", "Test item to be found"); PopulateMenu(helpMenu, "Helpmenu item ", itemcount); - helpMenu->Append(MenuTestCase_About, "&About...\tF1", - "(Would normally) Show about dialog"); + helpMenu->Append(MenuTestCase_Bar, "Bar"); helpMenu->AppendSubMenu(subMenu, "Sub&menu", "Test a submenu"); - // +2 for E&xit and &About, +2 for the 2 submenus + // +2 for "Foo" and "Bar", +2 for the 2 submenus m_itemCount = itemcount + 4; // Use an arraystring here, to help with future tests @@ -169,13 +168,13 @@ void MenuTestCase::FindInMenubar() CPPUNIT_ASSERT( bar->FindMenu("&Fail") == wxNOT_FOUND ); // Find by menu name plus item name: - CPPUNIT_ASSERT( bar->FindMenuItem("File", "Exit") != wxNOT_FOUND ); - CPPUNIT_ASSERT( bar->FindMenuItem("&File", "E&xit") != wxNOT_FOUND ); + CPPUNIT_ASSERT( bar->FindMenuItem("File", "Foo") != wxNOT_FOUND ); + CPPUNIT_ASSERT( bar->FindMenuItem("&File", "&Foo") != wxNOT_FOUND ); // and using the menu title int index = bar->FindMenu("&File"); CPPUNIT_ASSERT( index != wxNOT_FOUND ); wxString menutitle = bar->GetMenuLabel(index); - CPPUNIT_ASSERT( bar->FindMenuItem(menutitle, "E&xit") != wxNOT_FOUND ); + CPPUNIT_ASSERT( bar->FindMenuItem(menutitle, "&Foo") != wxNOT_FOUND ); // Find by position: for (size_t n=0; n < bar->GetMenuCount(); ++n) @@ -186,11 +185,11 @@ void MenuTestCase::FindInMenubar() // Find by id: wxMenu* menu = NULL; wxMenuItem* item = NULL; - item = bar->FindItem(MenuTestCase_Quit, &menu); + item = bar->FindItem(MenuTestCase_Foo, &menu); CPPUNIT_ASSERT( item ); CPPUNIT_ASSERT( menu ); // Check that the correct menu was found - CPPUNIT_ASSERT( menu->FindChildItem(MenuTestCase_Quit) ); + CPPUNIT_ASSERT( menu->FindChildItem(MenuTestCase_Foo) ); // Find submenu item: item = bar->FindItem(m_submenuItemId, &menu); @@ -208,8 +207,8 @@ void MenuTestCase::FindInMenu() // Find by name: wxMenu* menuFind = bar->GetMenu(0); - CPPUNIT_ASSERT( menuFind->FindItem("Exit") != wxNOT_FOUND ); - CPPUNIT_ASSERT( menuFind->FindItem("E&xit") != wxNOT_FOUND ); + CPPUNIT_ASSERT( menuFind->FindItem("Foo") != wxNOT_FOUND ); + CPPUNIT_ASSERT( menuFind->FindItem("&Foo") != wxNOT_FOUND ); // and for submenus wxMenu* menuHelp = bar->GetMenu(1); CPPUNIT_ASSERT( menuHelp->FindItem("Submenu") != wxNOT_FOUND ); @@ -222,8 +221,8 @@ void MenuTestCase::FindInMenu() } // Find by id: - CPPUNIT_ASSERT( menuHelp->FindItem(MenuTestCase_About) ); - CPPUNIT_ASSERT( menuHelp->FindItem(MenuTestCase_Quit) == NULL ); + CPPUNIT_ASSERT( menuHelp->FindItem(MenuTestCase_Bar) ); + CPPUNIT_ASSERT( menuHelp->FindItem(MenuTestCase_Foo) == NULL ); for (size_t n=0; n < menuHelp->GetMenuItemCount(); ++n) { -- 2.45.2