diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-12 07:10:32 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-12 07:10:32 (GMT) |
commit | 5c8e5eefbb01feb12a941d774c2760fdc617a9c3 (patch) | |
tree | db901cbe144cf016ff43e2a57397470d65fe2be4 /tests/auto/declarative/qmllanguage | |
parent | 6a4f57c100e8c27bbe8ad3975bd99383063dafa1 (diff) | |
parent | 7421702dd3202c21f3871171792476f0d2d50abe (diff) | |
download | Qt-5c8e5eefbb01feb12a941d774c2760fdc617a9c3.zip Qt-5c8e5eefbb01feb12a941d774c2760fdc617a9c3.tar.gz Qt-5c8e5eefbb01feb12a941d774c2760fdc617a9c3.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto/declarative/qmllanguage')
9 files changed, 108 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml b/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml new file mode 100644 index 0000000..f8726ef --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Component { + Object {} +} diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType.qml b/tests/auto/declarative/qmllanguage/data/CompositeType.qml new file mode 100644 index 0000000..8c5094b --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/CompositeType.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +Object { +} diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType2.qml b/tests/auto/declarative/qmllanguage/data/CompositeType2.qml new file mode 100644 index 0000000..86210e9 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/CompositeType2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { +} + diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType3.qml b/tests/auto/declarative/qmllanguage/data/CompositeType3.qml new file mode 100644 index 0000000..bb5469a --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/CompositeType3.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Object { + property int a +} diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType4.qml b/tests/auto/declarative/qmllanguage/data/CompositeType4.qml new file mode 100644 index 0000000..a6a8168 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/CompositeType4.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyQmlObject { + property int a +} + diff --git a/tests/auto/declarative/qmllanguage/data/alias.5.qml b/tests/auto/declarative/qmllanguage/data/alias.5.qml new file mode 100644 index 0000000..39bfd9b --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/alias.5.qml @@ -0,0 +1,13 @@ +import Qt 4.6 +import Test 1.0 + +Object { + property alias otherAlias: otherObject + + property var other + other: MyQmlObject { + id: otherObject + value: 10 + } +} + diff --git a/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml b/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml new file mode 100644 index 0000000..ec2867d --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml @@ -0,0 +1,18 @@ +import Qt 4.6 +import Test 1.0 + +Object { + property Object myProperty + property Object myProperty2 + property Object myProperty3 + property Object myProperty4 + property MyQmlObject myProperty5 + property MyQmlObject myProperty6 + + myProperty: CompositeType {} + myProperty2: CompositeType2 {} + myProperty3: CompositeType3 {} + myProperty4: CompositeType4 {} + myProperty5: CompositeType2 {} + myProperty6: CompositeType4 {} +} diff --git a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml b/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml new file mode 100644 index 0000000..3a1b191 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +Object { + property var test + + test: ComponentComposite {} +} + diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 135a207..a991144 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -39,6 +39,7 @@ private slots: void assignQmlComponent(); void assignBasicTypes(); void assignTypeExtremes(); + void assignCompositeToType(); void customParserTypes(); void rootAsQmlComponent(); void inlineQmlComponents(); @@ -56,6 +57,7 @@ private slots: void valueTypes(); void cppnamespace(); void aliasProperties(); + void componentCompositeType(); void importsBuiltin_data(); void importsBuiltin(); @@ -323,6 +325,15 @@ void tst_qmllanguage::assignTypeExtremes() QCOMPARE(object->intProperty(), -0x77359400); } +// Test that a composite type can assign to a property of its base type +void tst_qmllanguage::assignCompositeToType() +{ + QmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); +} + // Tests that custom parser types can be instantiated void tst_qmllanguage::customParserTypes() { @@ -620,7 +631,40 @@ void tst_qmllanguage::aliasProperties() QVERIFY(object != 0); QCOMPARE(object->property("enumAlias").toInt(), 1); + + delete object; } + + // Id aliases + { + QmlComponent component(&engine, TEST_FILE("alias.5.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVariant v = object->property("otherAlias"); + QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); + MyQmlObject *o = qvariant_cast<MyQmlObject*>(v); + QCOMPARE(o->value(), 10); + + delete o; + + v = object->property("otherAlias"); + QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); + o = qvariant_cast<MyQmlObject*>(v); + QVERIFY(o == 0); + + delete object; + } +} + +// Test that the root element in a composite type can be a Component +void tst_qmllanguage::componentCompositeType() +{ + QmlComponent component(&engine, TEST_FILE("componentCompositeType.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); } class TestType : public QObject { |