diff options
Diffstat (limited to 'tests/benchmarks/qml')
-rw-r--r-- | tests/benchmarks/qml/animation/tst_animation.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/qml/compilation/tst_compilation.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/qml/creation/tst_creation.cpp | 89 |
3 files changed, 94 insertions, 3 deletions
diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp index 4f693f9fa8..59f5a57f5c 100644 --- a/tests/benchmarks/qml/animation/tst_animation.cpp +++ b/tests/benchmarks/qml/animation/tst_animation.cpp @@ -107,8 +107,8 @@ void tst_animation::animationelements_data() { QTest::addColumn<QString>("type"); - QSet<QString> types = QQmlMetaType::qmlTypeNames().toSet(); - foreach (const QString &type, types) { + const QSet<QString> types = QQmlMetaType::qmlTypeNames().toSet(); + for (const QString &type : types) { if (type.contains(QLatin1String("Animation"))) QTest::newRow(type.toLatin1()) << type; } diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 3f2cb5b94f..690e193b53 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -75,7 +75,9 @@ void tst_compilation::boomblock() QQmlComponent c(&engine); c.setData(data, QUrl()); } - +#ifdef QT_NO_OPENGL + QSKIP("boomblock imports Particles which requires OpenGL Support"); +#endif QBENCHMARK { QQmlComponent c(&engine); c.setData(data, QUrl()); diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index c835e4799c..9fc67ada71 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -62,6 +62,12 @@ private slots: void itemtests_qml_data(); void itemtests_qml(); + void bindings_cpp(); + void bindings_cpp2(); + void bindings_qml(); + + void bindings_parent_qml(); + void anchors_creation(); void anchors_heightChange(); @@ -329,6 +335,89 @@ void tst_creation::itemtests_qml() QBENCHMARK { delete component.create(); } } +void tst_creation::bindings_cpp() +{ + QQuickItem item; + QMetaProperty widthProp = item.metaObject()->property(item.metaObject()->indexOfProperty("width")); + QMetaProperty heightProp = item.metaObject()->property(item.metaObject()->indexOfProperty("height")); + connect(&item, &QQuickItem::heightChanged, [&item, &widthProp, &heightProp](){ + QVariant height = heightProp.read(&item); + widthProp.write(&item, height); + }); + + int height = 0; + QBENCHMARK { + item.setHeight(++height); + } +} + +void tst_creation::bindings_cpp2() +{ + QQuickItem item; + int widthProp = item.metaObject()->indexOfProperty("width"); + int heightProp = item.metaObject()->indexOfProperty("height"); + connect(&item, &QQuickItem::heightChanged, [&item, widthProp, heightProp](){ + + qreal height = -1; + void *args[] = { &height, 0 }; + QMetaObject::metacall(&item, QMetaObject::ReadProperty, heightProp, args); + + int flags = 0; + int status = -1; + void *argv[] = { &height, 0, &status, &flags }; + QMetaObject::metacall(&item, QMetaObject::WriteProperty, widthProp, argv); + }); + + int height = 0; + QBENCHMARK { + item.setHeight(++height); + } +} + +void tst_creation::bindings_qml() +{ + QByteArray data = "import QtQuick 2.0\nItem { width: height }"; + + QQmlComponent component(&engine); + component.setData(data, QUrl()); + if (!component.isReady()) { + qWarning() << "Unable to create component: " << component.errorString(); + return; + } + + QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QVERIFY(obj != nullptr); + + int height = 0; + QBENCHMARK { + obj->setHeight(++height); + } + + delete obj; +} + +void tst_creation::bindings_parent_qml() +{ + QByteArray data = "import QtQuick 2.0\nItem { Item { width: parent.height }}"; + + QQmlComponent component(&engine); + component.setData(data, QUrl()); + if (!component.isReady()) { + qWarning() << "Unable to create component: " << component.errorString(); + return; + } + + QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QVERIFY(obj != nullptr); + + int height = 0; + QBENCHMARK { + obj->setHeight(++height); + } + + delete obj; +} + void tst_creation::anchors_creation() { QQmlComponent component(&engine); |