diff options
-rw-r--r-- | tests/auto/sanity/sanity.pro | 2 | ||||
-rw-r--r-- | tests/auto/sanity/tst_sanity.cpp | 18 | ||||
-rw-r--r-- | tests/benchmarks/creationtime/creationtime.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/creationtime/tst_creationtime.cpp | 22 |
4 files changed, 16 insertions, 28 deletions
diff --git a/tests/auto/sanity/sanity.pro b/tests/auto/sanity/sanity.pro index 436dc7dd..15f2679a 100644 --- a/tests/auto/sanity/sanity.pro +++ b/tests/auto/sanity/sanity.pro @@ -5,5 +5,7 @@ QT += qml testlib core-private qml-private CONFIG += testcase osx:CONFIG -= app_bundle +DEFINES += QQC2_IMPORT_PATH=\\\"$$absolute_path(../../../src/imports)\\\" + SOURCES += \ $$PWD/tst_sanity.cpp diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index bf6a3d11..ac5bcfba 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -135,20 +135,14 @@ private: QStringList m_errors; }; -static QMap<QString, QString> listQmlFiles(const QDir &dir) -{ - QMap<QString, QString> files; - foreach (const QFileInfo &entry, dir.entryInfoList(QStringList() << "*.qml" << "*.js", QDir::Files)) - files.insert(entry.baseName(), entry.absoluteFilePath()); - return files; -} - void tst_Sanity::initTestCase() { - QQmlEngine engine; - foreach (const QString &path, engine.importPathList()) { - files.unite(listQmlFiles(QDir(path + "/Qt/labs/calendar"))); - files.unite(listQmlFiles(QDir(path + "/Qt/labs/controls"))); + QDirIterator it(QQC2_IMPORT_PATH, QStringList() << "*.qml" << "*.js", QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + QFileInfo info = it.fileInfo(); + if (info.dir().dirName() != QStringLiteral("snippets") && info.dir().dirName() != QStringLiteral("designer")) + files.insert(info.baseName(), info.filePath()); } } diff --git a/tests/benchmarks/creationtime/creationtime.pro b/tests/benchmarks/creationtime/creationtime.pro index 050e29aa..4383a759 100644 --- a/tests/benchmarks/creationtime/creationtime.pro +++ b/tests/benchmarks/creationtime/creationtime.pro @@ -5,5 +5,7 @@ QT += qml testlib CONFIG += testcase osx:CONFIG -= app_bundle +DEFINES += QQC2_IMPORT_PATH=\\\"$$absolute_path(../../../src/imports)\\\" + SOURCES += \ tst_creationtime.cpp diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp index 32ba17ff..20fcfbbe 100644 --- a/tests/benchmarks/creationtime/tst_creationtime.cpp +++ b/tests/benchmarks/creationtime/tst_creationtime.cpp @@ -59,27 +59,17 @@ void tst_CreationTime::init() engine.clearComponentCache(); } -static QStringList listControls(const QDir &dir) +static QStringList listControls(const QString &path) { QStringList controls; - foreach (const QFileInfo &entry, dir.entryInfoList(QStringList("*.qml"), QDir::Files)) + foreach (const QFileInfo &entry, QDir(path).entryInfoList(QStringList("*.qml"), QDir::Files)) controls += entry.baseName(); return controls; } -static void addTestRows(const QStringList &importPaths, const QString &importPath) +static void addTestRows(const QString &path) { - QStringList controls; - foreach (const QString &path, importPaths) { - QDir dir(path); - if (dir.cd(importPath)) { - foreach (const QString &control, listControls(dir)) { - if (!controls.contains(control)) - controls += control; - } - } - } - + QStringList controls = listControls(path); foreach (const QString &control, controls) QTest::newRow(qPrintable(control)) << control.toUtf8(); } @@ -108,7 +98,7 @@ void tst_CreationTime::controls() void tst_CreationTime::controls_data() { QTest::addColumn<QByteArray>("control"); - addTestRows(engine.importPathList(), "Qt/labs/controls"); + addTestRows(QQC2_IMPORT_PATH "/controls"); } void tst_CreationTime::calendar() @@ -122,7 +112,7 @@ void tst_CreationTime::calendar() void tst_CreationTime::calendar_data() { QTest::addColumn<QByteArray>("control"); - addTestRows(engine.importPathList(), "Qt/labs/calendar"); + addTestRows(QQC2_IMPORT_PATH "/calendar"); } QTEST_MAIN(tst_CreationTime) |