diff options
Diffstat (limited to 'tests/auto/sanity/tst_sanity.cpp')
-rw-r--r-- | tests/auto/sanity/tst_sanity.cpp | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index df440ebd..69553d93 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -43,6 +43,9 @@ #include <QtQml/private/qqmljsast_p.h> #include <QtQml/private/qqmljsastvisitor_p.h> #include <QtQml/private/qqmlmetatype_p.h> +#include "../../auto/shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; Q_GLOBAL_STATIC(QObjectList, qt_qobjects) @@ -329,42 +332,6 @@ void tst_Sanity::ids_data() QTest::newRow(qPrintable(it.key())) << it.key() << it.value(); } -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; - } - } - } - } - } -} - void tst_Sanity::attachedObjects() { QFETCH(QUrl, url); @@ -388,11 +355,11 @@ void tst_Sanity::attachedObjects() void tst_Sanity::attachedObjects_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "calendar", "Qt/labs/calendar"); - addTestRows(&engine, "controls", "QtQuick/Controls.2"); - addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); - addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); - addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRowForEachControl(&engine, "calendar", "Qt/labs/calendar"); + addTestRowForEachControl(&engine, "controls", "QtQuick/Controls.2"); + addTestRowForEachControl(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); + addTestRowForEachControl(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); + addTestRowForEachControl(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); } QTEST_MAIN(tst_Sanity) |