diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-27 01:55:42 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-27 01:56:46 (GMT) |
commit | 04a2350db6ef1fffa3c81c747b4474e92d1af70d (patch) | |
tree | 588ad47e0bce498d5055e0d88c1c4de5fe7e93ca /tests/auto/declarative/qdeclarativeecmascript | |
parent | ddc7fcee9c3602bcbb79a6b8538315a633fa3db4 (diff) | |
download | Qt-04a2350db6ef1fffa3c81c747b4474e92d1af70d.zip Qt-04a2350db6ef1fffa3c81c747b4474e92d1af70d.tar.gz Qt-04a2350db6ef1fffa3c81c747b4474e92d1af70d.tar.bz2 |
Correctly inherit extension properties
Correct a typo that breaks extension properties in some cases.
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp | 23 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 12 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 154ff4d..8a4605a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ #include "testtypes.h" +#include <QWidget> +#include <QPlainTextEdit> class BaseExtensionObject : public QObject { @@ -80,6 +82,24 @@ public: DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {} }; +class QWidgetDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + +signals: + void widthChanged(); + +public: + QWidgetDeclarativeUI(QObject *other) : QObject(other) { } + +public: + int width() const { return 0; } + void setWidth(int) { } +}; + + void registerTypes() { qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); @@ -91,6 +111,9 @@ void registerTypes() qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment"); qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject"); qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject"); + + qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget"); + qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index d0a2f7c..491a736 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -134,6 +134,7 @@ private slots: void numberAssignment(); void bug1(); + void bug2(); void dynamicCreationCrash(); void regExpBug(); void nullObjectBinding(); @@ -1251,6 +1252,17 @@ void tst_qdeclarativeecmascript::bug1() delete object; } +void tst_qdeclarativeecmascript::bug2() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl()); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + // Don't crash in createObject when the component has errors. void tst_qdeclarativeecmascript::dynamicCreationCrash() { |