diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-08 04:45:46 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-08 04:45:46 (GMT) |
commit | 7abc7b839223eaf05006fe35dceec690fee5ce3d (patch) | |
tree | 55a26720a4add25528f3ef1bae99348b6bd54f14 | |
parent | 6db0dd65bdb9d999f5f5bbb54808517d3d212315 (diff) | |
download | Qt-7abc7b839223eaf05006fe35dceec690fee5ce3d.zip Qt-7abc7b839223eaf05006fe35dceec690fee5ce3d.tar.gz Qt-7abc7b839223eaf05006fe35dceec690fee5ce3d.tar.bz2 |
QML signal handler benchmark
5 files changed, 97 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/script/data/signal_args.qml b/tests/benchmarks/declarative/script/data/signal_args.qml new file mode 100644 index 0000000..f02acc0 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_args.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +TestObject { + onMySignalWithArgs: { var a = n; return a; } +} + diff --git a/tests/benchmarks/declarative/script/data/signal_qml.qml b/tests/benchmarks/declarative/script/data/signal_qml.qml new file mode 100644 index 0000000..ba53603 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_qml.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +TestObject { + onMySignal: { var a = 1; return a; } +} + diff --git a/tests/benchmarks/declarative/script/data/signal_unconnected.qml b/tests/benchmarks/declarative/script/data/signal_unconnected.qml new file mode 100644 index 0000000..53d06d5 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_unconnected.qml @@ -0,0 +1,4 @@ +import Qt.test 1.0 + +TestObject { +} diff --git a/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml b/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml new file mode 100644 index 0000000..3ff9071 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +TestObject { + onMySignalWithArgs: { var a = 1; return a; } +} + diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 2aa7a9f..9da795d 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -41,6 +41,7 @@ #include <qtest.h> #include <QmlEngine> +#include <QmlComponent> #include <private/qmlengine_p.h> #include <private/qmlobjectscriptclass_p.h> #include <QScriptEngine> @@ -71,9 +72,18 @@ private slots: void function_args_qobject(); void function_args_qmlobject(); + void signal_unconnected(); + void signal_qml(); + void signal_args(); + void signal_unusedArgs(); private: }; +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + class TestObject : public QObject { Q_OBJECT @@ -84,6 +94,13 @@ public: int x(); + void emitMySignal() { emit mySignal(); } + void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); } + +signals: + void mySignal(); + void mySignalWithArgs(int n); + public slots: int method() { return x(); @@ -96,6 +113,8 @@ public slots: private: int m_x; }; +QML_DECLARE_TYPE(TestObject); +QML_DEFINE_TYPE(Qt.test, 1, 0, TestObject, TestObject); TestObject::TestObject(QObject *parent) : QObject(parent), m_x(0) @@ -446,6 +465,62 @@ void tst_script::function_args_qmlobject() } } +void tst_script::signal_unconnected() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("signal_unconnected.qml")); + TestObject *object = qobject_cast<TestObject *>(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::signal_qml() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("signal_qml.qml")); + TestObject *object = qobject_cast<TestObject *>(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::signal_args() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("signal_args.qml")); + TestObject *object = qobject_cast<TestObject *>(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + +void tst_script::signal_unusedArgs() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("signal_unusedArgs.qml")); + TestObject *object = qobject_cast<TestObject *>(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + QTEST_MAIN(tst_script) #include "tst_script.moc" |