summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/examples/tst_examples.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-14 23:06:54 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-14 23:06:54 (GMT)
commitaad7bc4085980edf9fd6736efe909dc5a74a9d27 (patch)
treef44440a2633cb79b0e8e7c08315e0a8d8645a58b /tests/auto/declarative/examples/tst_examples.cpp
parentca52a35fa6bf4a86310d06c22aa256ab654712de (diff)
parent4174dd5dca647bfbe5ff5db1d495b7f887833323 (diff)
downloadQt-aad7bc4085980edf9fd6736efe909dc5a74a9d27.zip
Qt-aad7bc4085980edf9fd6736efe909dc5a74a9d27.tar.gz
Qt-aad7bc4085980edf9fd6736efe909dc5a74a9d27.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (71 commits) Add QML documentation for validators Updates to the module documentation Fix minor typo in docs Revert "qdeclarativefocusscope works fine as a parallel test" qdeclarativefocusscope works fine as a parallel test Reduce warnings at shutdown Image with PreserveAspect enabled with either width or height defined should implicitly update the undefined axis to follow the aspect ratio Fix GridView.onRemove animation in photoviewer. Reduce warnings at shutdown Fix QT_NO_DESKTOPSERVICES Compiled bindings should not print warnings where normal bindings don't Update references links Move example code into separate files to make sure they compile Include qvariant.h as a convenience as context properties Merged 'orientation' into 'runtime' context property in qmlruntime Add 'runtime' property to the rootContext of DeclarativeViewer Temporarily disable tests that require compilation Fix qdeclarativedom test Further improve failure output Doc: more mention of using QUrl::fromLocalFile() for URLs on local filesystem ...
Diffstat (limited to 'tests/auto/declarative/examples/tst_examples.cpp')
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp121
1 files changed, 93 insertions, 28 deletions
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)