summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/snippets/declarative/models/views-models-delegates.qml2
-rw-r--r--doc/src/snippets/declarative/models/visual-model-and-view.qml2
-rw-r--r--doc/src/snippets/declarative/mousearea/mousearea-snippet.qml6
-rw-r--r--tests/auto/declarative/examples/examples.pro4
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp54
-rw-r--r--tools/qml/qmlruntime.cpp49
-rw-r--r--tools/qml/qmlruntime.h3
7 files changed, 85 insertions, 35 deletions
diff --git a/doc/src/snippets/declarative/models/views-models-delegates.qml b/doc/src/snippets/declarative/models/views-models-delegates.qml
index 65775811..4f4c0c07 100644
--- a/doc/src/snippets/declarative/models/views-models-delegates.qml
+++ b/doc/src/snippets/declarative/models/views-models-delegates.qml
@@ -38,6 +38,8 @@
**
****************************************************************************/
+import QtQuick 1.0
+
//! [rectangle]
Rectangle {
width: 200; height: 200
diff --git a/doc/src/snippets/declarative/models/visual-model-and-view.qml b/doc/src/snippets/declarative/models/visual-model-and-view.qml
index b53081ea..d78bbea3 100644
--- a/doc/src/snippets/declarative/models/visual-model-and-view.qml
+++ b/doc/src/snippets/declarative/models/visual-model-and-view.qml
@@ -38,6 +38,8 @@
**
****************************************************************************/
+import QtQuick 1.0
+
Rectangle {
width: 200; height: 200
diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
index 2f704979..26a414d4 100644
--- a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
+++ b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
@@ -50,7 +50,7 @@ Rectangle {
Column {
//! [anchor fill]
Rectangle {
- id: button
+ id: button1
width: 100; height: 100
MouseArea {
@@ -65,7 +65,7 @@ Rectangle {
//! [anchor fill]
Rectangle {
- id: button
+ id: button2
width: 100; height: 100
//! [enable handlers]
@@ -79,7 +79,7 @@ Rectangle {
}
Rectangle {
- id: button
+ id: button3
width: 100; height: 100
//! [mouse handlers]
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index 111962a5..8ff6b6ef 100644
--- a/tests/auto/declarative/examples/examples.pro
+++ b/tests/auto/declarative/examples/examples.pro
@@ -2,6 +2,9 @@ CONFIG += testcase
testcase.timeout = 400 # this test is slow
TARGET = tst_examples
+!contains(QT_CONFIG, webkit): DEFINES += QT_NO_WEBKIT
+!contains(QT_CONFIG, xmlpatterns): DEFINES += QT_NO_XMLPATTERNS
+
QT += testlib
contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
@@ -14,5 +17,4 @@ DEFINES += SRCDIR=\\\"$$PWD\\\"
CONFIG += parallel_test
-CONFIG+=insignificant_test # QTQAINFRA-428
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 199a5d2c..0a74b643 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -67,19 +67,30 @@ private:
tst_examples::tst_examples()
{
// Add directories you want excluded here
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
+ excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"
+ << "doc/src/snippets/declarative/qtbinding";
+ // Known to violate naming conventions, QTQAINFRA-428
+ excludedDirs << "demos/mobile/qtbubblelevel/qml"
+ << "demos/mobile/quickhit";
+ // Layouts do not install, QTQAINFRA-428
+ excludedDirs << "examples/declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qml/qgraphicsgridlayout"
+ << "examples/declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qml/qgraphicslinearlayout";
+ // Various QML errors, QTQAINFRA-428
+ excludedDirs << "doc/src/snippets/declarative/imports";
#ifdef QT_NO_WEBKIT
- excludedDirs << "examples/declarative/modelviews/webview";
- excludedDirs << "demos/declarative/webbrowser";
+ excludedDirs << "examples/declarative/modelviews/webview"
+ << "demos/declarative/webbrowser"
+ << "doc/src/snippets/declarative/webview";
#endif
#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "examples/declarative/xml/xmldata";
- excludedDirs << "demos/declarative/twitter";
- excludedDirs << "demos/declarative/flickr";
- excludedDirs << "demos/declarative/photoviewer";
+ excludedDirs << "examples/declarative/xml/xmldata"
+ << "demos/declarative/twitter"
+ << "demos/declarative/flickr"
+ << "demos/declarative/photoviewer"
+ << "demos/declarative/rssnews/qml/rssnews"
+ << "doc/src/snippets/declarative";
#endif
}
@@ -128,11 +139,14 @@ void tst_examples::namingConvention()
QStringList tst_examples::findQmlFiles(const QDir &d)
{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
+ const QString absolutePath = d.absolutePath();
+#ifdef Q_OS_MAC // Mac: Do not recurse into bundle folders of built examples.
+ if (absolutePath.endsWith(QLatin1String(".app")))
+ return QStringList();
+#endif
+ foreach (const QString &excludedDir, excludedDirs)
+ if (absolutePath.endsWith(excludedDir))
return QStringList();
- }
QStringList rv;
@@ -186,6 +200,13 @@ static void silentErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const
{
}
+static inline QByteArray msgViewerErrors(const QList<QDeclarativeError> &l)
+{
+ QString errors;
+ QDebug(&errors) << '\n' << l;
+ return errors.toLocal8Bit();
+}
+
void tst_examples::examples()
{
QFETCH(QString, file);
@@ -195,11 +216,12 @@ void tst_examples::examples()
QtMessageHandler old = qInstallMessageHandler(silentErrorsMsgHandler);
QVERIFY(viewer.open(file));
qInstallMessageHandler(old);
+ QVERIFY2(viewer.view()->status() != QDeclarativeView::Error,
+ msgViewerErrors(viewer.view()->errors()).constData());
+ QTRY_VERIFY(viewer.view()->status() != QDeclarativeView::Loading);
+ QVERIFY2(viewer.view()->status() == QDeclarativeView::Ready,
+ msgViewerErrors(viewer.view()->errors()).constData());
- if (viewer.view()->status() == QDeclarativeView::Error)
- qWarning() << viewer.view()->errors();
-
- QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready);
viewer.show();
QVERIFY(QTest::qWaitForWindowActive(&viewer));
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index b84acd57..6c235d5b 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -486,10 +486,30 @@ QString QDeclarativeViewer::getVideoFileName()
return QFileDialog::getSaveFileName(this, title, QString(), types.join(QLatin1String(";; ")));
}
+// Check for presence of ImageMagick by launching its command line
+// convert tool except on Windows, where convert.exe is a file system converter.
+static bool senseImageMagick()
+{
+#ifdef Q_OS_WIN
+ return false;
+#else
+ static int imageMagickFound = -1;
+ if (imageMagickFound == -1) {
+ QProcess proc;
+ proc.start(QLatin1String("convert"), QStringList(QLatin1String("-h")));
+ imageMagickFound = proc.waitForStarted() && proc.waitForFinished(2000)
+ && proc.readAllStandardOutput().contains("ImageMagick") ?
+ 1 : 0;
+ }
+ return imageMagickFound != 0;
+#endif
+}
+
QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, loggerWindow(new LoggerWidget(this))
, frame_stream(0)
+ , convertAvailable(senseImageMagick())
, rotateAction(0)
, orientation(0)
, showWarningsWindow(0)
@@ -510,7 +530,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
recdlg = new RecordingDialog(this);
connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile()));
senseFfmpeg();
- senseImageMagick();
if (!ffmpegAvailable)
recdlg->showffmpegOptions(false);
if (!ffmpegAvailable && !convertAvailable)
@@ -1052,23 +1071,27 @@ bool QDeclarativeViewer::event(QEvent *event)
return QWidget::event(event);
}
-void QDeclarativeViewer::senseImageMagick()
+// Detect ffmpeg, return its help string.
+static inline QString detectFfmpeg()
{
- QProcess proc;
- proc.start(QLatin1String("convert"), QStringList() << QLatin1String("-h"));
- proc.waitForFinished(2000);
- QString help = QString::fromLatin1(proc.readAllStandardOutput());
- convertAvailable = help.contains(QLatin1String("ImageMagick"));
+ static QString ffmpegHelp;
+ if (ffmpegHelp.isNull()) {
+ QProcess proc;
+ proc.start(QLatin1String("ffmpeg"), QStringList(QLatin1String("-h")));
+ if (proc.waitForStarted() && proc.waitForFinished(2000)) {
+ ffmpegHelp = QString::fromLocal8Bit(proc.readAllStandardOutput());
+ } else {
+ ffmpegHelp = QLatin1String("");
+ }
+ }
+ return ffmpegHelp;
}
void QDeclarativeViewer::senseFfmpeg()
{
- QProcess proc;
- proc.start(QLatin1String("ffmpeg"), QStringList() << QLatin1String("-h"));
- proc.waitForFinished(2000);
- QString ffmpegHelp = QString::fromLatin1(proc.readAllStandardOutput());
+ const QString ffmpegHelp = detectFfmpeg();
ffmpegAvailable = ffmpegHelp.contains(QLatin1String("-s "));
- ffmpegHelp = tr("Video recording uses ffmpeg:") + QLatin1String("\n\n") + ffmpegHelp;
+ const QString text = tr("Video recording uses ffmpeg:") + QLatin1String("\n\n") + ffmpegHelp;
QDialog *d = new QDialog(recdlg);
QVBoxLayout *l = new QVBoxLayout(d);
@@ -1076,7 +1099,7 @@ void QDeclarativeViewer::senseFfmpeg()
QFont f = b->font();
f.setFamily(QLatin1String("courier"));
b->setFont(f);
- b->setText(ffmpegHelp);
+ b->setText(text);
l->addWidget(b);
d->setLayout(l);
ffmpegHelpWindow = d;
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 2fd5f967..76674d04 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -174,11 +174,10 @@ private:
QAction *recordAction;
RecordingDialog *recdlg;
- void senseImageMagick();
void senseFfmpeg();
QWidget *ffmpegHelpWindow;
bool ffmpegAvailable;
- bool convertAvailable;
+ const bool convertAvailable;
QAction *rotateAction;
QActionGroup *orientation;