diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-24 01:00:21 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-24 01:00:21 +0200 |
commit | 2ebbf03e880467ecc95adfafe7c0404add8a3328 (patch) | |
tree | 3cce73a83a3b6cb1dd3cefd936a915b333d1fd65 /tests | |
parent | 33bfa05c59a0d4ebcc8943ff710ee1da207da014 (diff) | |
parent | 8a2c182d5941a1d00ac9f7414d1508b7f959d6f3 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ic67fa1536977310b15ba55ee2220536aacef2b3c
Diffstat (limited to 'tests')
12 files changed, 149 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables.mjs b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables.mjs new file mode 100644 index 0000000000..19c012d19b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables.mjs @@ -0,0 +1,31 @@ +export function runTest(libraryUnderTest) { + let state1 = state(libraryUnderTest); + try { modifyFromOutside(libraryUnderTest); } catch (e) {} + let state2 = state(libraryUnderTest); + try { modifyFromInside(libraryUnderTest); } catch (e) {} + let state3 = state(libraryUnderTest); + return state1 + " " + state2 + " " + state3; +} + +function stringify(value) { + let s = "?"; + if (value !== undefined) + s = value.toString(); + return s; +} + +function state(libraryUnderTest) { + return (stringify(libraryUnderTest.varValue) + + stringify(libraryUnderTest.letValue) + + stringify(libraryUnderTest.constValue)); +} + +function modifyFromOutside(libraryUnderTest) { + ++libraryUnderTest.varValue; + ++libraryUnderTest.letValue; + ++libraryUnderTest.constValue; +} + +function modifyFromInside(libraryUnderTest) { + libraryUnderTest.incrementAll(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.mjs b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.mjs new file mode 100644 index 0000000000..b6eb1a2623 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.mjs @@ -0,0 +1,8 @@ +export var varValue = 0; +export let letValue = 0; +export const constValue = 0; +export function incrementAll() { + ++varValue; + ++letValue; + ++constValue; +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.qml b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.qml new file mode 100644 index 0000000000..bb4e759cbf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_module.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importLexicalVariables.mjs" as TestRunner +import "importLexicalVariables_module.mjs" as LibraryUnderTest + +QtObject { + id: root + function runTest() { + return TestRunner.runTest(LibraryUnderTest); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.js new file mode 100644 index 0000000000..f8c215a5e7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.js @@ -0,0 +1,9 @@ +.pragma library +var varValue = 0; +let letValue = 0; +const constValue = 0; +function incrementAll() { + ++varValue; + ++letValue; + ++constValue; +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.qml new file mode 100644 index 0000000000..1b3fe7fa2e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_pragmaLibrary.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importLexicalVariables.mjs" as TestRunner +import "importLexicalVariables_pragmaLibrary.js" as LibraryUnderTest + +QtObject { + id: root + function runTest() { + return TestRunner.runTest(LibraryUnderTest); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.js b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.js new file mode 100644 index 0000000000..4fb68abc87 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.js @@ -0,0 +1,8 @@ +var varValue = 0; +let letValue = 0; +const constValue = 0; +function incrementAll() { + ++varValue; + ++letValue; + ++constValue; +} diff --git a/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.qml b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.qml new file mode 100644 index 0000000000..263511e802 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importLexicalVariables_script.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importLexicalVariables.mjs" as TestRunner +import "importLexicalVariables_script.js" as LibraryUnderTest + +QtObject { + id: root + function runTest() { + return TestRunner.runTest(LibraryUnderTest); + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index cf3eecff6d..8f388fcac6 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -357,6 +357,8 @@ private slots: void jumpStrictNotEqualUndefined(); void removeBindingsWithNoDependencies(); void temporaryDeadZone(); + void importLexicalVariables_data(); + void importLexicalVariables(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8812,6 +8814,38 @@ void tst_qqmlecmascript::temporaryDeadZone() QVERIFY(v.isError()); } +void tst_qqmlecmascript::importLexicalVariables_data() +{ + QTest::addColumn<QUrl>("testFile"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("script") + << testFileUrl("importLexicalVariables_script.qml") + << QStringLiteral("0?? 1?? 2??"); + QTest::newRow("pragmaLibrary") + << testFileUrl("importLexicalVariables_pragmaLibrary.qml") + << QStringLiteral("0?? 1?? 2??"); + QTest::newRow("module") + << testFileUrl("importLexicalVariables_module.qml") + << QStringLiteral("000 000 110"); +} + +void tst_qqmlecmascript::importLexicalVariables() +{ + QFETCH(QUrl, testFile); + QFETCH(QString, expected); + + QQmlEngine engine; + QQmlComponent component(&engine, testFile); + QScopedPointer<QObject> object(component.create()); + QVERIFY(object != nullptr); + QVERIFY(!component.isError()); + + QVariant result; + QMetaObject::invokeMethod(object.data(), "runTest", Qt::DirectConnection, Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result, QVariant(expected)); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmllanguage/data/polymorphicFunctionLookup.qml b/tests/auto/qml/qqmllanguage/data/polymorphicFunctionLookup.qml new file mode 100644 index 0000000000..4a3cc52793 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/polymorphicFunctionLookup.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 +QtObject { + id: root + property bool testFunc; + property bool ok: false + property QtObject subObject: QtObject { + function testFunc() + { + root.ok = true + } + + Component.onCompleted: testFunc() + } +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index d890668655..bb6e9582c2 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1392,7 +1392,7 @@ class ScopedEnumsWithNameClash public: enum class ScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3, OtherScopedEnum }; - enum class OtherScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3 }; + enum class OtherScopedEnum : int { ScopedVal1 = 10, ScopedVal2 = 11, ScopedVal3 = 12 }; }; class ScopedEnumsWithResolvedNameClash diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 157fd500ad..7a8de739f4 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -298,6 +298,8 @@ private slots: void retrieveQmlTypeId(); + void polymorphicFunctionLookup(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -5049,6 +5051,17 @@ void tst_qqmllanguage::retrieveQmlTypeId() QVERIFY(qmlTypeId("Test", 1, 0, "MyTypeObjectSingleton") >= 0); } +void tst_qqmllanguage::polymorphicFunctionLookup() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("polymorphicFunctionLookup.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + QVERIFY(o->property("ok").toBool()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ae02352293..ff796a5bd8 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2676,7 +2676,7 @@ void tst_QQuickListView::sectionsSnap_data() QTest::addColumn<int>("duration"); QTest::newRow("drag") << QQuickListView::NoSnap << QPoint(100, 45) << 500; - QTest::newRow("flick") << QQuickListView::SnapOneItem << QPoint(100, 75) << 50; + QTest::newRow("flick") << QQuickListView::SnapOneItem << QPoint(100, 60) << 100; } void tst_QQuickListView::sectionsSnap() |