aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlapplicationengine
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-06-11 01:01:10 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-06-11 11:28:44 +0200
commit10e3b24c02cd1c22c7df0f350f229625e13faeae (patch)
treee9f02181e47156e9c8652e0c5dba15bbdcb97e5a /tests/auto/qml/qqmlapplicationengine
parent8733a8762c2db473d3a39d1f01c09156c04e3772 (diff)
parentac402fa6d99eeb519a9cc23b028358dfb6df4d82 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/qml/jsruntime/qv4value_p.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmltypewrapper.cpp src/quick/items/qquicktableview.cpp Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
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>