aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlapplicationengine
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlapplicationengine')
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qmbin0 -> 102 bytes
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts11
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml5
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp27
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro3
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc6
6 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm
new file mode 100644
index 0000000000..8e3c4967c2
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm
Binary files differ
diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts
new file mode 100644
index 0000000000..51a204be3e
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="" sourcelanguage="en">
+<context>
+ <name>loadTranslation</name>
+ <message>
+ <source>translate it</source>
+ <translation>translated</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml
new file mode 100644
index 0000000000..bba4cab8d6
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+
+QtObject {
+ property string translation: qsTr('translate it')
+}
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index ce654dc45e..a9c28a0911 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -50,6 +50,9 @@ private slots:
void application();
void applicationProperties();
void removeObjectsWhenDestroyed();
+ void loadTranslation_data();
+ void loadTranslation();
+
private:
QString buildDir;
QString srcDir;
@@ -241,6 +244,30 @@ void tst_qqmlapplicationengine::removeObjectsWhenDestroyed()
QCOMPARE(test->rootObjects().size(), 0);
}
+void tst_qqmlapplicationengine::loadTranslation_data()
+{
+ QTest::addColumn<QUrl>("qmlUrl");
+ QTest::addColumn<QString>("translation");
+
+ QTest::newRow("local file") << testFileUrl("loadTranslation.qml")
+ << QStringLiteral("translated");
+ QTest::newRow("qrc") << QUrl(QLatin1String("qrc:///data/loadTranslation.qml"))
+ << QStringLiteral("translated");
+}
+
+void tst_qqmlapplicationengine::loadTranslation()
+{
+ QFETCH(QUrl, qmlUrl);
+ QFETCH(QString, translation);
+
+ QQmlApplicationEngine test(qmlUrl);
+ QVERIFY(!test.rootObjects().isEmpty());
+
+ QObject *rootObject = test.rootObjects().first();
+ QVERIFY(rootObject);
+
+ QCOMPARE(rootObject->property("translation").toString(), translation);
+}
QTEST_MAIN(tst_qqmlapplicationengine)
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
index 18c38a80b6..88d07f2b62 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
@@ -5,6 +5,9 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qqmlapplicationengine.cpp
TESTDATA += data/*
+RESOURCES += tst_qqmlapplicationengine.qrc
include (../../shared/util.pri)
QT += core-private gui-private qml-private network testlib
+
+TRANSLATIONS = data/i18n/qml_ja.ts
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc
new file mode 100644
index 0000000000..de79d665a3
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>data/loadTranslation.qml</file>
+ <file>data/i18n/qml.qm</file>
+ </qresource>
+</RCC>