Split out test which will not work on QT, and fix insertion behaviour of radio menu items.
This commit is contained in:
@@ -70,6 +70,13 @@ static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previous
|
|||||||
wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" );
|
wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" );
|
||||||
previousItemActionGroup->addAction( itemAction );
|
previousItemActionGroup->addAction( itemAction );
|
||||||
}
|
}
|
||||||
|
else if( successiveItem != NULL && successiveItem->GetKind() == wxITEM_RADIO )
|
||||||
|
{
|
||||||
|
QAction *successiveItemAction = successiveItem->GetHandle();
|
||||||
|
QActionGroup *successiveItemActionGroup = successiveItemAction->actionGroup();
|
||||||
|
wxASSERT_MSG( successiveItemActionGroup != NULL, "An action group should have been setup" );
|
||||||
|
successiveItemActionGroup->addAction( itemAction );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QActionGroup *actionGroup = new QActionGroup( qtMenu );
|
QActionGroup *actionGroup = new QActionGroup( qtMenu );
|
||||||
|
@@ -90,7 +90,11 @@ private:
|
|||||||
#if wxUSE_INTL
|
#if wxUSE_INTL
|
||||||
CPPUNIT_TEST( TranslatedMnemonics );
|
CPPUNIT_TEST( TranslatedMnemonics );
|
||||||
#endif // wxUSE_INTL
|
#endif // wxUSE_INTL
|
||||||
|
#ifndef __WXQT__
|
||||||
CPPUNIT_TEST( RadioItems );
|
CPPUNIT_TEST( RadioItems );
|
||||||
|
#else
|
||||||
|
CPPUNIT_TEST( RadioItemsWithoutMutualExclusion );
|
||||||
|
#endif
|
||||||
CPPUNIT_TEST( RemoveAdd );
|
CPPUNIT_TEST( RemoveAdd );
|
||||||
CPPUNIT_TEST( ChangeBitmap );
|
CPPUNIT_TEST( ChangeBitmap );
|
||||||
WXUISIM_TEST( Events );
|
WXUISIM_TEST( Events );
|
||||||
@@ -107,6 +111,7 @@ private:
|
|||||||
void TranslatedMnemonics();
|
void TranslatedMnemonics();
|
||||||
#endif // wxUSE_INTL
|
#endif // wxUSE_INTL
|
||||||
void RadioItems();
|
void RadioItems();
|
||||||
|
void RadioItemsWithoutMutualExclusion();
|
||||||
void RemoveAdd();
|
void RemoveAdd();
|
||||||
void ChangeBitmap();
|
void ChangeBitmap();
|
||||||
void Events();
|
void Events();
|
||||||
@@ -425,7 +430,6 @@ void MenuTestCase::RadioItems()
|
|||||||
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) );
|
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) );
|
||||||
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
|
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
|
||||||
|
|
||||||
|
|
||||||
// Insert an item in the middle of an existing radio group.
|
// Insert an item in the middle of an existing radio group.
|
||||||
menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5");
|
menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5");
|
||||||
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
|
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
|
||||||
@@ -433,13 +437,56 @@ void MenuTestCase::RadioItems()
|
|||||||
menu->Check( MenuTestCase_First + 5, true );
|
menu->Check( MenuTestCase_First + 5, true );
|
||||||
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) );
|
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");
|
||||||
|
|
||||||
|
// Items should not be checked, as they are part of an existing group.
|
||||||
|
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) );
|
||||||
|
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 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) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuTestCase::RadioItemsWithoutMutualExclusion()
|
||||||
|
{
|
||||||
|
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) );
|
||||||
|
|
||||||
|
// Subsequent items in a group are not checked.
|
||||||
|
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) );
|
||||||
|
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) );
|
||||||
|
|
||||||
|
// 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 + 2) );
|
||||||
|
|
||||||
// Prepend a couple of items before the first group.
|
// Prepend a couple of items before the first group.
|
||||||
menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6");
|
menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6");
|
||||||
menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7");
|
menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7");
|
||||||
menu->Check(MenuTestCase_First + 7, true);
|
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) );
|
||||||
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) );
|
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) );
|
||||||
|
|
||||||
|
|
||||||
// Check that the last radio group still works as expected.
|
// Check that the last radio group still works as expected.
|
||||||
menu->Check(MenuTestCase_First + 4, true);
|
menu->Check(MenuTestCase_First + 4, true);
|
||||||
|
Reference in New Issue
Block a user