summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-15 20:47:57 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-07-15 20:47:57 +0200
commit82ea53ad24c92b345ac2b542a174887f5de5723a (patch)
tree7d326274b52bbedac481be522a20732f77457073 /tests/auto/widgets
parente46e112eb10850801218bd810ecaeb8fd29f4c34 (diff)
parent178ab885626bcd67507fde7f67f65c1872ac3be3 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: qmake/library/qmakeevaluator.cpp One side changed the iterator to use ranged-for, the other changed its body; they only conflicted because the latter had to add braces around the body, intruding on the for-line. Trivial resolution. Change-Id: Ib487bc3bd6e3c5225db15f94b9a8f6caaa33456b
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp19
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp25
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;