diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-03 15:28:51 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-04 17:02:55 +0200 |
commit | 11a11d1280b1634628b9c4a92a0fc420ee8a3a81 (patch) | |
tree | b48d9608ef3f08123cdeea605068342131b32b44 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | 52e07d564b65ed6ce26955a676c7692ad67686c1 (diff) | |
parent | fea26bb2941c3f24c4a5f3ad5efc1b85e0123ff3 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
The merge conflict is about the removal of "d1" from the register
set on ARM, but that was already done in dev in commit ddb33ee9ba9e1344caa9be5dbf4b534c3ede692e
The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675eab163b22dcc4e8ded80ed04d06369b
was reverted to what it was before, per Laszlo's advice.
Conflicts:
src/qml/jit/qv4isel_masm.cpp
Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 88 |
1 files changed, 74 insertions, 14 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index be417df325..e77c15b79a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -146,6 +146,7 @@ private slots: void onCompleted(); void onDestruction(); void scriptString(); + void scriptStringWithoutSourceCode(); void defaultPropertyListOrder(); void declaredPropertyValues(); void dontDoubleCallClassBegin(); @@ -1200,21 +1201,32 @@ void tst_qqmllanguage::inlineQmlComponents() // Tests that types that have an id property have it set void tst_qqmllanguage::idProperty() { - QQmlComponent component(&engine, testFileUrl("idProperty.qml")); - VERIFY_ERRORS(0); - MyContainer *object = qobject_cast<MyContainer *>(component.create()); - QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 2); - MyTypeObject *child = - qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); - QVERIFY(child != 0); - QCOMPARE(child->id(), QString("myObjectId")); - QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); + { + QQmlComponent component(&engine, testFileUrl("idProperty.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast<MyContainer *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->getChildren()->count(), 2); + MyTypeObject *child = + qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("myObjectId")); + QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); - child = - qobject_cast<MyTypeObject *>(object->getChildren()->at(1)); - QVERIFY(child != 0); - QCOMPARE(child->id(), QString("name.with.dots")); + child = + qobject_cast<MyTypeObject *>(object->getChildren()->at(1)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("name.with.dots")); + } + { + QQmlComponent component(&engine, testFileUrl("idPropertyMismatch.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> root(component.create()); + QVERIFY(!root.isNull()); + QQmlContext *ctx = qmlContext(root.data()); + QVERIFY(ctx); + QCOMPARE(ctx->nameForObject(root.data()), QString("root")); + } } // Tests automatic connection to notify signals if "onBlahChanged" syntax is used @@ -1932,6 +1944,54 @@ void tst_qqmllanguage::scriptString() } } +void tst_qqmllanguage::scriptStringWithoutSourceCode() +{ + QUrl url = testFileUrl("scriptString7.qml"); + { + QQmlEnginePrivate *eng = QQmlEnginePrivate::get(&engine); + QQmlTypeData *td = eng->typeLoader.getType(url); + Q_ASSERT(td); + + QV4::CompiledData::QmlUnit *qmlUnit = td->compiledData()->qmlUnit; + Q_ASSERT(qmlUnit); + const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(qmlUnit->indexOfRootObject); + QCOMPARE(qmlUnit->header.stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject")); + quint32 i; + for (i = 0; i < rootObject->nBindings; ++i) { + const QV4::CompiledData::Binding *binding = rootObject->bindingTable() + i; + if (qmlUnit->header.stringAt(binding->propertyNameIndex) != QString("scriptProperty")) + continue; + QCOMPARE(binding->valueAsScriptString(&qmlUnit->header), QString("intProperty")); + const_cast<QV4::CompiledData::Binding*>(binding)->stringIndex = 0; // empty string index + QVERIFY(binding->valueAsScriptString(&qmlUnit->header).isEmpty()); + break; + } + QVERIFY(i < rootObject->nBindings); + } + QQmlComponent component(&engine, url); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QQmlScriptString ss = object->scriptProperty(); + QVERIFY(!ss.isEmpty()); + QCOMPARE(ss.stringLiteral(), QString()); + bool ok; + QCOMPARE(ss.numberLiteral(&ok), qreal(0.)); + QCOMPARE(ok, false); + + const QQmlScriptStringPrivate *scriptPrivate = QQmlScriptStringPrivate::get(ss); + QVERIFY(scriptPrivate != 0); + QVERIFY(scriptPrivate->script.isEmpty()); + QCOMPARE(scriptPrivate->scope, qobject_cast<QObject*>(object)); + QCOMPARE(scriptPrivate->context, qmlContext(object)); + + { + QQmlExpression expr(ss, /*context*/0, object); + QCOMPARE(expr.evaluate().toInt(), int(100)); + } +} + // Check that default property assignments are correctly spliced into explicit // property assignments void tst_qqmllanguage::defaultPropertyListOrder() |