aboutsummaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/objectcount/tst_objectcount.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/objectcount/tst_objectcount.cpp')
-rw-r--r--tests/benchmarks/objectcount/tst_objectcount.cpp50
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)