diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-10 20:57:48 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-10 20:12:40 +0000 |
commit | 66126d9e558dc70d49257021f29fbfb4a01d25e9 (patch) | |
tree | f3cfee9ed2213e3219732dfe5af66212f280817c | |
parent | ad471146a715299bd3acab69f0cacb8a58d72d84 (diff) |
tst_sanity/tst_creationtime: use the source tree
Pick the interesting .qml files straight from the project source tree,
instead of matching files from the engine's import path list, which
might contain undesired stray files eg. while working on multiple
features and switching between branches. The tests would fail if it
found a file that cannot be instantiated.
Change-Id: Ice1e1be3568162a45fafdea3a725e3e3eb27e10d
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
-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) |