diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-11 11:08:11 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-11 12:00:31 +0100 |
commit | 7c9497a6d47a02d961baef3993ba4cf4267ec607 (patch) | |
tree | 335fae3e9e3a84d33310efca23f1d6993265805b /tests/auto/qml | |
parent | 67ba88947f57ab2d1859bbeb96c6dcba020561b1 (diff) | |
parent | 6c840c70d61c3ae277b60a024a086215c743e5b3 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/qml/compiler/qv4ssa.cpp
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4context.cpp
Change-Id: Ied5b23bec4dc14abe51127c507aed668f855c1e1
Diffstat (limited to 'tests/auto/qml')
6 files changed, 67 insertions, 1 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 529b97ed89..bb5f83bed1 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -47,6 +47,7 @@ #include <qgraphicsitem.h> #include <qstandarditemmodel.h> #include <QtCore/qnumeric.h> +#include <qqmlengine.h> #include <stdlib.h> #include <private/qv4alloca_p.h> @@ -82,6 +83,7 @@ private slots: void newQObject(); void newQObject_ownership(); void newQObject_deletedEngine(); + void exceptionInSlot(); void globalObjectProperties(); void globalObjectEquals(); void globalObjectProperties_enumerate(); @@ -145,6 +147,9 @@ private slots: void arrayPop_QTBUG_35979(); void regexpLastMatch(); + +signals: + void testSignal(); }; tst_QJSEngine::tst_QJSEngine() @@ -507,6 +512,25 @@ void tst_QJSEngine::newQObject_deletedEngine() QTRY_VERIFY(spy.count()); } +void tst_QJSEngine::exceptionInSlot() +{ + QJSEngine engine; + QJSValue wrappedThis = engine.newQObject(this); + QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); + engine.globalObject().setProperty("testCase", wrappedThis); + engine.evaluate( + "var called = false\n" + "function throwingSlot() {\n" + " called = true\n" + " throw 42;\n" + "}\n" + "testCase.testSignal.connect(throwingSlot)\n" + ); + QCOMPARE(engine.globalObject().property("called").toBool(), false); + emit testSignal(); + QCOMPARE(engine.globalObject().property("called").toBool(), true); +} + void tst_QJSEngine::globalObjectProperties() { // See ECMA-262 Section 15.1, "The Global Object". diff --git a/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml b/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml new file mode 100644 index 0000000000..81cb56f0e5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item +{ + property int someInt: 4 + property var variantArray: [1, 2] + property int arrayLength: 0 + + onSomeIntChanged: + { + arrayLength = variantArray.length + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml b/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml new file mode 100644 index 0000000000..2f55ff0709 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml @@ -0,0 +1,6 @@ +import QtQuick 2.1 + +LazyBindingComponent +{ + someInt: 5 +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml index 8d08cc5559..8847055a70 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml @@ -141,6 +141,15 @@ Item { expected = 7; if (poppedVal != expected) success = false; + // push + msco.stringListProperty = [ "one", "two" ] + msco.stringListProperty.push("three") + expected = [ "one", "two", "three" ] + if (msco.stringListProperty.toString() != expected.toString()) success = false; + msco.stringListProperty.push("four", "five") + expected = [ "one", "two", "three", "four", "five" ] + if (msco.stringListProperty.toString() != expected.toString()) success = false; + // concat msco.stringListProperty = [ "one", "two" ] stringList = [ "hello", "world" ] diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 6163628ab5..a39564bd19 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -317,6 +317,7 @@ private slots: void qtbug_34792(); void noCaptureWhenWritingProperty(); void singletonWithEnum(); + void lazyBindingEvaluation(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -663,7 +664,7 @@ void tst_qqmlecmascript::methods() void tst_qqmlecmascript::bindingLoop() { QQmlComponent component(&engine, testFileUrl("bindingLoop.qml")); - QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; + QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); @@ -7533,6 +7534,18 @@ void tst_qqmlecmascript::singletonWithEnum() QCOMPARE(prop.toInt(), int(SingletonWithEnum::TestValue)); } +void tst_qqmlecmascript::lazyBindingEvaluation() +{ + QQmlComponent component(&engine, testFileUrl("lazyBindingEvaluation.qml")); + QScopedPointer<QObject> obj(component.create()); + if (obj.isNull()) + qDebug() << component.errors().first().toString(); + QVERIFY(!obj.isNull()); + QVariant prop = obj->property("arrayLength"); + QVERIFY(prop.type() == QVariant::Int); + QCOMPARE(prop.toInt(), 2); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index e44d5aa8d5..95ca8b5c94 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -67,6 +67,7 @@ void tst_QQMLTypeLoader::testLoadComplete() QTRY_VERIFY(rootObject != 0); QTRY_COMPARE(rootObject->property("created").toInt(), 2); QTRY_COMPARE(rootObject->property("loaded").toInt(), 2); + delete window; } QTEST_MAIN(tst_QQMLTypeLoader) |