diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-22 01:30:54 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-22 01:30:54 (GMT) |
commit | fa85d539decf7bdcb16fa8f52858b13479cea659 (patch) | |
tree | ef877362de972e52ff62ebd66e0ed395bd1c6a25 /tests/auto | |
parent | 7717f6d250d1158ceb8b1c25ec78c8719d8252a0 (diff) | |
parent | a3b3ba02f0eba2f435f552a9aa64fc9fceade972 (diff) | |
download | Qt-fa85d539decf7bdcb16fa8f52858b13479cea659.zip Qt-fa85d539decf7bdcb16fa8f52858b13479cea659.tar.gz Qt-fa85d539decf7bdcb16fa8f52858b13479cea659.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto')
4 files changed, 57 insertions, 1 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/scriptString.qml b/tests/auto/declarative/qmllanguage/data/scriptString.qml new file mode 100644 index 0000000..51e6e48 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/scriptString.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: foo + bar + grouped.script: print(1921) +} diff --git a/tests/auto/declarative/qmllanguage/testtypes.cpp b/tests/auto/declarative/qmllanguage/testtypes.cpp index c11e195..58d99f1 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.cpp +++ b/tests/auto/declarative/qmllanguage/testtypes.cpp @@ -7,4 +7,4 @@ QML_DEFINE_TYPE(Test,1,0,0,MyContainer,MyContainer); QML_DEFINE_TYPE(Test,1,0,0,MyPropertyValueSource,MyPropertyValueSource); QML_DEFINE_TYPE(Test,1,0,0,MyDotPropertyObject,MyDotPropertyObject); QML_DEFINE_TYPE(Test,1,0,0,MyNamespacedType,MyNamespace::MyNamespacedType); - +QML_DEFINE_NOCREATE_TYPE(MyGroupedObject); diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index b1da9fb..355ff8b 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -10,6 +10,7 @@ #include <QtDeclarative/qmlcomponent.h> #include <QtDeclarative/qmlparserstatus.h> #include <QtDeclarative/qmlpropertyvaluesource.h> +#include <QtDeclarative/qmlscriptstring.h> class MyInterface { @@ -112,6 +113,21 @@ private: }; QML_DECLARE_TYPE(MyQmlObject); +class MyGroupedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QmlScriptString script READ script WRITE setScript); +public: + QmlScriptString script() const { return m_script; } + void setScript(const QmlScriptString &s) { m_script = s; } + +private: + QmlScriptString m_script; +}; + +QML_DECLARE_TYPE(MyGroupedObject); + + class MyTypeObject : public QObject { Q_OBJECT @@ -142,6 +158,9 @@ class MyTypeObject : public QObject Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty); Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty); + Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty); + Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT); + public: MyTypeObject() : objectPropertyValue(0), componentPropertyValue(0) {} @@ -334,6 +353,17 @@ public: variantPropertyValue = v; } + QmlScriptString scriptPropertyValue; + QmlScriptString scriptProperty() const { + return scriptPropertyValue; + } + void setScriptProperty(const QmlScriptString &v) { + scriptPropertyValue = v; + } + + MyGroupedObject groupedValue; + MyGroupedObject *grouped() { return &groupedValue; } + void doAction() { emit action(); } signals: void action(); @@ -365,6 +395,7 @@ private: QML_DECLARE_TYPE(MyContainer); + class MyPropertyValueSource : public QObject, public QmlPropertyValueSource { Q_OBJECT diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 8d4ae65..97038e6 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -63,6 +63,7 @@ private slots: void i18n(); void i18n_data(); void onCompleted(); + void scriptString(); void importsBuiltin_data(); void importsBuiltin(); @@ -739,6 +740,24 @@ void tst_qmllanguage::onCompleted() QVERIFY(object != 0); } +// Check that assignments to QmlScriptString properties work +void tst_qmllanguage::scriptString() +{ + QmlComponent component(&engine, TEST_FILE("scriptString.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); + QCOMPARE(object->scriptProperty().scopeObject(), object); + QCOMPARE(object->scriptProperty().context(), qmlContext(object)); + + QVERIFY(object->grouped() != 0); + QCOMPARE(object->grouped()->script().script(), QString("print(1921)")); + QCOMPARE(object->grouped()->script().scopeObject(), object); + QCOMPARE(object->grouped()->script().context(), qmlContext(object)); +} + // Check that first child of qml is of given type. Empty type insists on error. void tst_qmllanguage::testType(const QString& qml, const QString& type) { |