diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-03-08 14:41:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-14 01:12:35 +0100 |
commit | 665f860d9aaccd222c7fa8e309f087be35768022 (patch) | |
tree | 79bbef3db142abb4bd3e0a1e406b4446f0993ef8 /tests | |
parent | 89d6599de9092ac1f5e24981e642d87d57f593b5 (diff) |
Support module api objects in v4.
Change-Id: I72911a2c8e0a8613e53861da7b38312e51bf57da
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests')
4 files changed, 20 insertions, 9 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml index be647ca57f..e4a68d14ea 100644 --- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml @@ -6,6 +6,7 @@ QtObject { property int secondProperty: 2 property int readOnlyProperty: QtTest.qobjectTestProperty property int writableProperty: QtTest.qobjectTestWritableProperty + property int writableFinalProperty: QtTest.qobjectTestWritableFinalProperty onFirstPropertyChanged: { // In this case, we want to attempt to set the module API property. @@ -16,11 +17,14 @@ QtObject { } onSecondPropertyChanged: { - // In this case, we want to attempt to set the module API property. - // This should succeed, as the module API property is writable. + // In this case, we want to attempt to set the module API properties. + // This should succeed, as the module API properties are writable. if (secondProperty != QtTest.qobjectTestWritableProperty) { QtTest.qobjectTestWritableProperty = secondProperty; // should succeed. } + if (secondProperty != QtTest.qobjectTestWritableFinalProperty) { + QtTest.qobjectTestWritableFinalProperty = secondProperty; // should succeed. + } } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 78119cb776..64e91fbc95 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -140,6 +140,7 @@ static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine) testQObjectApi *o = new testQObjectApi(); o->setQObjectTestProperty(20); o->setQObjectTestWritableProperty(50); + o->setQObjectTestWritableFinalProperty(10); return o; } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 1d68e8ae13..65b84d66cb 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -978,10 +978,11 @@ class testQObjectApi : public QObject Q_ENUMS(MyEnum) Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged) Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged) + Q_PROPERTY (int qobjectTestWritableFinalProperty READ qobjectTestWritableFinalProperty WRITE setQObjectTestWritableFinalProperty NOTIFY qobjectTestWritableFinalPropertyChanged FINAL) public: testQObjectApi(QObject* parent = 0) - : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0) + : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_testWritableFinalProperty(0), m_methodCallCount(0) { } @@ -997,13 +998,18 @@ public: int qobjectTestWritableProperty() const { return m_testWritableProperty; } void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); } + int qobjectTestWritableFinalProperty() const { return m_testWritableFinalProperty; } + void setQObjectTestWritableFinalProperty(int tp) { m_testWritableFinalProperty = tp; emit qobjectTestWritableFinalPropertyChanged(); } + signals: void qobjectTestPropertyChanged(int testProperty); void qobjectTestWritablePropertyChanged(int testWritableProperty); + void qobjectTestWritableFinalPropertyChanged(); private: int m_testProperty; int m_testWritableProperty; + int m_testWritableFinalProperty; int m_methodCallCount; }; diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 5770dc4e03..0631df1759 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3089,13 +3089,13 @@ void tst_qqmlecmascript::moduleApi_data() QTest::newRow("qobject, writing + readonly constraints") << testFileUrl("moduleapi/qobjectModuleApiWriting.qml") << QString() - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) - << (QStringList() << "readOnlyProperty" << "writableProperty") - << (QVariantList() << 20 << 50) - << (QStringList() << "firstProperty" << "writableProperty") + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) + << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") + << (QVariantList() << 20 << 50 << 10) + << (QStringList() << "firstProperty" << "secondProperty") << (QVariantList() << 30 << 30) - << (QStringList() << "readOnlyProperty" << "writableProperty") - << (QVariantList() << 20 << 30); + << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") + << (QVariantList() << 20 << 30 << 30); QTest::newRow("script, writing + readonly constraints") << testFileUrl("moduleapi/scriptModuleApiWriting.qml") |