summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp5
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp53
2 files changed, 56 insertions, 2 deletions
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 85ee7144c9..6ef0988f31 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -362,8 +362,10 @@ void tst_QDataWidgetMapper::comboBox()
mapper.addMapping(&readWriteBox, 1, "currentText");
mapper.toFirst();
+ // setCurrentIndex caused the value at index 0 to be displayed
QCOMPARE(readOnlyBox.currentText(), QString("read only item 0"));
- QCOMPARE(readWriteBox.currentText(), QString("read write item 0"));
+ // setCurrentText set the value in the line edit since the combobox is editable
+ QCOMPARE(readWriteBox.currentText(), QString("item 0 1"));
// set some new values on the boxes
readOnlyBox.setCurrentIndex(1);
@@ -380,7 +382,6 @@ void tst_QDataWidgetMapper::comboBox()
model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole);
QCOMPARE(readOnlyBox.currentIndex(), 2);
- QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort);
QCOMPARE(readWriteBox.currentText(), QString("read write item z"));
}
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 11e9a9d82f..df0eb89682 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -121,6 +121,8 @@ private slots:
void modelDeleted();
void setMaxCount();
void setCurrentIndex();
+ void setCurrentText_data();
+ void setCurrentText();
void convenienceViews();
void findText_data();
void findText();
@@ -1355,6 +1357,57 @@ void tst_QComboBox::setCurrentIndex()
QCOMPARE(testWidget->currentText(), QString("foo"));
}
+void tst_QComboBox::setCurrentText_data()
+{
+ QTest::addColumn<bool>("editable");
+ QTest::newRow("editable") << true;
+ QTest::newRow("not editable") << false;
+}
+
+void tst_QComboBox::setCurrentText()
+{
+ QFETCH(bool, editable);
+
+ QCOMPARE(testWidget->count(), 0);
+ testWidget->addItems(QStringList() << "foo" << "bar");
+ QCOMPARE(testWidget->count(), 2);
+
+ testWidget->setEditable(editable);
+ testWidget->setCurrentIndex(0);
+ QCOMPARE(testWidget->currentIndex(), 0);
+
+ // effect on currentText and currentIndex
+ // currentIndex not changed if editable
+ QCOMPARE(testWidget->currentText(), QString("foo"));
+ testWidget->setCurrentText(QString("bar"));
+ QCOMPARE(testWidget->currentText(), QString("bar"));
+ if (editable)
+ QCOMPARE(testWidget->currentIndex(), 0);
+ else
+ QCOMPARE(testWidget->currentIndex(), 1);
+
+ testWidget->setCurrentText(QString("foo"));
+ QCOMPARE(testWidget->currentIndex(), 0);
+ QCOMPARE(testWidget->currentText(), QString("foo"));
+
+ // effect of text not found in list
+ testWidget->setCurrentText(QString("qt"));
+ QCOMPARE(testWidget->currentIndex(), 0);
+ if (editable)
+ QCOMPARE(testWidget->currentText(), QString("qt"));
+ else
+ QCOMPARE(testWidget->currentText(), QString("foo"));
+
+#ifndef QT_NO_PROPERTIES
+ // verify WRITE for currentText property
+ testWidget->setCurrentIndex(0);
+ const QByteArray n("currentText");
+ QCOMPARE(testWidget->property(n).toString(), QString("foo"));
+ testWidget->setProperty(n, QString("bar"));
+ QCOMPARE(testWidget->property(n).toString(), QString("bar"));
+#endif
+}
+
void tst_QComboBox::editTextChanged()
{
QCOMPARE(testWidget->count(), 0);