summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qml.h2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp16
-rw-r--r--src/declarative/qml/qmlcomponent.cpp21
-rw-r--r--src/declarative/qml/qmlparser.cpp1
-rw-r--r--src/declarative/qml/qmlparser_p.h1
-rw-r--r--tests/auto/declarative/qmlparser/assignBasicTypes.txt2
-rw-r--r--tests/auto/declarative/qmlparser/assignSignal.txt3
-rw-r--r--tests/auto/declarative/qmlparser/attachedProperties.txt3
-rw-r--r--tests/auto/declarative/qmlparser/autoComponentCreation.txt3
-rw-r--r--tests/auto/declarative/qmlparser/dynamicProperties.txt11
-rw-r--r--tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt6
-rw-r--r--tests/auto/declarative/qmlparser/idProperty.txt7
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.3.txt4
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.4.txt5
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.1.txt3
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.2.errors.txt2
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/listAssignment.3.txt5
-rw-r--r--tests/auto/declarative/qmlparser/propertyValueSource.txt3
-rw-r--r--tests/auto/declarative/qmlparser/simpleBindings.txt17
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp182
25 files changed, 272 insertions, 32 deletions
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index 1c662a7..b435e94 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -106,7 +106,7 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj)
if (idx == -1 || !obj)
return 0;
- return qmlAttachedPropertiesObjectById(obj, idx);
+ return qmlAttachedPropertiesObjectById(idx, obj);
}
QML_DECLARE_TYPE(QObject);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index a703ec3..ed520c1 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -863,9 +863,9 @@ bool QmlCompiler::compileIdProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
if (prop->value)
- COMPILE_EXCEPTION("The 'id' property cannot be fetched");
+ COMPILE_EXCEPTION2(prop,"The id property cannot be fetched");
if (prop->values.count() > 1)
- COMPILE_EXCEPTION("The 'id' property cannot be multiset");
+ COMPILE_EXCEPTION2(prop, "The object id may only be set once");
if (prop->values.count() == 1) {
if (prop->values.at(0)->object)
@@ -1018,6 +1018,7 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop,
if (assignedBinding)
COMPILE_EXCEPTION("Can only assign one binding to lists");
+ assignedBinding = true;
compileBinding(v->value.asScript(), prop, ctxt,
obj->metaObject(), v->location.start.line);
v->type = Value::PropertyBinding;
@@ -1305,17 +1306,6 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj)
p.defaultValue->isDefault = false;
COMPILE_CHECK(compileProperty(p.defaultValue, obj, 0));
}
-
- if (!p.onValueChanged.isEmpty()) {
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignSignal;
- assign.line = obj->location.start.line;
- assign.assignSignal.signal =
- output->indexForByteArray(p.name + "Changed()");
- assign.assignSignal.value =
- output->indexForString(p.onValueChanged);
- output->bytecode << assign;
- }
}
return true;
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index da8f26d..24b5dd2 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -482,18 +482,19 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
ctxt->deactivate();
+ QmlEnginePrivate *ep = d->engine->d_func();
+ if (ep->rootComponent == this) {
+ ep->rootComponent = 0;
+
+ d->bindValues = ep->bindValues;
+ d->parserStatus = ep->parserStatus;
+ ep->bindValues.clear();
+ ep->parserStatus.clear();
+ d->completePending = true;
+ }
+
if (rv) {
QFx_setParent_noEvent(ctxt, rv);
- QmlEnginePrivate *ep = d->engine->d_func();
- if (ep->rootComponent == this) {
- ep->rootComponent = 0;
-
- d->bindValues = ep->bindValues;
- d->parserStatus = ep->parserStatus;
- ep->bindValues.clear();
- ep->parserStatus.clear();
- d->completePending = true;
- }
} else {
delete ctxt;
}
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index bafdb02..10eec61 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -109,7 +109,6 @@ QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o)
: isDefaultProperty(o.isDefaultProperty),
type(o.type),
name(o.name),
- onValueChanged(o.onValueChanged),
defaultValue(o.defaultValue)
{
}
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index f25a76b..a6894fb 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -133,7 +133,6 @@ namespace QmlParser
bool isDefaultProperty;
Type type;
QByteArray name;
- QString onValueChanged;
QmlParser::Property *defaultValue;
};
struct DynamicSignal {
diff --git a/tests/auto/declarative/qmlparser/assignBasicTypes.txt b/tests/auto/declarative/qmlparser/assignBasicTypes.txt
index 49de929..71e400d 100644
--- a/tests/auto/declarative/qmlparser/assignBasicTypes.txt
+++ b/tests/auto/declarative/qmlparser/assignBasicTypes.txt
@@ -20,4 +20,6 @@ MyTypeObject {
rectFProperty: "1000.1,-10.9,400x90.99"
boolProperty: true
variantProperty: "Hello World!"
+
+ objectProperty: MyTypeObject { intProperty: 8 }
}
diff --git a/tests/auto/declarative/qmlparser/assignSignal.txt b/tests/auto/declarative/qmlparser/assignSignal.txt
new file mode 100644
index 0000000..6c0fd54
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/assignSignal.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ onBasicSignal: basicSlot()
+}
diff --git a/tests/auto/declarative/qmlparser/attachedProperties.txt b/tests/auto/declarative/qmlparser/attachedProperties.txt
new file mode 100644
index 0000000..bfe5733
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/attachedProperties.txt
@@ -0,0 +1,3 @@
+Object {
+ MyQmlObject.value: 10
+}
diff --git a/tests/auto/declarative/qmlparser/autoComponentCreation.txt b/tests/auto/declarative/qmlparser/autoComponentCreation.txt
new file mode 100644
index 0000000..e0dbbae
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/autoComponentCreation.txt
@@ -0,0 +1,3 @@
+MyTypeObject {
+ componentProperty : MyTypeObject { realProperty: 9 }
+}
diff --git a/tests/auto/declarative/qmlparser/dynamicProperties.txt b/tests/auto/declarative/qmlparser/dynamicProperties.txt
new file mode 100644
index 0000000..14c85a7
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/dynamicProperties.txt
@@ -0,0 +1,11 @@
+Object {
+ default property int intProperty : 10
+ property bool boolProperty: false
+ property double doubleProperty: -10.1
+ property real realProperty: -19.9
+ property string stringProperty: "Hello World!"
+ property color colorProperty: "red"
+ property date dateProperty: "1945-09-02"
+ property var varProperty: "Hello World!"
+ property variant variantProperty: 12
+}
diff --git a/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt
new file mode 100644
index 0000000..7cf65ee
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt
@@ -0,0 +1,6 @@
+Object {
+ signal signal1
+ function slot1() {}
+ signal signal2
+ function slot2() {}
+}
diff --git a/tests/auto/declarative/qmlparser/idProperty.txt b/tests/auto/declarative/qmlparser/idProperty.txt
new file mode 100644
index 0000000..9c7d6fb
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/idProperty.txt
@@ -0,0 +1,7 @@
+MyContainer {
+ property var object : MyObjectId
+
+ MyTypeObject {
+ id: MyObjectId
+ }
+}
diff --git a/tests/auto/declarative/qmlparser/invalidID.3.errors.txt b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt
new file mode 100644
index 0000000..05937f0
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt
@@ -0,0 +1 @@
+2:5:The id property cannot be fetched
diff --git a/tests/auto/declarative/qmlparser/invalidID.3.txt b/tests/auto/declarative/qmlparser/invalidID.3.txt
new file mode 100644
index 0000000..c686914
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.3.txt
@@ -0,0 +1,4 @@
+MyQmlObject {
+ id.other: 10
+}
+
diff --git a/tests/auto/declarative/qmlparser/invalidID.4.errors.txt b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt
new file mode 100644
index 0000000..50c8960
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt
@@ -0,0 +1 @@
+3:5:The object id may only be set once
diff --git a/tests/auto/declarative/qmlparser/invalidID.4.txt b/tests/auto/declarative/qmlparser/invalidID.4.txt
new file mode 100644
index 0000000..734ccc4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.4.txt
@@ -0,0 +1,5 @@
+MyQmlObject {
+ id: Hello
+ id: World
+}
+
diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt
new file mode 100644
index 0000000..44a275b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt
@@ -0,0 +1 @@
+1:1:Cannot assign primitives to lists
diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.txt b/tests/auto/declarative/qmlparser/listAssignment.1.txt
new file mode 100644
index 0000000..e2376f2
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.1.txt
@@ -0,0 +1,3 @@
+MyContainer {
+ qmllistInterfaces: 1
+}
diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt
new file mode 100644
index 0000000..572d662
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt
@@ -0,0 +1,2 @@
+1:1:Cannot assign primitives to lists
+
diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.txt b/tests/auto/declarative/qmlparser/listAssignment.2.txt
new file mode 100644
index 0000000..375e4b4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.2.txt
@@ -0,0 +1,3 @@
+MyContainer {
+ children: 2
+}
diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt
new file mode 100644
index 0000000..ab6fec8
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt
@@ -0,0 +1 @@
+1:1:Can only assign one binding to lists
diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.txt b/tests/auto/declarative/qmlparser/listAssignment.3.txt
new file mode 100644
index 0000000..b776bee
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listAssignment.3.txt
@@ -0,0 +1,5 @@
+MyContainer {
+ children: childBinding.expression
+ children: childBinding2.expression
+}
+
diff --git a/tests/auto/declarative/qmlparser/propertyValueSource.txt b/tests/auto/declarative/qmlparser/propertyValueSource.txt
new file mode 100644
index 0000000..780f527
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/propertyValueSource.txt
@@ -0,0 +1,3 @@
+MyTypeObject {
+ intProperty : MyPropertyValueSource {}
+}
diff --git a/tests/auto/declarative/qmlparser/simpleBindings.txt b/tests/auto/declarative/qmlparser/simpleBindings.txt
new file mode 100644
index 0000000..78f2503
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/simpleBindings.txt
@@ -0,0 +1,17 @@
+MyTypeObject {
+ id: Me
+ property int v1: 10
+ property int v2: 11
+
+ property int value1
+ property int value2
+ property int value3
+ property int value4
+
+ value1: v1
+ value2: Me.v1
+ value3: v1 + v2
+ value4: Math.min(v1, v2)
+
+ objectProperty: Me
+}
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index a3b94db..81d044b 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -1,6 +1,7 @@
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmlpropertyvaluesource.h>
#include <QtCore/qfile.h>
#include <QtCore/qdebug.h>
@@ -15,7 +16,7 @@ Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
QML_DECLARE_INTERFACE(MyInterface);
QML_DEFINE_INTERFACE(MyInterface);
-class MyQmlObject : public QObject, public MyInterface
+class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus
{
Q_OBJECT
Q_PROPERTY(int value READ value WRITE setValue)
@@ -24,7 +25,7 @@ class MyQmlObject : public QObject, public MyInterface
Q_PROPERTY(QRect rect READ rect WRITE setRect)
Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
Q_PROPERTY(MyInterface *interface READ interface WRITE setInterface)
- Q_INTERFACES(MyInterface)
+ Q_INTERFACES(MyInterface QmlParserStatus)
public:
MyQmlObject() : m_value(-1), m_interface(0) {}
@@ -45,6 +46,11 @@ public:
MyInterface *interface() const { return m_interface; }
void setInterface(MyInterface *iface) { m_interface = iface; }
+ static QObject *qmlAttachedProperties(QObject *other) {
+ MyQmlObject *rv = new MyQmlObject;
+ rv->setParent(other);
+ return rv;
+ }
Q_CLASSINFO("DefaultMethod", "basicSlot()");
public slots:
@@ -68,6 +74,9 @@ class MyTypeObject : public QObject
Q_ENUMS(MyEnum)
Q_FLAGS(MyFlags)
+ Q_PROPERTY(QString id READ id WRITE setId);
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
+ Q_PROPERTY(QmlComponent *componentProperty READ componentProperty WRITE setComponentProperty);
Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
@@ -89,6 +98,33 @@ class MyTypeObject : public QObject
Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QmlComponent *componentPropertyValue;
+ QmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
Q_DECLARE_FLAGS(MyFlags, MyFlag)
MyFlags flagPropertyValue;
@@ -273,6 +309,22 @@ private:
QML_DECLARE_TYPE(MyContainer);
QML_DEFINE_TYPE(MyContainer,MyContainer);
+class MyPropertyValueSource : public QmlPropertyValueSource
+{
+ Q_OBJECT
+public:
+ MyPropertyValueSource()
+ : QmlPropertyValueSource(0) {}
+
+ QmlMetaProperty prop;
+ virtual void setTarget(const QmlMetaProperty &p)
+ {
+ prop = p;
+ }
+};
+QML_DECLARE_TYPE(MyPropertyValueSource);
+QML_DEFINE_TYPE(MyPropertyValueSource,MyPropertyValueSource);
+
class MyDotPropertyObject : public QObject
{
Q_OBJECT
@@ -337,6 +389,14 @@ private slots:
void customParserTypes();
void rootAsQmlComponent();
void inlineQmlComponents();
+ void idProperty();
+ void assignSignal();
+ void dynamicProperties();
+ void dynamicSignalsAndSlots();
+ void simpleBindings();
+ void autoComponentCreation();
+ void propertyValueSource();
+ void attachedProperties();
// regression tests for crashes
void crash1();
@@ -400,17 +460,22 @@ void tst_qmlparser::errors_data()
QTest::newRow("wrongType (string for point)") << "wrongType.11.txt" << "wrongType.11.errors.txt" << false;
QTest::newRow("wrongType (color for size)") << "wrongType.12.txt" << "wrongType.12.errors.txt" << false;
+ QTest::newRow("readOnly.1") << "readOnly.1.txt" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("readOnly.2") << "readOnly.2.txt" << "readOnly.2.errors.txt" << true;
- QTest::newRow("nonExistantProperty.1") << "readOnly.1.txt" << "readOnly.1.errors.txt" << false;
- QTest::newRow("nonExistantProperty.2") << "readOnly.2.txt" << "readOnly.2.errors.txt" << true;
+ QTest::newRow("listAssignment.1") << "listAssignment.1.txt" << "listAssignment.1.errors.txt" << false;
+ QTest::newRow("listAssignment.2") << "listAssignment.2.txt" << "listAssignment.2.errors.txt" << false;
+ QTest::newRow("listAssignment.3") << "listAssignment.3.txt" << "listAssignment.3.errors.txt" << false;
+ QTest::newRow("invalidID.1") << "invalidID.txt" << "invalidID.errors.txt" << false;
+ QTest::newRow("invalidID.2") << "invalidID.2.txt" << "invalidID.2.errors.txt" << false;
+ QTest::newRow("invalidID.3") << "invalidID.3.txt" << "invalidID.3.errors.txt" << false;
+ QTest::newRow("invalidID.4") << "invalidID.4.txt" << "invalidID.4.errors.txt" << false;
QTest::newRow("unsupportedProperty") << "unsupportedProperty.txt" << "unsupportedProperty.errors.txt" << true;
QTest::newRow("nullDotProperty") << "nullDotProperty.txt" << "nullDotProperty.errors.txt" << true;
QTest::newRow("fakeDotProperty") << "fakeDotProperty.txt" << "fakeDotProperty.errors.txt" << true;
QTest::newRow("duplicateIDs") << "duplicateIDs.txt" << "duplicateIDs.errors.txt" << false;
- QTest::newRow("invalidID.1") << "invalidID.txt" << "invalidID.errors.txt" << false;
- QTest::newRow("invalidID.2") << "invalidID.2.txt" << "invalidID.2.errors.txt" << false;
QTest::newRow("unregisteredObject") << "unregisteredObject.txt" << "unregisteredObject.errors.txt" << false;
QTest::newRow("empty") << "empty.txt" << "empty.errors.txt" << false;
QTest::newRow("missingObject") << "missingObject.txt" << "missingObject.errors.txt" << false;
@@ -524,6 +589,10 @@ void tst_qmlparser::assignBasicTypes()
QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
QCOMPARE(object->boolProperty(), true);
QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QVERIFY(object->objectProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
+ QVERIFY(child != 0);
+ QCOMPARE(child->intProperty(), 8);
}
// Tests that custom parser tyeps can be instantiated
@@ -559,6 +628,107 @@ void tst_qmlparser::inlineQmlComponents()
QCOMPARE(compObject->value(), 11);
}
+// Tests that types that have an id property have it set
+void tst_qmlparser::idProperty()
+{
+ QmlComponent component(&engine, TEST_FILE("idProperty.txt"));
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->children()->count(), 1);
+ MyTypeObject *child =
+ qobject_cast<MyTypeObject *>(object->children()->at(0));
+ QVERIFY(child != 0);
+ QCOMPARE(child->id(), QString("MyObjectId"));
+ QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
+}
+
+// Tests that signals can be assigned to
+void tst_qmlparser::assignSignal()
+{
+ QmlComponent component(&engine, TEST_FILE("assignSignal.txt"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+}
+
+// Tests the creation and assignment of dynamic properties
+void tst_qmlparser::dynamicProperties()
+{
+ QmlComponent component(&engine, TEST_FILE("dynamicProperties.txt"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intProperty"), QVariant(10));
+ QCOMPARE(object->property("boolProperty"), QVariant(false));
+ QCOMPARE(object->property("doubleProperty"), QVariant((float)-10.1));
+ QCOMPARE(object->property("realProperty"), QVariant((float)-19.9));
+ QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
+ QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
+ QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("variantProperty"), QVariant(12));
+}
+
+// Tests the declaration of dynamic signals and slots
+void tst_qmlparser::dynamicSignalsAndSlots()
+{
+ QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.txt"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
+}
+
+void tst_qmlparser::simpleBindings()
+{
+ QmlComponent component(&engine, TEST_FILE("simpleBindings.txt"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value1"), QVariant(10));
+ QCOMPARE(object->property("value2"), QVariant(10));
+ QCOMPARE(object->property("value3"), QVariant(21));
+ QCOMPARE(object->property("value4"), QVariant(10));
+ QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
+}
+
+void tst_qmlparser::autoComponentCreation()
+{
+ QmlComponent component(&engine, TEST_FILE("autoComponentCreation.txt"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->componentProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
+ QVERIFY(child != 0);
+ QCOMPARE(child->realProperty(), qreal(9));
+}
+
+void tst_qmlparser::propertyValueSource()
+{
+ QmlComponent component(&engine, TEST_FILE("propertyValueSource.txt"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QList<QmlPropertyValueSource *> valueSources =
+ object->findChildren<QmlPropertyValueSource *>();
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), object);
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+}
+
+void tst_qmlparser::attachedProperties()
+{
+ QmlComponent component(&engine, TEST_FILE("attachedProperties.txt"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
+ QVERIFY(attached != 0);
+ QCOMPARE(attached->property("value"), QVariant(10));
+}
+
void tst_qmlparser::crash1()
{
QmlComponent component(&engine, "Component {}");