aboutsummaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/creationtime/tst_creationtime.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-04-12 10:58:08 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-04-12 12:17:35 +0000
commitc6e94e46077baf07793f95213bb53a8e56cf9b44 (patch)
tree5916d3f56997d466dd625d0fedea85a7439c377c /tests/benchmarks/creationtime/tst_creationtime.cpp
parentad343ad8ffc1016dd7d2d79603148ab2a07fe713 (diff)
Tests: move duplicated addTestRows() to QQuickVisualTestUtil
Change-Id: I723f1fe2e5df1ea4a09bd7e567079cdbc7124e6e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/benchmarks/creationtime/tst_creationtime.cpp')
-rw-r--r--tests/benchmarks/creationtime/tst_creationtime.cpp52
1 files changed, 10 insertions, 42 deletions
diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp
index 1d300b1c..41d7224d 100644
--- a/tests/benchmarks/creationtime/tst_creationtime.cpp
+++ b/tests/benchmarks/creationtime/tst_creationtime.cpp
@@ -37,6 +37,10 @@
#include <QtQml>
#include <QtTest>
+#include "../../auto/shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
class tst_CreationTime : public QObject
{
Q_OBJECT
@@ -71,42 +75,6 @@ void tst_CreationTime::init()
engine.clearComponentCache();
}
-static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList())
-{
- // 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/QtQuick/Controls.2/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.
-
- const QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files);
- for (const QFileInfo &entry : entries) {
- QString name = entry.baseName();
- if (!skiplist.contains(name)) {
- const auto importPathList = engine->importPathList();
- for (const QString &importPath : importPathList) {
- QString name = entry.dir().dirName() + "/" + entry.fileName();
- QString filePath = importPath + "/" + targetPath + "/" + entry.fileName();
- if (QFile::exists(filePath)) {
- QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
- break;
- } else {
- filePath = QQmlFile::urlToLocalFileOrQrc(filePath);
- if (!filePath.isEmpty() && QFile::exists(filePath)) {
- QTest::newRow(qPrintable(name)) << QUrl(filePath);
- break;
- }
- }
- }
- }
- }
-}
-
static void doBenchmark(QQmlEngine *engine, const QUrl &url)
{
QQmlComponent component(engine);
@@ -131,7 +99,7 @@ void tst_CreationTime::controls()
void tst_CreationTime::controls_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "ApplicationWindow");
+ addTestRowForEachControl(&engine, "controls", "QtQuick/Controls.2", QStringList() << "ApplicationWindow");
}
void tst_CreationTime::fusion()
@@ -143,7 +111,7 @@ void tst_CreationTime::fusion()
void tst_CreationTime::fusion_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2/Fusion", QStringList() << "ApplicationWindow" << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
+ addTestRowForEachControl(&engine, "controls/fusion", "QtQuick/Controls.2/Fusion", QStringList() << "ApplicationWindow" << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
}
void tst_CreationTime::imagine()
@@ -155,7 +123,7 @@ void tst_CreationTime::imagine()
void tst_CreationTime::imagine_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "controls/imagine", "QtQuick/Controls.2/Imagine", QStringList() << "ApplicationWindow");
+ addTestRowForEachControl(&engine, "controls/imagine", "QtQuick/Controls.2/Imagine", QStringList() << "ApplicationWindow");
}
void tst_CreationTime::material()
@@ -167,7 +135,7 @@ void tst_CreationTime::material()
void tst_CreationTime::material_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "ApplicationWindow" << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
+ addTestRowForEachControl(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "ApplicationWindow" << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
}
void tst_CreationTime::universal()
@@ -179,7 +147,7 @@ void tst_CreationTime::universal()
void tst_CreationTime::universal_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "ApplicationWindow" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
+ addTestRowForEachControl(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "ApplicationWindow" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
}
void tst_CreationTime::calendar()
@@ -191,7 +159,7 @@ void tst_CreationTime::calendar()
void tst_CreationTime::calendar_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "calendar", "Qt/labs/calendar");
+ addTestRowForEachControl(&engine, "calendar", "Qt/labs/calendar");
}
QTEST_MAIN(tst_CreationTime)