summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-13 00:30:00 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-13 00:30:00 (GMT)
commit2b64519c05edab3678fea2f56bba82077e5fedd1 (patch)
treea817294b6c1909a214bfc0b50315748c33c34baf /tests
parent1d11153b5564deb06d9f2936e0e43a0700a0e359 (diff)
parentb417ed17f15d88eeac21c46fa666af37b69d4531 (diff)
downloadQt-2b64519c05edab3678fea2f56bba82077e5fedd1.zip
Qt-2b64519c05edab3678fea2f56bba82077e5fedd1.tar.gz
Qt-2b64519c05edab3678fea2f56bba82077e5fedd1.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: tests/auto/declarative/qmlparser/tst_qmlparser.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlparser/FailingComponent.qml3
-rw-r--r--tests/auto/declarative/qmlparser/MyComponent.qml2
-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/assignTypeExtremes.txt4
-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/dynamicObject.1.txt6
-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/failingComponent.errors.txt2
-rw-r--r--tests/auto/declarative/qmlparser/failingComponent.txt4
-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/missingSignal.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/missingSignal.txt3
-rw-r--r--tests/auto/declarative/qmlparser/propertyValueSource.txt3
-rw-r--r--tests/auto/declarative/qmlparser/qmlparser.pro2
-rw-r--r--tests/auto/declarative/qmlparser/simpleBindings.txt17
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp206
29 files changed, 305 insertions, 9 deletions
diff --git a/tests/auto/declarative/qmlparser/FailingComponent.qml b/tests/auto/declarative/qmlparser/FailingComponent.qml
new file mode 100644
index 0000000..b604e0b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/FailingComponent.qml
@@ -0,0 +1,3 @@
+Object {
+ a: 10
+}
diff --git a/tests/auto/declarative/qmlparser/MyComponent.qml b/tests/auto/declarative/qmlparser/MyComponent.qml
index 320a036..8a9f57d 100644
--- a/tests/auto/declarative/qmlparser/MyComponent.qml
+++ b/tests/auto/declarative/qmlparser/MyComponent.qml
@@ -1,4 +1,4 @@
-Object {
+MyQmlObject {
property real x;
property real y;
}
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/assignTypeExtremes.txt b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt
new file mode 100644
index 0000000..dbd281a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt
@@ -0,0 +1,4 @@
+MyTypeObject {
+ uintProperty: 4000000000
+ intProperty: -2000000000
+}
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/dynamicObject.1.txt b/tests/auto/declarative/qmlparser/dynamicObject.1.txt
new file mode 100644
index 0000000..ac892c3
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/dynamicObject.1.txt
@@ -0,0 +1,6 @@
+SetProperties {
+ propa: a + 10
+ propb: Math.min(a, 10)
+ propc: MyPropertyValueSource {}
+ onPropA: a
+}
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/failingComponent.errors.txt b/tests/auto/declarative/qmlparser/failingComponent.errors.txt
new file mode 100644
index 0000000..0db1271
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/failingComponent.errors.txt
@@ -0,0 +1,2 @@
+2:-1:Unknown property "a"
+2:-1:Unable to create object of type "FailingComponent"
diff --git a/tests/auto/declarative/qmlparser/failingComponent.txt b/tests/auto/declarative/qmlparser/failingComponent.txt
new file mode 100644
index 0000000..8c43f84
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/failingComponent.txt
@@ -0,0 +1,4 @@
+MyContainer {
+ FailingComponent {}
+}
+
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/missingSignal.errors.txt b/tests/auto/declarative/qmlparser/missingSignal.errors.txt
new file mode 100644
index 0000000..8ae1bbe4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingSignal.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot assign a signal to property "onClicked"
diff --git a/tests/auto/declarative/qmlparser/missingSignal.txt b/tests/auto/declarative/qmlparser/missingSignal.txt
new file mode 100644
index 0000000..07d1bfa
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingSignal.txt
@@ -0,0 +1,3 @@
+Object {
+ onClicked: print("Hello world!")
+}
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/qmlparser.pro b/tests/auto/declarative/qmlparser/qmlparser.pro
index f50cf2b..42e157f 100644
--- a/tests/auto/declarative/qmlparser/qmlparser.pro
+++ b/tests/auto/declarative/qmlparser/qmlparser.pro
@@ -3,5 +3,5 @@ contains(QT_CONFIG,declarative): QT += declarative
SOURCES += tst_qmlparser.cpp
macx:CONFIG -= app_bundle
-QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
LIBS += -lgcov
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 7b6d7aa..b27d5d5 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
@@ -334,9 +386,19 @@ private slots:
void assignObjectToSignal();
void assignQmlComponent();
void assignBasicTypes();
+ void assignTypeExtremes();
void customParserTypes();
void rootAsQmlComponent();
void inlineQmlComponents();
+ void idProperty();
+ void assignSignal();
+ void dynamicProperties();
+ void dynamicSignalsAndSlots();
+ void simpleBindings();
+ void autoComponentCreation();
+ void propertyValueSource();
+ void attachedProperties();
+ void dynamicObjects();
// regression tests for crashes
void crash1();
@@ -385,7 +447,6 @@ void tst_qmlparser::errors_data()
QTest::newRow("nonExistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false;
QTest::newRow("nonExistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << true;
-
QTest::newRow("wrongType (string for int)") << "wrongType.1.txt" << "wrongType.1.errors.txt" << false;
QTest::newRow("wrongType (int for bool)") << "wrongType.2.txt" << "wrongType.2.errors.txt" << false;
QTest::newRow("wrongType (bad rect)") << "wrongType.3.txt" << "wrongType.3.errors.txt" << false;
@@ -402,19 +463,27 @@ void tst_qmlparser::errors_data()
QTest::newRow("wrongType (number string for int)") << "wrongType.13.txt" << "wrongType.13.errors.txt" << false;
QTest::newRow("wrongType (int for string)") << "wrongType.14.txt" << "wrongType.14.errors.txt" << false;
- 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("readOnly.1") << "readOnly.1.txt" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("readOnly.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;
+ QTest::newRow("failingComponent") << "failingComponent.txt" << "failingComponent.errors.txt" << true;
+ QTest::newRow("missingSignal") << "missingSignal.txt" << "missingSignal.errors.txt" << true;
}
void tst_qmlparser::errors()
@@ -525,6 +594,20 @@ 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);
+}
+
+// Test edge case type assignments
+void tst_qmlparser::assignTypeExtremes()
+{
+ QmlComponent component(&engine, TEST_FILE("assignTypeExtremes.txt"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->uintProperty(), 0xEE6B2800);
+ QCOMPARE(object->intProperty(), -0x77359400);
}
// Tests that custom parser tyeps can be instantiated
@@ -560,6 +643,115 @@ 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));
+}
+
+// Tests non-static object properties
+void tst_qmlparser::dynamicObjects()
+{
+ QmlComponent component(&engine, TEST_FILE("dynamicObject.1.txt"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
void tst_qmlparser::crash1()
{
QmlComponent component(&engine, "Component {}");