From f7a439a0a00b0bdd6ebeff8bfd5ee2285eab1398 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 29 Sep 2010 14:16:27 +1000 Subject: Autotest that new "import Qt 4.7"s aren't added accidentally Task-number: QTBUG-13799 --- .../auto/declarative/moduleqt47/tst_moduleqt47.cpp | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp b/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp index c1896a7..feae417 100644 --- a/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp +++ b/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include @@ -56,12 +57,20 @@ public: private slots: void create(); + void accidentalImport_data(); + void accidentalImport(); + private: + QStringList findFiles(const QDir &d); + QDeclarativeEngine engine; + QStringList excludedFiles; }; tst_moduleqt47::tst_moduleqt47() { + excludedFiles << "tests/auto/declarative/moduleqt47/data/importqt47.qml" + << "doc/src/declarative/whatsnew.qdoc"; } void tst_moduleqt47::create() @@ -74,6 +83,54 @@ void tst_moduleqt47::create() delete obj; } +QStringList tst_moduleqt47::findFiles(const QDir &d) +{ + QStringList rv; + + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.qdoc"), QDir::Files); + foreach (const QString &file, files) { + + QString absFile = d.absoluteFilePath(file); + + bool skip = false; + for (int ii = 0; !skip && ii < excludedFiles.count(); ++ii) + skip = (absFile.endsWith(excludedFiles.at(ii))); + + if (!skip) + rv << absFile; + } + + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + rv << findFiles(sub); + } + + return rv; +} + +void tst_moduleqt47::accidentalImport_data() +{ + QTest::addColumn("file"); + QStringList files = findFiles(QDir(SRCDIR "/../../../../")); + + foreach(const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} + +void tst_moduleqt47::accidentalImport() +{ + QFETCH(QString, file); + + QFile f(file); + if (!f.open(QIODevice::ReadOnly)) + return; + QByteArray data = f.readAll(); + + QVERIFY(!data.contains("import Qt 4")); +} + QTEST_MAIN(tst_moduleqt47) #include "tst_moduleqt47.moc" -- cgit v0.12