diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-19 10:46:15 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-07-19 10:46:15 +0000 |
commit | b3f260236a5f5bcf2db0692e90bb2a875b9da078 (patch) | |
tree | f1cc4378e829cc4521621329764914adb60439da /tests/auto/widgets | |
parent | 267c01390544ba12f81783c8b0e37ed38db231d6 (diff) | |
parent | 82ea53ad24c92b345ac2b542a174887f5de5723a (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp | 19 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 25 |
2 files changed, 42 insertions, 2 deletions
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index b2824c00ee..ff71a6d56b 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -286,8 +286,8 @@ retry: // Testing get/set functions void tst_QCompleter::getSetCheck() { - QStandardItemModel model(3,3); - QCompleter completer(&model); + QStandardItemModel standardItemModel(3,3); + QCompleter completer(&standardItemModel); // QString QCompleter::completionPrefix() // void QCompleter::setCompletionPrefix(QString) @@ -347,6 +347,21 @@ void tst_QCompleter::getSetCheck() QCOMPARE(completer.wrapAround(), true); // default value completer.setWrapAround(false); QCOMPARE(completer.wrapAround(), false); + +#ifndef QT_NO_FILESYSTEMMODEL + // QTBUG-54642, changing from QFileSystemModel to another model should restore role. + completer.setCompletionRole(Qt::EditRole); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); // default value + QFileSystemModel fileSystemModel; + completer.setModel(&fileSystemModel); + QCOMPARE(completer.completionRole(), static_cast<int>(QFileSystemModel::FileNameRole)); + completer.setModel(&standardItemModel); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); + completer.setCompletionRole(Qt::ToolTipRole); + QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models + completer.setModel(&standardItemModel2); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::ToolTipRole)); +#endif // QT_NO_FILESYSTEMMODEL } void tst_QCompleter::csMatchingOnCsSortedModel_data() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 2a356f574c..50024460fc 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -156,6 +156,7 @@ private slots: void itemData(); void task_QTBUG_31146_popupCompletion(); void task_QTBUG_41288_completerChangesCurrentIndex(); + void task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly(); void keyboardSelection(); void setCustomModelAndView(); void updateDelegateOnEditableChange(); @@ -3121,6 +3122,30 @@ void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex() } } +namespace { + struct SetReadOnly { + QComboBox *cb; + explicit SetReadOnly(QComboBox *cb) : cb(cb) {} + void operator()() const + { cb->setEditable(false); } + }; +} + +void tst_QComboBox::task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly() +{ + QComboBox cb; + cb.addItems(QStringList() << "one" << "two"); + cb.setEditable(true); + cb.setCurrentIndex(0); + + connect(&cb, &QComboBox::editTextChanged, + SetReadOnly(&cb)); + + cb.setCurrentIndex(1); + // the real test is that it didn't crash... + QCOMPARE(cb.currentIndex(), 1); +} + void tst_QComboBox::keyboardSelection() { QComboBox comboBox; |