+
+void MenuTestCase::Labels()
+{
+ wxMenuBar* bar = m_frame->GetMenuBar();
+ CPPUNIT_ASSERT( bar );
+ wxMenu* filemenu;
+ wxMenuItem* itemFoo = bar->FindItem(MenuTestCase_Foo, &filemenu);
+ CPPUNIT_ASSERT( itemFoo );
+ CPPUNIT_ASSERT( filemenu );
+
+ // These return labels including mnemonics/accelerators:
+
+ // wxMenuBar
+ CPPUNIT_ASSERT_EQUAL( "&File", bar->GetMenuLabel(0) );
+ CPPUNIT_ASSERT_EQUAL( "&Foo\tCtrl-F", bar->GetLabel(MenuTestCase_Foo) );
+
+ // wxMenu
+ CPPUNIT_ASSERT_EQUAL( "&File", filemenu->GetTitle() );
+ CPPUNIT_ASSERT_EQUAL( "&Foo\tCtrl-F", filemenu->GetLabel(MenuTestCase_Foo) );
+
+ // wxMenuItem
+ CPPUNIT_ASSERT_EQUAL( "&Foo\tCtrl-F", itemFoo->GetItemLabel() );
+
+ // These return labels stripped of mnemonics/accelerators:
+
+ // wxMenuBar
+ CPPUNIT_ASSERT_EQUAL( "File", bar->GetMenuLabelText(0) );
+
+ // wxMenu
+ CPPUNIT_ASSERT_EQUAL( "Foo", filemenu->GetLabelText(MenuTestCase_Foo) );
+
+ // wxMenuItem
+ CPPUNIT_ASSERT_EQUAL( "Foo", itemFoo->GetItemLabelText() );
+ CPPUNIT_ASSERT_EQUAL( "Foo", wxMenuItem::GetLabelText("&Foo\tCtrl-F") );
+}
+
+void MenuTestCase::RadioItems()
+{
+ wxMenuBar * const bar = m_frame->GetMenuBar();
+ wxMenu * const menu = new wxMenu;
+ bar->Append(menu, "&Radio");
+
+ // Adding consecutive radio items creates a radio group.
+ menu->AppendRadioItem(MenuTestCase_First, "Radio 0");
+ menu->AppendRadioItem(MenuTestCase_First + 1, "Radio 1");
+
+ // First item of a radio group is checked by default.
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) );
+
+ // Checking the second one make the first one unchecked however.
+ menu->Check(MenuTestCase_First + 1, true);
+ CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First) );
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
+
+ // Adding more radio items after a separator creates another radio group...
+ menu->AppendSeparator();
+ menu->AppendRadioItem(MenuTestCase_First + 2, "Radio 2");
+ menu->AppendRadioItem(MenuTestCase_First + 3, "Radio 3");
+ menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4");
+
+ // ... which is independent from the first one.
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) );
+
+ menu->Check(MenuTestCase_First + 3, true);
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
+ CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) );
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
+
+
+ // Insert an item in the middle of an existing radio group.
+ menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5");
+ CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
+
+ menu->Check( MenuTestCase_First + 5, true );
+ CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) );
+
+
+ // Prepend a couple of items before the first group.
+ menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6");
+ menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7");
+ menu->Check(MenuTestCase_First + 7, true);
+ CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) );
+
+
+ // Check that the last radio group still works as expected.
+ menu->Check(MenuTestCase_First + 4, true);
+ CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) );
+}