summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2013-09-11 10:50:39 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-04 13:19:57 +0100
commit3e549f5daa55464512ee2763558f3a7ffd45c545 (patch)
tree9713933b6ae01159706a08fb10eac759441673e2 /tests/auto/widgets/widgets
parent5da094c1aa21d0440a31bf09d51016b8af7de046 (diff)
QComboBox: fix keyboard selection with multiple character strings.
Take longer search strings into account instead of just using the first character of the search string. Touches up https://qt.gitorious.org/qt/qt/merge_requests/1418 for resubmission. Task-number: QTBUG-3032 [ChangeLog][QtWidgets][QSpinBox] Fixed keyboard selection with multiple-character strings. Change-Id: I2f68c8b97b1a1884659dcb19f52b1efeace9b88b Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index eabb7aaa17..509ccc37b6 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -162,6 +162,7 @@ private slots:
void highlightedSignal();
void itemData();
void task_QTBUG_31146_popupCompletion();
+ void keyboardSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1848,7 +1849,7 @@ void tst_QComboBox::flaggedItems_data()
itemList << "nine" << "ten";
keyMovementList << Qt::Key_T;
- QTest::newRow(testCase.toLatin1() + "search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 9;
+ QTest::newRow(testCase.toLatin1() + "search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
keyMovementList.clear();
keyMovementList << Qt::Key_T << Qt::Key_H;
@@ -2946,5 +2947,32 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion()
QCOMPARE(comboBox.currentIndex(), 0);
}
+void tst_QComboBox::keyboardSelection()
+{
+ QComboBox comboBox;
+ const int keyboardInterval = QApplication::keyboardInputInterval();
+ QStringList list;
+ list << "OA" << "OB" << "OC" << "OO" << "OP" << "PP";
+ comboBox.addItems(list);
+
+ // Clear any remaining keyboard input from previous tests.
+ QTest::qWait(keyboardInterval);
+ QTest::keyClicks(&comboBox, "oo", Qt::NoModifier, 50);
+ QCOMPARE(comboBox.currentText(), list.at(3));
+
+ QTest::qWait(keyboardInterval);
+ QTest::keyClicks(&comboBox, "op", Qt::NoModifier, 50);
+ QCOMPARE(comboBox.currentText(), list.at(4));
+
+ QTest::keyClick(&comboBox, Qt::Key_P, Qt::NoModifier, keyboardInterval);
+ QCOMPARE(comboBox.currentText(), list.at(5));
+
+ QTest::keyClick(&comboBox, Qt::Key_O, Qt::NoModifier, keyboardInterval);
+ QCOMPARE(comboBox.currentText(), list.at(0));
+
+ QTest::keyClick(&comboBox, Qt::Key_O, Qt::NoModifier, keyboardInterval);
+ QCOMPARE(comboBox.currentText(), list.at(1));
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"