diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-02-24 02:42:00 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-02-24 02:42:00 (GMT) |
commit | 7c76abb0dc4204043bec9b6fa315f9753a7986ae (patch) | |
tree | cee303672cfd138790645e731f2d69472564d4b7 /tests/benchmarks/declarative/qdeclarativecomponent | |
parent | 4066e60e859853cfe3240245ba05271e79839506 (diff) | |
download | Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.zip Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.tar.gz Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.tar.bz2 |
Change class prefix to from QmlXXX to QDeclarativeXXX, QmlGraphicsXXX to QDeclarativeXXX.
Diffstat (limited to 'tests/benchmarks/declarative/qdeclarativecomponent')
18 files changed, 360 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml new file mode 100644 index 0000000..9c3f7f8 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml @@ -0,0 +1,3 @@ +import Qt.test 4.6 + +MyQmlObject {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml new file mode 100644 index 0000000..e6cc4cf --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml @@ -0,0 +1,6 @@ +import Qt.test 4.6 + +MyQmlObject { + result: value +} + diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml new file mode 100644 index 0000000..0d2d49b --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml @@ -0,0 +1,3 @@ +import Qt 4.6 + +QtObject {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml new file mode 100644 index 0000000..69114af --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +QtObject { + id: Blah +} + diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml new file mode 100644 index 0000000..723e62a --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml @@ -0,0 +1,55 @@ +import Qt 4.6 + +Item { id:block + property bool dying: false + property bool spawned: false + property int type: 0 + property int targetX: 0 + property int targetY: 0 + + x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } + y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } + + Image { id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + opacity: Behavior { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + + Particles { id: particles + width:1; height:1; anchors.centerIn: parent; + emissionRate: 0; + lifeSpan: 700; lifeSpanDeviation: 600; + angle: 0; angleDeviation: 360; + velocity: 100; velocityDeviation:30; + source: { + if(type == 0){ + "pics/redStar.png"; + } else if (type == 1) { + "pics/blueStar.png"; + } else { + "pics/greenStar.png"; + } + } + } + + states: [ + State{ name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png Binary files differnew file mode 100644 index 0000000..ff9588f --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png Binary files differnew file mode 100644 index 0000000..bf342e0 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png Binary files differnew file mode 100644 index 0000000..cd06854 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png Binary files differnew file mode 100644 index 0000000..5ac14a5 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png Binary files differnew file mode 100644 index 0000000..0a4dffe --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png Binary files differnew file mode 100644 index 0000000..b099f60 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png Binary files differnew file mode 100644 index 0000000..c56124a --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml new file mode 100644 index 0000000..27c5646 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml @@ -0,0 +1,15 @@ +import Qt 4.6 + +QtObject { + property int a + property bool b + property double c + property real d + property string e + property url f + property color g + property date h + property var i + property variant j +} + diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml new file mode 100644 index 0000000..d08f35b --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + property int a +} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro new file mode 100644 index 0000000..12fa9f4 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -0,0 +1,19 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qdeclarativecomponent +QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp +HEADERS += testtypes.h + +symbian* { + data.sources = data/* + data.path = data + samegame.sources = data/samegame/* + samegame.path = data/samegame + samegame_pics.sources = data/samegame/pics/* + samegame_pics.path = data/samegame/pics + DEPLOYMENT += data samegame samegame_pics +} + diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp new file mode 100644 index 0000000..acdc395 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +void registerTypes() +{ + QML_REGISTER_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject); +} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h new file mode 100644 index 0000000..4b103ce --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include <QtCore/qobject.h> +#include <QtDeclarative/qdeclarative.h> + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult); + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); + Q_PROPERTY(QDeclarativeList<QObject *> *data READ data); + Q_CLASSINFO("DefaultProperty", "data"); +public: + MyQmlObject() : m_result(0), m_value(0), m_object(0) {} + + int result() const { return m_result; } + void setResult(int r) { m_result = r; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QDeclarativeList<QObject *> *data() { return &m_data; } + + MyQmlObject *object() const { return m_object; } + void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } + +signals: + void valueChanged(); + void objectChanged(); + +private: + QDeclarativeConcreteList<QObject *> m_data; + int m_result; + int m_value; + MyQmlObject *m_object; +}; +QML_DECLARE_TYPE(MyQmlObject); + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp new file mode 100644 index 0000000..7065303 --- /dev/null +++ b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> +#include <QFile> +#include <QDebug> +#include "testtypes.h" + +//TESTED_FILES= + + +class tst_qmlcomponent : public QObject +{ + Q_OBJECT + +public: + tst_qmlcomponent(); + virtual ~tst_qmlcomponent(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void creation_data(); + void creation(); + +private: + QDeclarativeEngine engine; +}; + +tst_qmlcomponent::tst_qmlcomponent() +{ +} + +tst_qmlcomponent::~tst_qmlcomponent() +{ +} + +void tst_qmlcomponent::initTestCase() +{ + registerTypes(); +} + +void tst_qmlcomponent::cleanupTestCase() +{ +} + +void tst_qmlcomponent::creation_data() +{ + QTest::addColumn<QString>("file"); + + QTest::newRow("Object") << "data/object.qml"; + QTest::newRow("Object - Id") << "data/object_id.qml"; + QTest::newRow("MyQmlObject") << "data/myqmlobject.qml"; + QTest::newRow("MyQmlObject: basic binding") << "data/myqmlobject_binding.qml"; + QTest::newRow("Synthesized properties") << "data/synthesized_properties.qml"; + QTest::newRow("Synthesized properties.2") << "data/synthesized_properties.2.qml"; + QTest::newRow("SameGame - BoomBlock") << "data/samegame/BoomBlock.qml"; +} + +void tst_qmlcomponent::creation() +{ + QFETCH(QString, file); + + QDeclarativeComponent c(&engine, file); + QVERIFY(c.isReady()); + + QObject *obj = c.create(); + delete obj; + + QBENCHMARK { + QObject *obj = c.create(); + delete obj; + } +} + +QTEST_MAIN(tst_qmlcomponent) +#include "tst_qdeclarativecomponent.moc" |