diff options
Diffstat (limited to 'tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp')
-rw-r--r-- | tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp index dcfe914af6..a75a00bd01 100644 --- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp +++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp @@ -46,6 +46,7 @@ private slots: void translation(); void idTranslation(); void translationChange(); + void preferJSContext(); }; void tst_qqmltranslation::translation_data() @@ -175,6 +176,10 @@ class DummyTranslator : public QTranslator Q_UNUSED(n); if (!qstrcmp(sourceText, "translate me")) return QString::fromUtf8("xxx"); + if (!qstrcmp(sourceText, "English in mylibrary") && !qstrcmp(context, "mylibrary")) + return QString::fromUtf8("Deutsch in mylibrary"); + if (!qstrcmp(sourceText, "English in translation") && !qstrcmp(context, "nested_js_translation")) + return QString::fromUtf8("Deutsch in Setzung"); return QString(); } @@ -213,6 +218,24 @@ void tst_qqmltranslation::translationChange() QCoreApplication::removeTranslator(&translator); } +void tst_qqmltranslation::preferJSContext() +{ + DummyTranslator translator; + QCoreApplication::installTranslator(&translator); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("preferjs.qml")); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QCOMPARE(object->property("german1").toString(), + QStringLiteral("Deutsch in Setzung")); + QCOMPARE(object->property("german2").toString(), + QStringLiteral("Deutsch in mylibrary")); + + QCoreApplication::removeTranslator(&translator); +} + QTEST_MAIN(tst_qqmltranslation) #include "tst_qqmltranslation.moc" |