diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-15 16:11:58 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-20 19:15:27 +0000 |
commit | 561b9ce09d8ad3e5c8e9c622ab70034975cfe48f (patch) | |
tree | a9704348c80a054eef9ac04839b8bcc8a22f2bba /tests/benchmarks/objectcount | |
parent | 67398f037ebf9b36b88e870998eea5918832db2c (diff) |
Add material style to benchmarks
Change-Id: I2b8d09f8dcd1380af849f3263bf2ea7599681190
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/benchmarks/objectcount')
-rw-r--r-- | tests/benchmarks/objectcount/tst_objectcount.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index f2998708..59956588 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -69,6 +69,9 @@ private slots: void controls(); void controls_data(); + void material(); + void material_data(); + void universal(); void universal_data(); @@ -102,11 +105,32 @@ static void printItems(const QList<QQuickItem *> &items) } } -static void addTestRows(const QString &path) +static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QStringList &skiplist = QStringList()) { - QFileInfoList entries = QDir(path).entryInfoList(QStringList("*.qml"), QDir::Files); - foreach (const QFileInfo &entry, entries) - QTest::newRow(qPrintable(entry.baseName())) << QUrl::fromLocalFile(entry.absoluteFilePath()); + // We cannot use QQmlComponent to load QML files directly from the source tree. + // For styles that use internal QML types (eg. material/Ripple.qml), the source + // dir would be added as an "implicit" import path overriding the actual import + // path (qtbase/qml/Qt/labs/controls/material). => The QML engine fails to load + // the style C++ plugin from the implicit import path (the source dir). + // + // Therefore we only use the source tree for finding out the set of QML files that + // a particular style implements, and then we locate the respective QML files in + // the engine's import path. This way we can use QQmlComponent to load each QML file + // for benchmarking. + + QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); + foreach (const QFileInfo &entry, entries) { + QString name = entry.baseName(); + if (!skiplist.contains(name)) { + foreach (const QString &importPath, engine->importPathList()) { + QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName()); + if (QFile::exists(filePath)) { + QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath); + break; + } + } + } + } } static void doBenchmark(QQmlEngine *engine, const QUrl &url) @@ -137,7 +161,7 @@ void tst_ObjectCount::calendar() void tst_ObjectCount::calendar_data() { QTest::addColumn<QUrl>("url"); - addTestRows(QQC2_IMPORT_PATH "/calendar"); + addTestRows(&engine, "/calendar"); } void tst_ObjectCount::legacy() @@ -216,7 +240,19 @@ void tst_ObjectCount::controls() void tst_ObjectCount::controls_data() { QTest::addColumn<QUrl>("url"); - addTestRows(QQC2_IMPORT_PATH "/controls"); + addTestRows(&engine, "/controls"); +} + +void tst_ObjectCount::material() +{ + QFETCH(QUrl, url); + doBenchmark(&engine, url); +} + +void tst_ObjectCount::material_data() +{ + QTest::addColumn<QUrl>("url"); + addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle"); } void tst_ObjectCount::universal() @@ -228,7 +264,7 @@ void tst_ObjectCount::universal() void tst_ObjectCount::universal_data() { QTest::addColumn<QUrl>("url"); - addTestRows(QQC2_IMPORT_PATH "/controls/universal"); + addTestRows(&engine, "/controls/universal"); } QTEST_MAIN(tst_ObjectCount) |