diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-05-18 00:43:25 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-05-18 00:47:11 (GMT) |
commit | 273024e58d90bb9b3a5da0161f884f1af22d75df (patch) | |
tree | 92f8348094c45b2f6a1cac38b663cd381d589fb2 /tests/auto/declarative/qdeclarativelanguage | |
parent | 4530e4c8cf1ddb1ac92fc04fa5d25b0b78308534 (diff) | |
download | Qt-273024e58d90bb9b3a5da0161f884f1af22d75df.zip Qt-273024e58d90bb9b3a5da0161f884f1af22d75df.tar.gz Qt-273024e58d90bb9b3a5da0161f884f1af22d75df.tar.bz2 |
Use QDeclarativeScriptString for ParentChange.
So that scope resolution is correct, e.g. "width: parent.width-10;" in
a ParentChange works correctly.
Task-number: QTBUG-10675
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
4 files changed, 56 insertions, 12 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.3.qml new file mode 100644 index 0000000..0de3667 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: "hello world" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.4.qml new file mode 100644 index 0000000..0cd82ff --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: 12.345 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.5.qml new file mode 100644 index 0000000..3e2f9a4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.5.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: true +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 6b070f5..4434e46 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1105,19 +1105,48 @@ void tst_qdeclarativelanguage::onDestruction() // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); - VERIFY_ERRORS(0); + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); + VERIFY_ERRORS(0); - MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); - QVERIFY(object != 0); - QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); - QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->scriptProperty().context(), qmlContext(object)); - - QVERIFY(object->grouped() != 0); - QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); - QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); + QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->scriptProperty().context(), qmlContext(object)); + + QVERIFY(object->grouped() != 0); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); + QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("\"hello world\"")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("12.345")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString5.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("true")); + } } // Check that default property assignments are correctly spliced into explicit |