diff options
author | João Abecasis <joao@abecasis.name> | 2009-05-07 18:45:35 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-05-08 11:28:35 (GMT) |
commit | 813835f67a1053561eba67bf958eb39c0f4eedfe (patch) | |
tree | aba4f5d40d54c8858bbc8dd80453a2d981e36b2e /tests/auto | |
parent | 42e2070925d012845db9cf85e597a17851a0dcb6 (diff) | |
download | Qt-813835f67a1053561eba67bf958eb39c0f4eedfe.zip Qt-813835f67a1053561eba67bf958eb39c0f4eedfe.tar.gz Qt-813835f67a1053561eba67bf958eb39c0f4eedfe.tar.bz2 |
Fix QCompleter with UnfilteredPopupCompletion
Fixes regression introduced in a794ded85f74516239a08cf848e6b4f8b6dcac6a.
When using UnfilteredPopupCompletion the matchCount is always zero and
completion was being skipped. By adding the check for showAll we still
avoid the assert but retain correct behavior.
Task-number: 253125
Reviewed-by: jasplin
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qcompleter/tst_qcompleter.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 656995a..b71cdc6 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -143,6 +143,9 @@ private slots: void task246056_setCompletionPrefix(); void task250064_lostFocus(); + void task253125_lineEditCompletion_data(); + void task253125_lineEditCompletion(); + private: void filter(); void testRowCount(); @@ -1184,5 +1187,48 @@ void tst_QCompleter::task250064_lostFocus() QCOMPARE(textEdit->focusPolicy(), origPolicy); } +void tst_QCompleter::task253125_lineEditCompletion_data() +{ + QTest::addColumn<QStringList>("list"); + QTest::addColumn<int>("completionMode"); + + QStringList list = QStringList() + << "alpha" << "beta" << "gamma" << "delta" << "epsilon" << "zeta" + << "eta" << "theta" << "iota" << "kappa" << "lambda" << "mu" + << "nu" << "xi" << "omicron" << "pi" << "rho" << "sigma" + << "tau" << "upsilon" << "phi" << "chi" << "psi" << "omega"; + + QTest::newRow("Inline") << list << (int)QCompleter::InlineCompletion; + QTest::newRow("Filtered") << list << (int)QCompleter::PopupCompletion; + QTest::newRow("Unfiltered") << list << (int)QCompleter::UnfilteredPopupCompletion; +} + +void tst_QCompleter::task253125_lineEditCompletion() +{ + QFETCH(QStringList, list); + QFETCH(int, completionMode); + + QStringListModel *model = new QStringListModel; + model->setStringList(list); + + QCompleter *completer = new QCompleter(list); + completer->setModel(model); + completer->setCompletionMode((QCompleter::CompletionMode)completionMode); + + QLineEdit edit; + edit.setCompleter(completer); + edit.show(); + edit.setFocus(); + + QTest::qWait(100); + + QTest::keyClick(&edit, 'i'); + QCOMPARE(edit.completer()->currentCompletion(), QString("iota")); + QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); + QTest::keyClick(edit.completer()->popup(), Qt::Key_Enter); + + QCOMPARE(edit.text(), QString("iota")); +} + QTEST_MAIN(tst_QCompleter) #include "tst_qcompleter.moc" |