summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/examples
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/examples')
-rw-r--r--tests/auto/declarative/examples/examples.pro3
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp121
2 files changed, 96 insertions, 28 deletions
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index 85d2a73..b316cb9 100644
--- a/tests/auto/declarative/examples/examples.pro
+++ b/tests/auto/declarative/examples/examples.pro
@@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle
SOURCES += tst_examples.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 3d717bc..e62aad2 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -43,6 +43,8 @@
#include <QDir>
#include <QProcess>
#include <QDebug>
+#include <QFutureSynchronizer>
+#include <QtConcurrentRun>
class tst_examples : public QObject
{
@@ -51,7 +53,6 @@ public:
tst_examples();
private slots:
- void examples_data();
void examples();
void namingConvention();
@@ -81,6 +82,15 @@ tst_examples::tst_examples()
excludedDirs << "examples/declarative/plugins";
excludedDirs << "examples/declarative/proxywidgets";
excludedDirs << "examples/declarative/gestures";
+
+ excludedDirs << "examples/declarative/imageprovider";
+ excludedDirs << "demos/declarative/minehunt";
+
+#ifdef QT_NO_WEBKIT
+ excludedDirs << "examples/declarative/webview";
+ excludedDirs << "demos/declarative/webbrowser";
+#endif
+
#ifdef QT_NO_XMLPATTERNS
excludedDirs << "examples/declarative/xmldata";
excludedDirs << "demos/declarative/twitter";
@@ -101,19 +111,19 @@ void tst_examples::namingConvention(const QDir &d)
return;
}
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
QDir::Files);
bool seenQml = !files.isEmpty();
bool seenLowercase = false;
foreach (const QString &file, files) {
- if (file.at(0).isLower())
+ if (file.at(0).isLower())
seenLowercase = true;
}
if (!seenQml) {
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
QDir::NoSymLinks);
foreach (const QString &dir, dirs) {
QDir sub = d;
@@ -144,7 +154,7 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
QStringList rv;
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
QDir::Files);
foreach (const QString &file, files) {
if (file.at(0).isLower()) {
@@ -152,7 +162,7 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
}
}
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
QDir::NoSymLinks);
foreach (const QString &dir, dirs) {
QDir sub = d;
@@ -163,41 +173,38 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
return rv;
}
+
+
/*
-This test runs all the examples in the declarative UI source tree and ensures
+This test runs all the examples in the declarative UI source tree and ensures
that they start and exit cleanly.
Examples are any .qml files under the examples/ or demos/ directory that start
-with a lower case letter.
+with a lower case letter.
*/
-void tst_examples::examples_data()
-{
- QTest::addColumn<QString>("file");
+#define THREADS 5
- QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
- QString demos = QLibraryInfo::location(QLibraryInfo::DemosPath);
- QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
+struct Example {
+public:
+ Example() : result(Unknown) {}
- QStringList files;
- files << findQmlFiles(QDir(examples));
- files << findQmlFiles(QDir(demos));
- files << findQmlFiles(QDir(snippets));
+ enum Result { Pass, Unknown, Fail };
+ Result result;
+ QString file;
+ QString qmlruntime;
- foreach (const QString &file, files)
- QTest::newRow(file.toLatin1().constData()) << file;
-}
+ void run();
+};
-void tst_examples::examples()
+void Example::run()
{
- QFETCH(QString, file);
-
QFileInfo fi(file);
QFileInfo dir(fi.path());
QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName();
QFileInfo testdata(script+".qml");
QStringList arguments;
arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest"))
- << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
+ << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
<< file;
#ifdef Q_WS_QWS
arguments << "-qws";
@@ -205,11 +212,69 @@ void tst_examples::examples()
QProcess p;
p.start(qmlruntime, arguments);
- QVERIFY(p.waitForFinished());
+ if (!p.waitForFinished()) {
+ result = Fail;
+ return;
+ }
+
if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0)
qWarning() << p.readAllStandardOutput() << p.readAllStandardError();
- QCOMPARE(p.exitStatus(), QProcess::NormalExit);
- QCOMPARE(p.exitCode(), 0);
+
+ if (p.exitStatus() != QProcess::NormalExit ||
+ p.exitCode() != 0) {
+ result = Fail;
+ return;
+ } else {
+ result = Pass;
+ return;
+ }
+}
+
+void tst_examples::examples()
+{
+ QThreadPool::globalInstance()->setMaxThreadCount(5);
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/";
+ QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/";
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
+
+ QStringList files;
+ files << findQmlFiles(QDir(examples));
+ files << findQmlFiles(QDir(demos));
+ files << findQmlFiles(QDir(snippets));
+
+ QList<Example> tests;
+
+ for (int ii = 0; ii < files.count(); ++ii) {
+ Example e;
+ e.file = files.at(ii);
+ e.qmlruntime = qmlruntime;
+ tests << e;
+ }
+
+ QFutureSynchronizer<void> sync;
+
+ for (int ii = 0; ii < tests.count(); ++ii) {
+ Example *e = &tests[ii];
+ QFuture<void> r = QtConcurrent::run(e, &Example::run);
+ sync.addFuture(r);
+ }
+
+ sync.waitForFinished();
+
+ QStringList failures;
+ for (int ii = 0; ii < tests.count(); ++ii) {
+ if (tests.at(ii).result != Example::Pass)
+ failures << QDir::cleanPath(tests.at(ii).file);
+ }
+
+ if (failures.count()) {
+ QString error("Failed examples: ");
+ error += failures.join(", ");
+
+ QFAIL(qPrintable(error));
+ }
+
}
QTEST_MAIN(tst_examples)