summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative/creation/tst_creation.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-18 14:08:26 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-18 14:08:26 (GMT)
commit8d2b0c0c41ca862ea943277f67cce71a32fb4c37 (patch)
tree8e7c9bbc4913c3deedae7828abf69b2747e41445 /tests/benchmarks/declarative/creation/tst_creation.cpp
parentf43c00902e9ff6a314836c6955769e941ea33277 (diff)
parenta762bb1ead644e00290b2f4c023e96f5ef765d43 (diff)
downloadQt-8d2b0c0c41ca862ea943277f67cce71a32fb4c37.zip
Qt-8d2b0c0c41ca862ea943277f67cce71a32fb4c37.tar.gz
Qt-8d2b0c0c41ca862ea943277f67cce71a32fb4c37.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (147 commits) Add missing semicolons. moc was confused and positionViewAtIndex not invokable. Use the correct base URL in resolveUri Remove timing sensitivity. Optimize id checking. Fix examples after 47fb07c9fdf47584ae55f3412102bbeef5576b04. Don't use QScriptValueIterator to iterate over arrays. Skip test, to be fixed. Only release the binding once we're finished with its memory Make it harder to accidentally delete a binding Adjust test now that redundant contexts are not create due Block modifications to internal QDeclarativeContexts Don't destroy cookie jar until while someone may be using it. Fix tests after 47fb07c9fdf47584ae55f3412102bbeef5576b04. Another fix to find Improve implicit "." import Fix auto test Fix type lookup with url Fix default values on Textinput Add an implicit import "." to types loaded from a local url Fix crash ...
Diffstat (limited to 'tests/benchmarks/declarative/creation/tst_creation.cpp')
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp252
1 files changed, 115 insertions, 137 deletions
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
index 5b0004f..7aec32a 100644
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ b/tests/benchmarks/declarative/creation/tst_creation.cpp
@@ -47,6 +47,7 @@
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QDeclarativeItem>
+#include <QDeclarativeContext>
#include <private/qobject_p.h>
#ifdef Q_OS_SYMBIAN
@@ -59,7 +60,7 @@ class tst_creation : public QObject
{
Q_OBJECT
public:
- tst_creation() {}
+ tst_creation();
private slots:
void qobject_cpp();
@@ -67,13 +68,11 @@ private slots:
void qobject_qmltype();
void qobject_alloc();
- void objects_qmltype_data();
- void objects_qmltype();
+ void qobject_10flat_qml();
+ void qobject_10flat_cpp();
- void qgraphicsitem();
- void qgraphicsobject();
- void qgraphicsitem14();
- void qgraphicsitem_tree14();
+ void qobject_10tree_qml();
+ void qobject_10tree_cpp();
void itemtree_notree_cpp();
void itemtree_objtree_cpp();
@@ -82,10 +81,36 @@ private slots:
void itemtree_qml();
void itemtree_scene_cpp();
+ void elements_data();
+ void elements();
+
private:
QDeclarativeEngine engine;
};
+class TestType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources);
+Q_CLASSINFO("DefaultProperty", "resources");
+public:
+ TestType(QObject *parent = 0)
+ : QObject(parent) {}
+
+ QDeclarativeListProperty<QObject> resources() {
+ return QDeclarativeListProperty<QObject>(this, 0, resources_append);
+ }
+
+ static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) {
+ o->setParent(p->object);
+ }
+};
+
+tst_creation::tst_creation()
+{
+ qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType");
+}
+
inline QUrl TEST_FILE(const QString &filename)
{
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
@@ -101,7 +126,8 @@ void tst_creation::qobject_cpp()
void tst_creation::qobject_qml()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qobject.qml"));
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nQtObject {}", QUrl());
QObject *obj = component.create();
delete obj;
@@ -111,60 +137,73 @@ void tst_creation::qobject_qml()
}
}
-void tst_creation::qobject_qmltype()
+void tst_creation::qobject_10flat_qml()
{
- QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6);
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl());
+ QObject *obj = component.create();
+ delete obj;
QBENCHMARK {
- QObject *obj = t->create();
+ QObject *obj = component.create();
delete obj;
}
}
-struct QObjectFakeData {
- char data[sizeof(QObjectPrivate)];
-};
-
-struct QObjectFake {
- QObjectFake();
- virtual ~QObjectFake();
-private:
- QObjectFakeData *d;
-};
-
-QObjectFake::QObjectFake()
+void tst_creation::qobject_10flat_cpp()
{
- d = new QObjectFakeData;
+ QBENCHMARK {
+ QObject *item = new TestType;
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ delete item;
+ }
}
-QObjectFake::~QObjectFake()
+void tst_creation::qobject_10tree_qml()
{
- delete d;
-}
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
-void tst_creation::qobject_alloc()
-{
QBENCHMARK {
- QObjectFake *obj = new QObjectFake;
+ QObject *obj = component.create();
delete obj;
}
}
-void tst_creation::objects_qmltype_data()
+void tst_creation::qobject_10tree_cpp()
{
- QTest::addColumn<QByteArray>("type");
-
- QList<QByteArray> types = QDeclarativeMetaType::qmlTypeNames();
- foreach (QByteArray type, types)
- QTest::newRow(type.constData()) << type;
+ QBENCHMARK {
+ QObject *item = new TestType;
+ QObject *root = item;
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ delete root;
+ }
}
-void tst_creation::objects_qmltype()
+void tst_creation::qobject_qmltype()
{
- QFETCH(QByteArray, type);
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6);
- if (!t || !t->isCreatable())
- QSKIP("Non-creatable type", SkipSingle);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6);
QBENCHMARK {
QObject *obj = t->create();
@@ -172,114 +211,32 @@ void tst_creation::objects_qmltype()
}
}
-class QGraphicsItemDummy : public QGraphicsItem
-{
-public:
- virtual QRectF boundingRect() const { return QRectF(); }
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
+struct QObjectFakeData {
+ char data[sizeof(QObjectPrivate)];
};
-class QGraphicsObjectDummy : public QGraphicsObject
-{
-public:
- virtual QRectF boundingRect() const { return QRectF(); }
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
+struct QObjectFake {
+ QObjectFake();
+ virtual ~QObjectFake();
+private:
+ QObjectFakeData *d;
};
-void tst_creation::qgraphicsitem()
-{
- QBENCHMARK {
- QGraphicsItemDummy *i = new QGraphicsItemDummy();
- delete i;
- }
-}
-
-void tst_creation::qgraphicsobject()
+QObjectFake::QObjectFake()
{
- QBENCHMARK {
- QGraphicsObjectDummy *i = new QGraphicsObjectDummy();
- delete i;
- }
+ d = new QObjectFakeData;
}
-void tst_creation::qgraphicsitem14()
+QObjectFake::~QObjectFake()
{
- QBENCHMARK {
- QGraphicsItemDummy *i1 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i2 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i3 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i4 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i5 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i6 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i7 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i8 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i9 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i10 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i11 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i12 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i13 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i14 = new QGraphicsItemDummy();
-
- delete i1;
- delete i2;
- delete i3;
- delete i4;
- delete i5;
- delete i6;
- delete i7;
- delete i8;
- delete i9;
- delete i10;
- delete i11;
- delete i12;
- delete i13;
- delete i14;
- }
+ delete d;
}
-void tst_creation::qgraphicsitem_tree14()
+void tst_creation::qobject_alloc()
{
QBENCHMARK {
- // i1
- // +-------------------------+
- // i2 i3
- // +-----------+ +-----+-----+
- // i4 i5 i6 i7
- // +----+ +--+ +--+--+ +----+
- // i8 i9 i10 i11 i12 i13 i14
-
- QGraphicsItemDummy *i1 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i2 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i3 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i4 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i5 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i6 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i7 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i8 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i9 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i10 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i11 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i12 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i13 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i14 = new QGraphicsItemDummy();
-
- i14->setParentItem(i7);
- i13->setParentItem(i7);
- i12->setParentItem(i6);
- i11->setParentItem(i6);
- i10->setParentItem(i5);
- i9->setParentItem(i4);
- i8->setParentItem(i4);
-
- i7->setParentItem(i3);
- i6->setParentItem(i3);
- i5->setParentItem(i2);
- i4->setParentItem(i2);
-
- i3->setParentItem(i1);
- i2->setParentItem(i1);
-
- delete i1;
+ QObjectFake *obj = new QObjectFake;
+ delete obj;
}
}
@@ -378,6 +335,27 @@ void tst_creation::itemtree_scene_cpp()
delete root;
}
+void tst_creation::elements_data()
+{
+ QTest::addColumn<QByteArray>("type");
+
+ QList<QByteArray> types = QDeclarativeMetaType::qmlTypeNames();
+ foreach (QByteArray type, types)
+ QTest::newRow(type.constData()) << type;
+}
+
+void tst_creation::elements()
+{
+ QFETCH(QByteArray, type);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6);
+ if (!t || !t->isCreatable())
+ QSKIP("Non-creatable type", SkipSingle);
+
+ QBENCHMARK {
+ QObject *obj = t->create();
+ delete obj;
+ }
+}
QTEST_MAIN(tst_creation)