From ecfe2b1cb35a8779bea5d23c0bb2c1b31939c01d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 23 Sep 2009 13:02:57 +1000 Subject: Merge qmlengine and qmlbindengine tests --- .../qmlbindengine/data/valueTypeFunctions.qml | 6 ++ tests/auto/declarative/qmlbindengine/testtypes.cpp | 1 + tests/auto/declarative/qmlbindengine/testtypes.h | 67 +++++++++++++++ .../qmlbindengine/tst_qmlbindengine.cpp | 11 +++ tests/auto/declarative/qmlengine/functions.qml | 6 -- tests/auto/declarative/qmlengine/qmlengine.pro | 5 -- tests/auto/declarative/qmlengine/tst_qmlengine.cpp | 98 ---------------------- 7 files changed, 85 insertions(+), 109 deletions(-) create mode 100644 tests/auto/declarative/qmlbindengine/data/valueTypeFunctions.qml delete mode 100644 tests/auto/declarative/qmlengine/functions.qml delete mode 100644 tests/auto/declarative/qmlengine/qmlengine.pro delete mode 100644 tests/auto/declarative/qmlengine/tst_qmlengine.cpp diff --git a/tests/auto/declarative/qmlbindengine/data/valueTypeFunctions.qml b/tests/auto/declarative/qmlbindengine/data/valueTypeFunctions.qml new file mode 100644 index 0000000..33b4a68 --- /dev/null +++ b/tests/auto/declarative/qmlbindengine/data/valueTypeFunctions.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyTypeObject { + rectProperty: Qt.rect(0,0,100,100) + rectFProperty: Qt.rect(0,0.5,100,99.5) +} diff --git a/tests/auto/declarative/qmlbindengine/testtypes.cpp b/tests/auto/declarative/qmlbindengine/testtypes.cpp index 3ff05d7..22e3071 100644 --- a/tests/auto/declarative/qmlbindengine/testtypes.cpp +++ b/tests/auto/declarative/qmlbindengine/testtypes.cpp @@ -37,5 +37,6 @@ QML_DEFINE_TYPE(Qt.test, 1, 0, 0, MyDeferredObject,MyDeferredObject); QML_DEFINE_TYPE(Qt.test, 1, 0, 0, MyQmlContainer,MyQmlContainer); QML_DEFINE_EXTENDED_TYPE(Qt.test, 1, 0, 0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); QML_DEFINE_EXTENDED_TYPE(Qt.test, 1, 0, 0, MyExtendedObject,MyExtendedObject,ExtensionObject); +QML_DEFINE_TYPE(Qt.test, 1, 0, 0, MyTypeObject, MyTypeObject); #include "testtypes.moc" diff --git a/tests/auto/declarative/qmlbindengine/testtypes.h b/tests/auto/declarative/qmlbindengine/testtypes.h index f27c0b0..f0302aa 100644 --- a/tests/auto/declarative/qmlbindengine/testtypes.h +++ b/tests/auto/declarative/qmlbindengine/testtypes.h @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include class MyQmlAttachedObject : public QObject { @@ -197,5 +200,69 @@ private: }; QML_DECLARE_TYPE(MyExtendedObject); +class MyTypeObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty); + Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty); + Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty); + Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty); + Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged); + Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty); + +public: + MyTypeObject() {} + + QPoint pointPropertyValue; + QPoint pointProperty() const { + return pointPropertyValue; + } + void setPointProperty(const QPoint &v) { + pointPropertyValue = v; + } + + QPointF pointFPropertyValue; + QPointF pointFProperty() const { + return pointFPropertyValue; + } + void setPointFProperty(const QPointF &v) { + pointFPropertyValue = v; + } + + QSize sizePropertyValue; + QSize sizeProperty() const { + return sizePropertyValue; + } + void setSizeProperty(const QSize &v) { + sizePropertyValue = v; + } + + QSizeF sizeFPropertyValue; + QSizeF sizeFProperty() const { + return sizeFPropertyValue; + } + void setSizeFProperty(const QSizeF &v) { + sizeFPropertyValue = v; + } + + QRect rectPropertyValue; + QRect rectProperty() const { + return rectPropertyValue; + } + void setRectProperty(const QRect &v) { + rectPropertyValue = v; + } + + QRectF rectFPropertyValue; + QRectF rectFProperty() const { + return rectFPropertyValue; + } + void setRectFProperty(const QRectF &v) { + rectFPropertyValue = v; + } + +}; +QML_DECLARE_TYPE(MyTypeObject); + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp index c7d6a87..612220a 100644 --- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp +++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp @@ -39,6 +39,7 @@ private slots: void deferredProperties(); void extensionObjects(); void enums(); + void valueTypeFunctions(); private: QmlEngine engine; @@ -385,6 +386,16 @@ void tst_qmlbindengine::enums() QCOMPARE(object->property("j").toInt(), 19); } +void tst_qmlbindengine::valueTypeFunctions() +{ + QmlComponent component(&engine, TEST_FILE("valueTypeFunctions.qml")); + MyTypeObject *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->rectProperty(), QRect(0,0,100,100)); + QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5)); +} + + QTEST_MAIN(tst_qmlbindengine) #include "tst_qmlbindengine.moc" diff --git a/tests/auto/declarative/qmlengine/functions.qml b/tests/auto/declarative/qmlengine/functions.qml deleted file mode 100644 index 28e8ed4..0000000 --- a/tests/auto/declarative/qmlengine/functions.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Test 1.0 - -MyTypeObject { - rectProperty: Qt.rect(0,0,100,100) - rectFProperty: Qt.rect(0,0.5,100,99.5) -} diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro deleted file mode 100644 index 4ac81e9..0000000 --- a/tests/auto/declarative/qmlengine/qmlengine.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_qmlengine.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp deleted file mode 100644 index 8c050cb..0000000 --- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -class tst_qmlengine : public QObject -{ - Q_OBJECT -public: - tst_qmlengine() {} - -private slots: - void valueTypeFunctions(); - -private: - QmlEngine engine; -}; - -class MyTypeObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty); - Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty); - Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty); - Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty); - Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged); - Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty); - -public: - MyTypeObject() {} - - QPoint pointPropertyValue; - QPoint pointProperty() const { - return pointPropertyValue; - } - void setPointProperty(const QPoint &v) { - pointPropertyValue = v; - } - - QPointF pointFPropertyValue; - QPointF pointFProperty() const { - return pointFPropertyValue; - } - void setPointFProperty(const QPointF &v) { - pointFPropertyValue = v; - } - - QSize sizePropertyValue; - QSize sizeProperty() const { - return sizePropertyValue; - } - void setSizeProperty(const QSize &v) { - sizePropertyValue = v; - } - - QSizeF sizeFPropertyValue; - QSizeF sizeFProperty() const { - return sizeFPropertyValue; - } - void setSizeFProperty(const QSizeF &v) { - sizeFPropertyValue = v; - } - - QRect rectPropertyValue; - QRect rectProperty() const { - return rectPropertyValue; - } - void setRectProperty(const QRect &v) { - rectPropertyValue = v; - } - - QRectF rectFPropertyValue; - QRectF rectFProperty() const { - return rectFPropertyValue; - } - void setRectFProperty(const QRectF &v) { - rectFPropertyValue = v; - } - -}; -QML_DECLARE_TYPE(MyTypeObject); -QML_DEFINE_TYPE(Test, 1, 0, 0, MyTypeObject, MyTypeObject); - -void tst_qmlengine::valueTypeFunctions() -{ - QmlComponent component(&engine, SRCDIR "/functions.qml"); - MyTypeObject *obj = qobject_cast(component.create()); - QCOMPARE(obj->rectProperty(), QRect(0,0,100,100)); - QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5)); -} - -QTEST_MAIN(tst_qmlengine) - -#include "tst_qmlengine.moc" -- cgit v0.12