diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-12-09 05:12:17 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-12-09 05:12:17 (GMT) |
commit | 651b71feff5c703b2070e17b794e4744ec55f984 (patch) | |
tree | f70f8958f8cde5b7f34a33a888d94eb2d47e2514 /tests | |
parent | 611bd1247ff8254c567dc2c50573e84093dd8c5a (diff) | |
parent | 4bad9d6661f6b63c6ce9b9a29e9f5cf7aa032e37 (diff) | |
download | Qt-651b71feff5c703b2070e17b794e4744ec55f984.zip Qt-651b71feff5c703b2070e17b794e4744ec55f984.tar.gz Qt-651b71feff5c703b2070e17b794e4744ec55f984.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/anchors/data/centerin.qml | 12 | ||||
-rw-r--r-- | tests/auto/declarative/anchors/tst_anchors.cpp | 16 | ||||
-rw-r--r-- | tests/benchmarks/declarative/creation/data/item.qml | 34 | ||||
-rw-r--r-- | tests/benchmarks/declarative/creation/tst_creation.cpp | 103 |
4 files changed, 165 insertions, 0 deletions
diff --git a/tests/auto/declarative/anchors/data/centerin.qml b/tests/auto/declarative/anchors/data/centerin.qml new file mode 100644 index 0000000..09b97f6 --- /dev/null +++ b/tests/auto/declarative/anchors/data/centerin.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "centered" + width: 50; height: 50; color: "blue" + anchors.centerIn: parent; + anchors.verticalCenterOffset: 30 + anchors.horizontalCenterOffset: 10 + } +} diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 7378d95..bbe5ef1 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -71,6 +71,7 @@ private slots: void nullItem(); void nullItem_data(); void crash1(); + void centerIn(); }; /* @@ -378,6 +379,21 @@ void tst_anchors::crash1() delete view; } +void tst_anchors::centerIn() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl("file://" SRCDIR "/data/centerin.qml")); + + view->execute(); + qApp->processEvents(); + + QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->x(), 85.0); + QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->y(), 105.0); + + delete view; +} + QTEST_MAIN(tst_anchors) #include "tst_anchors.moc" diff --git a/tests/benchmarks/declarative/creation/data/item.qml b/tests/benchmarks/declarative/creation/data/item.qml new file mode 100644 index 0000000..74d2f27 --- /dev/null +++ b/tests/benchmarks/declarative/creation/data/item.qml @@ -0,0 +1,34 @@ +import Qt 4.6 + +Item { + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} +} diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 99411d4..61033e2 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -44,7 +44,9 @@ #include <QmlComponent> #include <QmlMetaType> #include <QDebug> +#include <QGraphicsScene> #include <QGraphicsItem> +#include <QmlGraphicsItem> #include <private/qobject_p.h> class tst_creation : public QObject @@ -65,6 +67,13 @@ private slots: void qgraphicsitem(); void qgraphicsitem_tree(); + void itemtree_notree_cpp(); + void itemtree_objtree_cpp(); + void itemtree_cpp(); + void itemtree_data_cpp(); + void itemtree_qml(); + void itemtree_scene_cpp(); + private: QmlEngine engine; }; @@ -241,6 +250,100 @@ void tst_creation::qgraphicsitem_tree() } } +struct QmlGraphics_DerivedObject : public QObject +{ + void setParent_noEvent(QObject *parent) { + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + setParent(parent); + d_ptr->sendChildEvents = sce; + } +}; + +inline void QmlGraphics_setParent_noEvent(QObject *object, QObject *parent) +{ + static_cast<QmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent); +} + +void tst_creation::itemtree_notree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + } + delete item; + } +} + +void tst_creation::itemtree_objtree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + } + delete item; + } +} + +void tst_creation::itemtree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + delete item; + } +} + +void tst_creation::itemtree_data_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + item->data()->append(child); + } + delete item; + } +} + +void tst_creation::itemtree_qml() +{ + QmlComponent component(&engine, TEST_FILE("item.qml")); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::itemtree_scene_cpp() +{ + QGraphicsScene scene; + QmlGraphicsItem *root = new QmlGraphicsItem; + scene.addItem(root); + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + item->setParentItem(root); + delete item; + } + delete root; +} + QTEST_MAIN(tst_creation) |