summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2014-12-29 10:35:09 +0100
committerAndré Hartmann <aha_1980@gmx.de>2015-03-18 16:57:19 +0000
commite610ef8c8d156f8e70a51c719458eaea1b2266a8 (patch)
treebace99e38b9454cd99d360804fa8cf775e4deea4 /tests
parentf64b87a5df8870be138dbf3febad950e1fc4ed8c (diff)
QComboBox: Update completer on setCurrentIndex()
When the ComboBox currentText() was changed by key LineUp or LineDown or mouse click, the completer still contained the last inserted characters. If now all text was selected (by Ctrl+A or selectAll()), the old item and index was restored on next Enter press. Task-number: QTBUG-41288 Change-Id: I6916fd31c8b8fbacfb12e1a62c3e46823cf918b4 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 23d0ffd2d2..4e0808a7b3 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -158,6 +158,7 @@ private slots:
void highlightedSignal();
void itemData();
void task_QTBUG_31146_popupCompletion();
+ void task_QTBUG_41288_completerChangesCurrentIndex();
void keyboardSelection();
void setCustomModelAndView();
void updateDelegateOnEditableChange();
@@ -3026,6 +3027,44 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion()
QCOMPARE(comboBox.currentIndex(), 0);
}
+void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex()
+{
+ QComboBox comboBox;
+ comboBox.setEditable(true);
+
+ comboBox.addItems(QStringList() << QStringLiteral("111") << QStringLiteral("222"));
+
+ comboBox.show();
+ comboBox.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&comboBox));
+
+ {
+ // change currentIndex() by keyboard
+ comboBox.lineEdit()->selectAll();
+ QTest::keyClicks(comboBox.lineEdit(), "222");
+ QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter);
+ QCOMPARE(comboBox.currentIndex(), 1);
+
+ QTest::keyClick(&comboBox, Qt::Key_Up);
+ comboBox.lineEdit()->selectAll();
+ QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter);
+ QCOMPARE(comboBox.currentIndex(), 0);
+ }
+
+ {
+ // change currentIndex() programmatically
+ comboBox.lineEdit()->selectAll();
+ QTest::keyClicks(comboBox.lineEdit(), "222");
+ QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter);
+ QCOMPARE(comboBox.currentIndex(), 1);
+
+ comboBox.setCurrentIndex(0);
+ comboBox.lineEdit()->selectAll();
+ QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter);
+ QCOMPARE(comboBox.currentIndex(), 0);
+ }
+}
+
void tst_QComboBox::keyboardSelection()
{
QComboBox comboBox;