summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFrédéric Mercille <fmercille@homer.(none)>2009-07-17 12:46:29 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-17 13:20:24 (GMT)
commit866e6e6338767086cef8f97bc4e7b38e78b83651 (patch)
tree81fdb2a2403ef12db4d0305335b65ba14c35ee2a /tests/auto
parente3a34408aa65af33494b7154ab5eaefe676b5f20 (diff)
downloadQt-866e6e6338767086cef8f97bc4e7b38e78b83651.zip
Qt-866e6e6338767086cef8f97bc4e7b38e78b83651.tar.gz
Qt-866e6e6338767086cef8f97bc4e7b38e78b83651.tar.bz2
Lets the size of the completer be configurable in a way similar to QComboBox.
Merge-request: 884 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index fb03e1a..0a9c16a 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -102,6 +102,8 @@ public:
~tst_QCompleter();
private slots:
+ void getSetCheck();
+
void multipleWidgets();
void focusIn();
@@ -268,6 +270,72 @@ void tst_QCompleter::filter()
QCOMPARE(completer->currentCompletion(), completionText);
}
+// Testing get/set functions
+void tst_QCompleter::getSetCheck()
+{
+ QStandardItemModel model(3,3);
+ QCompleter completer(&model);
+
+ // QString QCompleter::completionPrefix()
+ // void QCompleter::setCompletionPrefix(QString)
+ completer.setCompletionPrefix(QString("te"));
+ QCOMPARE(completer.completionPrefix(), QString("te"));
+ completer.setCompletionPrefix(QString());
+ QCOMPARE(completer.completionPrefix(), QString());
+
+ // ModelSorting QCompleter::modelSorting()
+ // void QCompleter::setModelSorting(ModelSorting)
+ completer.setModelSorting(QCompleter::CaseSensitivelySortedModel);
+ QCOMPARE(completer.modelSorting(), QCompleter::CaseSensitivelySortedModel);
+ completer.setModelSorting(QCompleter::CaseInsensitivelySortedModel);
+ QCOMPARE(completer.modelSorting(), QCompleter::CaseInsensitivelySortedModel);
+ completer.setModelSorting(QCompleter::UnsortedModel);
+ QCOMPARE(completer.modelSorting(), QCompleter::UnsortedModel);
+
+ // CompletionMode QCompleter::completionMode()
+ // void QCompleter::setCompletionMode(CompletionMode)
+ QCOMPARE(completer.completionMode(), QCompleter::PopupCompletion); // default value
+ completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+ QCOMPARE(completer.completionMode(), QCompleter::UnfilteredPopupCompletion);
+ completer.setCompletionMode(QCompleter::InlineCompletion);
+ QCOMPARE(completer.completionMode(), QCompleter::InlineCompletion);
+
+ // int QCompleter::completionColumn()
+ // void QCompleter::setCompletionColumn(int)
+ completer.setCompletionColumn(2);
+ QCOMPARE(completer.completionColumn(), 2);
+ completer.setCompletionColumn(1);
+ QCOMPARE(completer.completionColumn(), 1);
+
+ // int QCompleter::completionRole()
+ // void QCompleter::setCompletionRole(int)
+ QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); // default value
+ completer.setCompletionRole(Qt::DisplayRole);
+ QCOMPARE(completer.completionRole(), static_cast<int>(Qt::DisplayRole));
+
+ // int QCompleter::maxVisibleItems()
+ // void QCompleter::setMaxVisibleItems(int)
+ QCOMPARE(completer.maxVisibleItems(), 7); // default value
+ completer.setMaxVisibleItems(10);
+ QCOMPARE(completer.maxVisibleItems(), 10);
+ QTest::ignoreMessage(QtWarningMsg, "QCompleter::setMaxVisibleItems: "
+ "Invalid max visible items (-2147483648) must be >= 0");
+ completer.setMaxVisibleItems(INT_MIN);
+ QCOMPARE(completer.maxVisibleItems(), 10); // Cannot be set to something negative => old value
+
+ // Qt::CaseSensitivity QCompleter::caseSensitivity()
+ // void QCompleter::setCaseSensitivity(Qt::CaseSensitivity)
+ QCOMPARE(completer.caseSensitivity(), Qt::CaseSensitive); // default value
+ completer.setCaseSensitivity(Qt::CaseInsensitive);
+ QCOMPARE(completer.caseSensitivity(), Qt::CaseInsensitive);
+
+ // bool QCompleter::wrapAround()
+ // void QCompleter::setWrapAround(bool)
+ QCOMPARE(completer.wrapAround(), true); // default value
+ completer.setWrapAround(false);
+ QCOMPARE(completer.wrapAround(), false);
+}
+
void tst_QCompleter::csMatchingOnCsSortedModel_data()
{
delete completer;