diff options
46 files changed, 202 insertions, 10 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 240f16c..8e92eb4 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -1714,7 +1714,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value, obj, ctxt.incr())); obj->addValueTypeProperty(prop); } else { - COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property access")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid grouped property access")); } } else { @@ -1722,7 +1722,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value->metatype = QmlEnginePrivate::get(engine)->metaObjectForType(prop->type); if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Cannot nest non-QObject property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid grouped property access")); obj->addGroupedProperty(prop); @@ -1749,8 +1749,11 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, prop->index = idx; prop->type = p.userType(); - if (prop->value || prop->values.count() != 1) - COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use")); + if (prop->value) + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Property assignment expected")); + + if (prop->values.count() != 1) + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Single property assignment expected")); Value *value = prop->values.at(0); @@ -1758,7 +1761,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1; bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1; if (!isPropertyValue && !isPropertyInterceptor) { - COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Unexpected object assignment")); } else { COMPILE_CHECK(buildObject(value->object, ctxt)); diff --git a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml index 50723a3..c86c96b 100644 --- a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml @@ -23,6 +23,7 @@ MyTypeObject { boolProperty: true variantProperty: "Hello World!" vectorProperty: "10,1,2.2" + urlProperty: "main.qml" objectProperty: MyTypeObject { intProperty: 8 } } diff --git a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml b/tests/auto/declarative/qmllanguage/data/attachedProperties.qml index 8343754..fec96cc 100644 --- a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml +++ b/tests/auto/declarative/qmllanguage/data/attachedProperties.qml @@ -1,5 +1,8 @@ import Test 1.0 +import Test 1.0 as Namespace import Qt 4.6 + Object { MyQmlObject.value: 10 + Namespace.MyQmlObject.value2: 13 } diff --git a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt index e56ad3a..3074823 100644 --- a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt @@ -1 +1 @@ -3:5:Invalid property access +3:5:Invalid grouped property access diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt new file mode 100644 index 0000000..68fe671 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt @@ -0,0 +1 @@ +5:17:Cannot assign to non-existant property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml new file mode 100644 index 0000000..e99c635 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import Qt 4.6 + +Object { + MyQmlObject.foo: 10 +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt new file mode 100644 index 0000000..7f630f4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt @@ -0,0 +1 @@ +5:15:Non-existant attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml new file mode 100644 index 0000000..8f987ce --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import Qt 4.6 + +Object { + Namespace.MadeUpClass.foo: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt new file mode 100644 index 0000000..fee5050 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt @@ -0,0 +1 @@ +5:15:Not an attached property name diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml new file mode 100644 index 0000000..18770fc --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml @@ -0,0 +1,7 @@ +import Test 1.0 as Namespace +import Qt 4.6 + +Object { + Namespace.madeUpClass.foo: 10 +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt new file mode 100644 index 0000000..9f06e07 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt @@ -0,0 +1 @@ +5:27:Cannot assign to non-existant property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml new file mode 100644 index 0000000..3c9ae5b --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import Qt 4.6 + +Object { + Namespace.MyQmlObject.foo: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt new file mode 100644 index 0000000..05161c4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt @@ -0,0 +1 @@ +5:5:Invalid attached object assignment diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml new file mode 100644 index 0000000..e9405a4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import Qt 4.6 + +Object { + MyQmlObject: 10 +} + + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt new file mode 100644 index 0000000..a208bcf --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt @@ -0,0 +1 @@ +5:15:Invalid attached object assignment diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml new file mode 100644 index 0000000..6fbf718 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 as Namespace +import Qt 4.6 + +Object { + Namespace.MyQmlObject: 10 +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt new file mode 100644 index 0000000..05161c4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt @@ -0,0 +1 @@ +5:5:Invalid attached object assignment diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml new file mode 100644 index 0000000..1827a16 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import Qt 4.6 + +Object { + MyQmlObject: Object {} +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt new file mode 100644 index 0000000..e232b23 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt @@ -0,0 +1 @@ +5:5:Non-existant attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml new file mode 100644 index 0000000..5c7f0ec --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import Qt 4.6 + +Object { + Test.MyQmlObject: Object {} +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt new file mode 100644 index 0000000..e232b23 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt @@ -0,0 +1 @@ +5:5:Non-existant attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml new file mode 100644 index 0000000..841cc08 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import Qt 4.6 + +Object { + MyTypeObject.foo: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt new file mode 100644 index 0000000..7f630f4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt @@ -0,0 +1 @@ +5:15:Non-existant attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml new file mode 100644 index 0000000..f1b4b96 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import Qt 4.6 + +Object { + Namespace.MyTypeObject.foo: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt new file mode 100644 index 0000000..e232b23 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt @@ -0,0 +1 @@ +5:5:Non-existant attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml new file mode 100644 index 0000000..99c4a5c --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import Qt 4.6 + +Object { + MadeUpClass.foo: 10 +} + diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt index 7c00ce4..810fd31 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt @@ -1 +1 @@ -5:5:Invalid property access +5:5:Invalid grouped property access diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt index 7c00ce4..810fd31 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt @@ -1 +1 @@ -5:5:Invalid property access +5:5:Invalid grouped property access diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt new file mode 100644 index 0000000..f6d6f29 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt @@ -0,0 +1 @@ +4:5:Invalid grouped property access diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml new file mode 100644 index 0000000..0bbfc4f --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + customType.x: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt new file mode 100644 index 0000000..19934fa --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existant property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml new file mode 100644 index 0000000..134fef9 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + foo.x: 10 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt new file mode 100644 index 0000000..2c8a970 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt @@ -0,0 +1 @@ +4:18:Property assignment expected diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml new file mode 100644 index 0000000..55cefe6 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x.foo: 100 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt new file mode 100644 index 0000000..8331725 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt @@ -0,0 +1 @@ +5:18:Single property assignment expected diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml new file mode 100644 index 0000000..9ec33ab --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x: 100 + rectProperty.x: 101 +} diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt new file mode 100644 index 0000000..4a7e383 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt @@ -0,0 +1 @@ +4:-1:Cannot set properties on nullGrouped as it is null diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml new file mode 100644 index 0000000..b77fb90 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + nullGrouped.script: print(1921) +} diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt new file mode 100644 index 0000000..dfaa218 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt @@ -0,0 +1 @@ +4:18:Cannot assign to non-existant property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml new file mode 100644 index 0000000..9a0fa6a --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.foo: 9 +} diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt new file mode 100644 index 0000000..db7d9c0 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt @@ -0,0 +1 @@ +4:18:Unexpected object assignment diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml b/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml new file mode 100644 index 0000000..9924773 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x: MyTypeObject {} +} + diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt b/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt new file mode 100644 index 0000000..44768e3 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt @@ -0,0 +1 @@ +3:18:Invalid property assignment: url expected diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.qml b/tests/auto/declarative/qmllanguage/data/wrongType.15.qml new file mode 100644 index 0000000..633a5ba --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/wrongType.15.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + urlProperty: 12 +} diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index e654faa..b251f87 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -80,14 +80,19 @@ class MyAttachedObject : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int value2 READ value2 WRITE setValue2) public: - MyAttachedObject(QObject *parent) : QObject(parent), m_value(0) {} + MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {} int value() const { return m_value; } void setValue(int v) { m_value = v; } + int value2() const { return m_value2; } + void setValue2(int v) { m_value2 = v; } + private: int m_value; + int m_value2; }; class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus @@ -201,9 +206,11 @@ class MyTypeObject : public QObject Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty); Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty); Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty); + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty); Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty); Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT); + Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT); public: MyTypeObject() @@ -413,6 +420,14 @@ public: vectorPropertyValue = v; } + QUrl urlPropertyValue; + QUrl urlProperty() const { + return urlPropertyValue; + } + void setUrlProperty(const QUrl &v) { + urlPropertyValue = v; + } + QmlScriptString scriptPropertyValue; QmlScriptString scriptProperty() const { return scriptPropertyValue; @@ -424,6 +439,8 @@ public: MyGroupedObject groupedValue; MyGroupedObject *grouped() { return &groupedValue; } + MyGroupedObject *nullGrouped() { return 0; } + void doAction() { emit action(); } signals: void action(); diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index c646583..c23bb2d 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -141,6 +141,7 @@ private: QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ QVERIFY(file.open(QIODevice::ReadOnly)); \ QByteArray data = file.readAll(); \ + file.close(); \ QList<QByteArray> expected = data.split('\n'); \ expected.removeAll(QByteArray("")); \ QList<QmlError> errors = component.errors(); \ @@ -154,7 +155,16 @@ private: } \ if (qgetenv("DEBUG") != "" && expected != actual) \ qWarning() << "Expected:" << expected << "Actual:" << actual; \ - QCOMPARE(expected, actual); \ + if (qgetenv("QMLLANGUAGE_UPDATEERRORS") != "" && expected != actual) {\ + QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ + QVERIFY(file.open(QIODevice::WriteOnly)); \ + for (int ii = 0; ii < actual.count(); ++ii) { \ + file.write(actual.at(ii)); file.write("\n"); \ + } \ + file.close(); \ + } else { \ + QCOMPARE(expected, actual); \ + } \ } inline QUrl TEST_FILE(const QString &filename) @@ -214,6 +224,7 @@ void tst_qmllanguage::errors_data() QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false; QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false; QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false; + QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false; QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false; QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false; @@ -240,8 +251,14 @@ void tst_qmllanguage::errors_data() QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false; QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false; QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false; QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true; QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false; QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false; @@ -278,13 +295,28 @@ void tst_qmllanguage::errors_data() QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false; QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false; + QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false; QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false; QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false; QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false; QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false; + QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; + QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; } + void tst_qmllanguage::errors() { QFETCH(QString, file); @@ -420,6 +452,7 @@ void tst_qmllanguage::assignBasicTypes() QCOMPARE(object->boolProperty(), true); QCOMPARE(object->variantProperty(), QVariant("Hello World!")); QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); QVERIFY(object->objectProperty() != 0); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty()); QVERIFY(child != 0); @@ -611,6 +644,7 @@ void tst_qmllanguage::attachedProperties() QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object); QVERIFY(attached != 0); QCOMPARE(attached->property("value"), QVariant(10)); + QCOMPARE(attached->property("value2"), QVariant(13)); } // Tests non-static object properties |