diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-20 16:51:57 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-22 10:57:18 +0000 |
commit | b799e061a3cbf995ac7c88b315f5916e3a687162 (patch) | |
tree | 6e215df2359c6b9d3aac855c76ac4534f8771559 /tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp | |
parent | f2e73f5f49d44fd9f94e918489007d57510edb59 (diff) |
LocalStorage: Return new version of DB from changeVersion()
This is probably what you want if you change the version of the
database. Without this, you need to reopen the connection, which makes
the code ugly.
Fixes: QTBUG-71838
Change-Id: I6f1e118ba8e102d1043c4658d036c144bbde7229
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp')
-rw-r--r-- | tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp index f1dcefdab6..28f9c9a0c2 100644 --- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp +++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp @@ -63,6 +63,7 @@ private slots: void testQml_cleanopen_data(); void testQml_cleanopen(); void totalDatabases(); + void upgradeDatabase(); void cleanupTestCase(); @@ -200,6 +201,22 @@ void tst_qqmlsqldatabase::totalDatabases() QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2); } +void tst_qqmlsqldatabase::upgradeDatabase() +{ + QQmlComponent component(engine, testFile("changeVersion.qml")); + QVERIFY(component.isReady()); + + QObject *object = component.create(); + QVERIFY(object); + QVERIFY(object->property("version").toString().isEmpty()); + + QVERIFY(QMetaObject::invokeMethod(object, "create")); + QCOMPARE(object->property("version").toString(), QLatin1String("2")); + + QVERIFY(QMetaObject::invokeMethod(object, "upgrade")); + QCOMPARE(object->property("version").toString(), QLatin1String("22")); +} + QTEST_MAIN(tst_qqmlsqldatabase) #include "tst_qqmlsqldatabase.moc" |