aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp')
-rw-r--r--tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
index 276f4e2b9f..eb1fbda45a 100644
--- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
+++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
@@ -57,6 +57,7 @@ private slots:
void setRowsMultipleTimes();
void defaultDisplayRoles();
void roleDataProvider();
+ void dataAndEditing();
};
void tst_QQmlTableModel::appendRemoveRow()
@@ -878,6 +879,27 @@ void tst_QQmlTableModel::roleDataProvider()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 5 * 7);
}
+void tst_QQmlTableModel::dataAndEditing()
+{
+ QQuickView view(testFileUrl("dataAndSetData.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQmlTableModel *model = view.rootObject()->property("model").value<QQmlTableModel*>();
+ QVERIFY(model);
+
+ const QHash<int, QByteArray> roleNames = model->roleNames();
+ QVERIFY(roleNames.values().contains("display"));
+ QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
+ QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
+ QVERIFY(QMetaObject::invokeMethod(model, "happyBirthday", Q_ARG(QVariant, QLatin1String("Oliver"))));
+ QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("John"));
+ QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
+ QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
+ QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 34);
+}
+
QTEST_MAIN(tst_QQmlTableModel)
#include "tst_qqmltablemodel.moc"