summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-10-31 17:12:11 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-01 03:17:57 +0100
commit390e20fc71e787fd37639fdba16a854771237b79 (patch)
treecf35d4b0efdf9be018c716410fef75139f1de5c5 /tests/auto/widgets
parent1365d290c670f1f082b1286637d67f516f41d726 (diff)
Improve QMenu autotest.
Originally this commit was just going to reinstate the disabled line of test data (after correcting it to use keyboard modifiers instead of invalid bitwise-or of key-codes, which would trigger an assert in qtestlib). Unfortunately, this revealed a minor bug in QMenu, as reported in QTBUG-22449, so a QEXPECT_FAIL has also been added. Change-Id: I29699fcbfa353c037a83379a6140f0e3da5be027 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 61bbd5449d..a83785a1a0 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -56,6 +56,9 @@
#include <qstyle.h>
#include <qdebug.h>
+Q_DECLARE_METATYPE(Qt::Key);
+Q_DECLARE_METATYPE(Qt::KeyboardModifiers);
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -308,7 +311,8 @@ void tst_QMenu::mouseActivation()
void tst_QMenu::keyboardNavigation_data()
{
- QTest::addColumn<int>("key");
+ QTest::addColumn<Qt::Key>("key");
+ QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
QTest::addColumn<int>("expected_action");
QTest::addColumn<int>("expected_menu");
QTest::addColumn<bool>("init");
@@ -316,31 +320,30 @@ void tst_QMenu::keyboardNavigation_data()
QTest::addColumn<bool>("expected_highlighted");
//test up and down (order is important here)
- QTest::newRow("data0") << int(Qt::Key_Down) << 0 << 0 << true << false << true;
- QTest::newRow("data1") << int(Qt::Key_Down) << 2 << 0 << false << false << true; //skips the separator
- QTest::newRow("data2") << int(Qt::Key_Down) << 3 << 0 << false << false << true;
+ QTest::newRow("data0") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 0 << 0 << true << false << true;
+ QTest::newRow("data1") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 2 << 0 << false << false << true; //skips the separator
+ QTest::newRow("data2") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false << true;
if (QApplication::style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled))
- QTest::newRow("data3_noMac") << int(Qt::Key_Down) << 4 << 0 << false << false << true;
+ QTest::newRow("data3_noMac") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 4 << 0 << false << false << true;
else
- QTest::newRow("data3_Mac") << int(Qt::Key_Down) << 5 << 0 << false << false << true;
- QTest::newRow("data4") << int(Qt::Key_Up) << 3 << 0 << false << false << true;
- QTest::newRow("data5") << int(Qt::Key_Up) << 2 << 0 << false << false << true;
- QTest::newRow("data6") << int(Qt::Key_Right) << 8 << 1 << false << false << true;
- QTest::newRow("data7") << int(Qt::Key_Down) << 9 << 1 << false << false << true;
- QTest::newRow("data8") << int(Qt::Key_Escape) << 2 << 0 << false << false << false;
- QTest::newRow("data9") << int(Qt::Key_Down) << 3 << 0 << false << false<< true;
- QTest::newRow("data10") << int(Qt::Key_Return) << 3 << 0 << false << true << false;
-
- //test shortcuts
-#if 0
- QTest::newRow("shortcut0") << (Qt::ALT | Qt::Key_A) << 2 << 0 << true << true << false;
-#endif
+ QTest::newRow("data3_Mac") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 5 << 0 << false << false << true;
+ QTest::newRow("data4") << Qt::Key(Qt::Key_Up) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false << true;
+ QTest::newRow("data5") << Qt::Key(Qt::Key_Up) << Qt::KeyboardModifiers(Qt::NoModifier) << 2 << 0 << false << false << true;
+ QTest::newRow("data6") << Qt::Key(Qt::Key_Right) << Qt::KeyboardModifiers(Qt::NoModifier) << 8 << 1 << false << false << true;
+ QTest::newRow("data7") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 9 << 1 << false << false << true;
+ QTest::newRow("data8") << Qt::Key(Qt::Key_Escape) << Qt::KeyboardModifiers(Qt::NoModifier) << 2 << 0 << false << false << false;
+ QTest::newRow("data9") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false<< true;
+ QTest::newRow("data10") << Qt::Key(Qt::Key_Return) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << true << false;
+
+ // Test shortcuts.
+ QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false;
}
void tst_QMenu::keyboardNavigation()
{
- QFETCH(int, key);
+ QFETCH(Qt::Key, key);
+ QFETCH(Qt::KeyboardModifiers, modifiers);
QFETCH(int, expected_action);
QFETCH(int, expected_menu);
QFETCH(bool, init);
@@ -354,9 +357,10 @@ void tst_QMenu::keyboardNavigation()
lastMenu->popup(QPoint(0, 0));
}
- QTest::keyClick(lastMenu, (Qt::Key)key);
+ QTest::keyClick(lastMenu, key, modifiers);
if (expected_activated) {
QCOMPARE(activated, builtins[expected_action]);
+ QEXPECT_FAIL("shortcut0", "QTBUG-22449: QMenu doesn't remove highlight if a menu item is activated by a shortcut", Abort);
QCOMPARE(menus[expected_menu]->activeAction(), (QAction *)0);
} else {
QCOMPARE(menus[expected_menu]->activeAction(), builtins[expected_action]);