diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2018-10-30 00:49:43 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2018-10-30 00:49:43 +0100 |
commit | 708e4f7e626468f53636b7d2ef7c6a99c129751f (patch) | |
tree | 18e983f3aa8cc15c73a24ededc1eabdbb4c6d800 /tests/auto | |
parent | 4207940684b578469f7ec6b428403af85e579b2c (diff) | |
parent | 475c74a9926efcd968572563e678988e53804603 (diff) |
Merge 5.12 into 5.12.0
Change-Id: I9c455be35c18031c1eb4e8ca8d4b85183f72a051
Diffstat (limited to 'tests/auto')
16 files changed, 223 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/qqmlincubator/data/garbageCollection.qml b/tests/auto/qml/qqmlincubator/data/garbageCollection.qml new file mode 100644 index 0000000000..6866a02a00 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/garbageCollection.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property var incubator + + function getAndClearIncubator() { + var result = incubator + incubator = null + return result + } + + Component.onCompleted: { + var c = Qt.createComponent("statusChanged.qml"); // use existing simple type for convenience + var incubator = c.incubateObject(root); + incubator.onStatusChanged = function(status) { if (status === 1) root.incubator = incubator } + } +} diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index 8f0e04e12e..8e25079703 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -39,6 +39,7 @@ #include <QQmlComponent> #include <QQmlIncubator> #include "../../shared/util.h" +#include <private/qjsvalue_p.h> #include <private/qqmlincubator_p.h> #include <private/qqmlobjectcreator_p.h> @@ -68,6 +69,7 @@ private slots: void chainedAsynchronousClear(); void selfDelete(); void contextDelete(); + void garbageCollection(); private: QQmlIncubationController controller; @@ -1144,6 +1146,34 @@ void tst_qqmlincubator::contextDelete() } } +// QTBUG-53111 +void tst_qqmlincubator::garbageCollection() +{ + QQmlComponent component(&engine, testFileUrl("garbageCollection.qml")); + QScopedPointer<QObject> obj(component.create()); + + engine.collectGarbage(); + + bool b = true; + controller.incubateWhile(&b); + + // verify incubation completed (the incubator was not prematurely collected) + QVariant incubatorVariant; + QMetaObject::invokeMethod(obj.data(), "getAndClearIncubator", Q_RETURN_ARG(QVariant, incubatorVariant)); + QJSValue strongRef = incubatorVariant.value<QJSValue>(); + QVERIFY(!strongRef.isNull() && !strongRef.isUndefined()); + + // turn the last strong reference to the incubator into a weak one and collect + QV4::WeakValue weakIncubatorRef; + weakIncubatorRef.set(QQmlEnginePrivate::getV4Engine(&engine), *QJSValuePrivate::getValue(&strongRef)); + strongRef = QJSValue(); + incubatorVariant.clear(); + + // verify incubator is correctly collected now that incubation is complete and all references are gone + engine.collectGarbage(); + QVERIFY(weakIncubatorRef.isNullOrUndefined()); +} + QTEST_MAIN(tst_qqmlincubator) #include "tst_qqmlincubator.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() diff --git a/tests/auto/quick/qquickstates/data/duplicateStateName.qml b/tests/auto/quick/qquickstates/data/duplicateStateName.qml new file mode 100644 index 0000000000..7bfafbef1b --- /dev/null +++ b/tests/auto/quick/qquickstates/data/duplicateStateName.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + property bool condition1: false + property bool condition2: false + property bool condition3: false + + states: [ + State { name: "state1"; when: condition1 }, + State { name: "state2"; when: condition2 }, + State { name: "state1"; when: condition3 } + ] +} diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index 073fe33e20..50554f6333 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -137,6 +137,7 @@ private slots: void revertListBug(); void QTBUG_38492(); void revertListMemoryLeak(); + void duplicateStateName(); }; void tst_qquickstates::initTestCase() @@ -1654,6 +1655,17 @@ void tst_qquickstates::revertListMemoryLeak() QVERIFY(bindingPtr->ref == 1); } +void tst_qquickstates::duplicateStateName() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("duplicateStateName.qml")); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("duplicateStateName.qml") + ":3:1: QML Rectangle: Found duplicate state name: state1"); + QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem *>(c.create())); + QVERIFY(!item.isNull()); +} + + QTEST_MAIN(tst_qquickstates) #include "tst_qquickstates.moc" |