aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-02-14 08:21:39 +0100
committerLars Knoll <lars.knoll@qt.io>2017-02-14 08:21:39 +0100
commit802bebd566574153e7bf96470199732bf36c36da (patch)
treedf749b7bdcea1ef37fa6c4cd7ca502b94d839415 /tests/auto/qml
parent24d4e164ad4ef0bf8e5a4a0f2c28e3b9df48d352 (diff)
parent32f6315d6d458600bb3f1db08c53148557382c21 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp13
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp29
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 99fe262cb4..44582817d5 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -337,6 +337,7 @@ private slots:
void constkw_data();
void constkw();
void redefineGlobalProp();
+ void freeze_empty_object();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8289,6 +8290,18 @@ void tst_qqmlecmascript::redefineGlobalProp()
}
}
+void tst_qqmlecmascript::freeze_empty_object()
+{
+ // this shouldn't crash
+ QJSEngine engine;
+ QJSValue v = engine.evaluate(QString::fromLatin1(
+ "var obj = {};\n"
+ "Object.freeze(obj);\n"
+ ));
+ QVERIFY(!v.isError());
+ QCOMPARE(v.toBool(), true);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 9c155eda5b..e170920486 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -56,6 +56,7 @@ private slots:
void baseUrl();
void contextForObject();
void offlineStoragePath();
+ void offlineDatabaseStoragePath();
void clearComponentCache();
void trimComponentCache();
void trimComponentCache_data();
@@ -252,6 +253,34 @@ void tst_qqmlengine::offlineStoragePath()
QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
}
+void tst_qqmlengine::offlineDatabaseStoragePath()
+{
+ // Without these set, QDesktopServices::storageLocation returns
+ // strings with extra "//" at the end. We set them to ignore this problem.
+ qApp->setApplicationName("tst_qqmlengine");
+ qApp->setOrganizationName("QtProject");
+ qApp->setOrganizationDomain("www.qt-project.org");
+
+ QQmlEngine engine;
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ const QString databaseName = QLatin1String("foo");
+ QString databaseLocation = engine.offlineStorageDatabaseFilePath(databaseName);
+ QCOMPARE(dataLocation.isEmpty(), databaseLocation.isEmpty());
+
+ QDir dir(dataLocation);
+ dir.mkpath("QML");
+ dir.cd("QML");
+ dir.mkpath("OfflineStorage");
+ dir.cd("OfflineStorage");
+ dir.mkpath("Databases");
+ dir.cd("Databases");
+ QCOMPARE(QFileInfo(databaseLocation).dir().path(), dir.path());
+
+ QCryptographicHash md5(QCryptographicHash::Md5);
+ md5.addData(databaseName.toUtf8());
+ QCOMPARE(databaseLocation, QDir::toNativeSeparators(dir.filePath(QLatin1String(md5.result().toHex()))));
+}
+
void tst_qqmlengine::clearComponentCache()
{
QQmlEngine engine;