diff options
Diffstat (limited to 'tests')
14 files changed, 135 insertions, 11 deletions
diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp index c7f8ec1118..f08f3c1da7 100644 --- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp +++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp @@ -322,7 +322,7 @@ void tst_QQmlPreview::zoom() for (auto testZoomFactor : {2.0f, 1.5f, 0.5f}) { m_client->triggerZoom(testZoomFactor); - verifyZoomFactor(m_process, baseZoomFactor * testZoomFactor); + verifyZoomFactor(m_process, testZoomFactor); } m_client->triggerZoom(-1.0f); diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index 0e0d70845b..4c04afe886 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -712,8 +712,6 @@ language/statements/generators/yield-identifier-non-strict.js sloppyFails language/statements/let/block-local-closure-set-before-initialization.js fails language/statements/let/function-local-closure-set-before-initialization.js fails language/statements/let/global-closure-set-before-initialization.js fails -language/statements/throw/S12.13_A2_T6.js strictFails -language/statements/try/S12.14_A18_T6.js strictFails language/statements/try/scope-catch-block-lex-open.js fails language/statements/variable/binding-resolution.js sloppyFails language/statements/with/unscopables-inc-dec.js sloppyFails diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm Binary files differnew file mode 100644 index 0000000000..8e3c4967c2 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm 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> diff --git a/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml b/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml new file mode 100644 index 0000000000..3166ab647d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 +import Test.Singletons 1.0 + +QtObject { + property Component singletonAccessor : Component { + QtObject { + property var singletonHolder; + property int result: singletonHolder.testVar + } + } + + property int firstLookup: singletonAccessor.createObject(this, { singletonHolder: CppSingleton1 }).result; + property int secondLookup: singletonAccessor.createObject(this, { singletonHolder: CppSingleton2 }).result; +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 5ae9a6b038..5b73ffbe1d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -369,6 +369,7 @@ private slots: void intMinDividedByMinusOne(); void undefinedPropertiesInObjectWrapper(); void hugeRegexpQuantifiers(); + void singletonTypeWrapperLookup(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -9007,6 +9008,55 @@ void tst_qqmlecmascript::hugeRegexpQuantifiers() QVERIFY(value.isRegExp()); } +struct CppSingleton1 : public QObject +{ + Q_OBJECT + Q_PROPERTY(int testVar MEMBER testVar CONSTANT) +public: + const int testVar = 0; +}; + +struct CppSingleton2 : public QObject +{ + Q_OBJECT + Q_PROPERTY(int testVar MEMBER testVar CONSTANT) +public: + const int testVar = 1; +}; + +void tst_qqmlecmascript::singletonTypeWrapperLookup() +{ + QQmlEngine engine; + + auto singletonTypeId1 = qmlRegisterSingletonType<CppSingleton1>("Test.Singletons", 1, 0, "CppSingleton1", + [](QQmlEngine *, QJSEngine *) -> QObject * { + return new CppSingleton1; + }); + + auto singletonTypeId2 = qmlRegisterSingletonType<CppSingleton2>("Test.Singletons", 1, 0, "CppSingleton2", + [](QQmlEngine *, QJSEngine *) -> QObject * { + return new CppSingleton2; + }); + + auto cleanup = qScopeGuard([&]() { + QQmlMetaType::unregisterType(singletonTypeId1); + QQmlMetaType::unregisterType(singletonTypeId2); + }); + + QQmlComponent component(&engine, testFileUrl("SingletonLookupTest.qml")); + QScopedPointer<QObject> test(component.create()); + QVERIFY2(!test.isNull(), qPrintable(component.errorString())); + + auto singleton1 = engine.singletonInstance<CppSingleton1*>(singletonTypeId1); + QVERIFY(singleton1); + + auto singleton2 = engine.singletonInstance<CppSingleton2*>(singletonTypeId2); + QVERIFY(singleton2); + + QCOMPARE(test->property("firstLookup").toInt(), singleton1->testVar); + QCOMPARE(test->property("secondLookup").toInt(), singleton2->testVar); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index fead8c4ebc..f16e96a385 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -54,6 +54,7 @@ private slots: void noSubstitutionTemplateLiteral(); void templateLiteral(); void leadingSemicolonInClass(); + void templatedReadonlyProperty(); private: QStringList excludedDirs; @@ -289,6 +290,15 @@ void tst_qqmlparser::leadingSemicolonInClass() QVERIFY(parser.parseProgram()); } +void tst_qqmlparser::templatedReadonlyProperty() +{ + QQmlJS::Engine engine; + QQmlJS::Lexer lexer(&engine); + lexer.setCode(QLatin1String("A { readonly property list<B> listfoo: [ C{} ] }"), 1); + QQmlJS::Parser parser(&engine); + QVERIFY(parser.parse()); +} + QTEST_MAIN(tst_qqmlparser) #include "tst_qqmlparser.moc" diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index a1b2b64ae2..9f7ede44cf 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1491,11 +1491,11 @@ void tst_QQuickPathView::undefinedPath() // QPainterPath warnings are only received if QT_NO_DEBUG is not defined if (QLibraryInfo::isDebugBuild()) { - QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1)); + QRegularExpression warning1("^QPainterPath::moveTo:.*ignoring call$"); + QTest::ignoreMessage(QtWarningMsg, warning1); - QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2)); + QRegularExpression warning2("^QPainterPath::lineTo:.*ignoring call$"); + QTest::ignoreMessage(QtWarningMsg, warning2); } QQmlComponent c(&engine, testFileUrl("undefinedpath.qml")); diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 063358c795..b4abdd6fe2 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -564,7 +564,10 @@ bool tst_SceneGraph::isRunningOnOpenGL() bool retval = false; QQuickView dummy; dummy.show(); - QTest::qWaitForWindowExposed(&dummy); + if (!QTest::qWaitForWindowExposed(&dummy)) { + [](){ QFAIL("Could not show a QQuickView"); }(); + return false; + } if (dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) retval = true; dummy.hide(); diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index fd5c3653ad..691dfd1bc6 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -449,9 +449,6 @@ void tst_qquickwidget::reparentToNewWindow() qqw->setParent(&window2); qqw->show(); - if (QGuiApplication::platformName() == QLatin1String("offscreen")) - QEXPECT_FAIL("", "afterRendering not emitted after reparenting on offscreen", Continue); - QTRY_VERIFY(afterRenderingSpy.size() > 0); QImage img = qqw->grabFramebuffer(); |