diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-20 01:25:02 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-20 01:25:02 (GMT) |
commit | c734d6eecbdb594346b3008bd5a843605d761af8 (patch) | |
tree | ff2341a64a38824b97816bd222c2c0cd18e13585 /tests | |
parent | 1b80a6bc28cb49b9f6e1a2132d929819924aa604 (diff) | |
download | Qt-c734d6eecbdb594346b3008bd5a843605d761af8.zip Qt-c734d6eecbdb594346b3008bd5a843605d761af8.tar.gz Qt-c734d6eecbdb594346b3008bd5a843605d761af8.tar.bz2 |
Handle overrides correctly in extension objects
QTBUG-7817
Diffstat (limited to 'tests')
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 0d07055..154ff4d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -72,6 +72,14 @@ private: int m_value; }; +class DefaultPropertyExtensionObject : public QObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultProperty", "firstProperty") +public: + DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {} +}; + void registerTypes() { qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); @@ -81,6 +89,8 @@ void registerTypes() qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject"); qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject"); qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment"); + qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject"); + qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 79d3226..1381d57 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -659,6 +659,31 @@ public: void setTest12(unsigned int v) { _test12 = v; } }; +class DefaultPropertyExtendedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty) + Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty) +public: + DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {} + + QObject *firstProperty() const { return m_firstProperty; } + QObject *secondProperty() const { return m_secondProperty; } + void setFirstProperty(QObject *property) { m_firstProperty = property; } + void setSecondProperty(QObject *property) { m_secondProperty = property; } +private: + QObject* m_firstProperty; + QObject* m_secondProperty; +}; + +class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultProperty", "secondProperty") +public: + OverrideDefaultPropertyObject() {} +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 33629b8..a2ecf74 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -90,6 +90,7 @@ private slots: void objectPropertiesTriggerReeval(); void deferredProperties(); void extensionObjects(); + void overrideExtensionProperties(); void attachedProperties(); void enums(); void valueTypeFunctions(); @@ -565,6 +566,16 @@ void tst_qdeclarativeecmascript::extensionObjects() } +void tst_qdeclarativeecmascript::overrideExtensionProperties() +{ + QDeclarativeComponent component(&engine, TEST_FILE("extensionObjectsPropertyOverride.qml")); + OverrideDefaultPropertyObject *object = + qobject_cast<OverrideDefaultPropertyObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->secondProperty() != 0); + QVERIFY(object->firstProperty() == 0); +} + void tst_qdeclarativeecmascript::attachedProperties() { QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml")); |