diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
6 files changed, 86 insertions, 6 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/misctypetest.qml b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml index 60ff53a2b4..088ede67ec 100644 --- a/tests/auto/qml/qqmlecmascript/data/misctypetest.qml +++ b/tests/auto/qml/qqmlecmascript/data/misctypetest.qml @@ -11,7 +11,7 @@ Item { return mtt.invalidUrl() == mtt.invalidUrl(); } - function test_invalid_url_refequal() + function test_invalid_url_strictequal() { return mtt.invalidUrl() === mtt.invalidUrl(); } @@ -21,7 +21,7 @@ Item { return mtt.validUrl() == mtt.validUrl(); } - function test_valid_url_refequal() + function test_valid_url_strictequal() { return mtt.validUrl() === mtt.validUrl(); } diff --git a/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml b/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml new file mode 100644 index 0000000000..8b8601692d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 +QtObject { + property bool somePropertyEvaluated: false; + + property int someProperty: { + // It's sort of evil to set the property here, but that doesn't mean that + // this expression should get re-evaluated when unrelatedProperty changes later. + somePropertyEvaluated = true + return 20; + } + Component.onCompleted: { + somePropertyEvaluated = false + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml index 52abda1e55..8d08cc5559 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml @@ -140,6 +140,22 @@ Item { if (msco.intListProperty.toString() != expected.toString()) success = false; expected = 7; if (poppedVal != expected) success = false; + + // concat + msco.stringListProperty = [ "one", "two" ] + stringList = [ "hello", "world" ] + stringList = stringList.concat(msco.stringListProperty) + expected = [ "hello", "world", "one", "two" ] + if (stringList.length != expected.length) { + success = false; + } else { + for (var i = 0; i < stringList.length; ++i) { + if (stringList[i] != expected[i]) { + success = false; + break; + } + } + } } property variant variantList: [ 1, 2, 3, 4, 5 ]; diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml index 975be1b2ad..7e85312692 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml @@ -57,4 +57,38 @@ QtObject { if (onTestSignal !== undefined) definedHandlerResult = true; } + + property QtObject objWithAlias: QtObject { + id: testObjectWithAlias + + property int count: 0; + property alias countAlias: testObjectWithAlias.count + } + + function testConnectionOnAlias() { + var called = false; + + testObjectWithAlias.onCountAliasChanged.connect(function() { + called = true + }) + + testObjectWithAlias.count++; + return called; + } + + property QtObject objWithAliasHandler: QtObject { + id: testObjectWithAliasHandler + + property bool testSuccess: false + + property int count: 0 + property alias countAlias: testObjectWithAliasHandler.count + onCountAliasChanged: testSuccess = true + } + + function testAliasSignalHandler() { + testObjectWithAliasHandler.testSuccess = false + testObjectWithAliasHandler.count++ + return testObjectWithAliasHandler.testSuccess + } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 41fa3672bd..22fac2013e 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -106,7 +106,7 @@ public: void MyQmlObject::v8function(QQmlV4Function *function) { - QV8Engine::getV4(function->engine())->current->throwError(QStringLiteral("Exception thrown from within QObject slot")); + QV8Engine::getV4(function->engine())->currentContext()->throwError(QStringLiteral("Exception thrown from within QObject slot")); } static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 6b19c13109..7b89709923 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -319,6 +319,7 @@ private slots: void stackLimits(); void idsAsLValues(); void qtbug_34792(); + void noCaptureWhenWritingProperty(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -2267,7 +2268,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); program.inheritContext = true; - QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext(); QV4::Scope scope(ctx); QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); @@ -2295,7 +2296,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o, QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); program.inheritContext = true; - QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext(); QV4::Scope scope(ctx); QV4::Scoped<QV4::FunctionObject> function(scope, program.run()); @@ -2324,7 +2325,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext(); QV4::Scope scope(ctx); QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); @@ -6060,6 +6061,13 @@ void tst_qqmlecmascript::signalHandlers() QMetaObject::invokeMethod(o, "testSignalHandlerDefined"); QCOMPARE(o->property("definedHandlerResult").toBool(), true); + QVariant result; + QMetaObject::invokeMethod(o, "testConnectionOnAlias", Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result.toBool(), true); + + QMetaObject::invokeMethod(o, "testAliasSignalHandler", Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result.toBool(), true); + delete o; } @@ -7491,6 +7499,14 @@ void tst_qqmlecmascript::qtbug_34792() delete object; } +void tst_qqmlecmascript::noCaptureWhenWritingProperty() +{ + QQmlComponent component(&engine, testFileUrl("noCaptureWhenWritingProperty.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("somePropertyEvaluated").toBool(), false); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |