diff options
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/gifs/gifrecorder.cpp | 78 | ||||
-rw-r--r-- | tests/manual/gifs/tst_gifs.cpp | 4 | ||||
-rw-r--r-- | tests/manual/testbench/controls/SplitView.qml | 79 | ||||
-rw-r--r-- | tests/manual/testbench/qml.qrc | 1 |
4 files changed, 133 insertions, 29 deletions
diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp index a1ad6957..a7a5b9d6 100644 --- a/tests/manual/gifs/gifrecorder.cpp +++ b/tests/manual/gifs/gifrecorder.cpp @@ -47,7 +47,7 @@ \note The following programs must be installed if \c setHighQuality(true) is called: - \li \e avconv (sudo apt-get install libav-tools) + \li \e ffmpeg (sudo apt-get install ffmpeg) \li \e convert (sudo apt-get install imagemagick) \li \e gifsicle (sudo apt-get install gifsicle) @@ -142,29 +142,36 @@ QQuickWindow *GifRecorder::window() const } namespace { - void startProcess(QProcess &process, const QString &processName, const QString &args) + struct ProcessWaitResult { + bool success; + QString errorMessage; + }; + + ProcessWaitResult waitForProcessToStart(QProcess &process, const QString &processName, const QString &args) { qCDebug(lcGifRecorder) << "Starting" << processName << "with the following arguments:" << args; const QString command = processName + QLatin1Char(' ') + args; process.start(command); if (!process.waitForStarted(1000)) { - QString message = QString::fromLatin1("Could not launch %1 with the following arguments: %2\nError:\n%3"); - message = message.arg(processName).arg(args).arg(process.errorString()); - QFAIL(qPrintable(message)); - } else { - qCDebug(lcGifRecorder) << "Successfully started" << processName; + QString errorMessage = QString::fromLatin1("Could not launch %1 with the following arguments: %2\nError:\n%3"); + errorMessage = errorMessage.arg(processName).arg(args).arg(process.errorString()); + return { false, errorMessage }; } + + qCDebug(lcGifRecorder) << "Successfully started" << processName; + return { true, QString() }; } - void waitForProcessToFinish(QProcess &process, const QString &processName, int waitDuration) + ProcessWaitResult waitForProcessToFinish(QProcess &process, const QString &processName, int waitDuration) { if (!process.waitForFinished(waitDuration) || process.exitCode() != 0) { - QString message = QString::fromLatin1("%1 failed to finish (exit code %2): %3"); - message = message.arg(processName).arg(process.exitCode()).arg(process.errorString()); - QFAIL(qPrintable(message)); - } else { - qCDebug(lcGifRecorder) << processName << "finished"; + QString errorMessage = QString::fromLatin1("\"%1\" failed to finish (exit code %2): %3"); + errorMessage = errorMessage.arg(processName).arg(process.exitCode()).arg(process.errorString()); + return { false, errorMessage }; } + + qCDebug(lcGifRecorder) << processName << "finished"; + return { true, QString() }; } } @@ -222,7 +229,9 @@ void GifRecorder::start() connect(&mEventTimer, SIGNAL(timeout()), mWindow, SLOT(update())); mEventTimer.start(100); - startProcess(mByzanzProcess, byzanzProcessName, args); + const ProcessWaitResult result = waitForProcessToStart(mByzanzProcess, byzanzProcessName, args); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); } void GifRecorder::waitForFinish() @@ -252,20 +261,32 @@ void GifRecorder::waitForFinish() QSignalSpy spy(mWindow, SIGNAL(frameSwapped())); QVERIFY(spy.wait()); - QProcess avconvProcess; + // Start ffmpeg and send its output to imagemagick's convert command. + // Based on the example in the documentation for QProcess::setStandardOutputProcess(). + QProcess ffmpegProcess; QProcess convertProcess; - avconvProcess.setStandardOutputProcess(&convertProcess); + ffmpegProcess.setStandardOutputProcess(&convertProcess); - const QString avconvProcessName = QStringLiteral("avconv"); - const QString avconvArgs = QString::fromLatin1("-i %1 -r 20 -f image2pipe -vcodec ppm -").arg(mByzanzOutputFileName); - startProcess(avconvProcess, avconvProcessName, avconvArgs); + const QString ffmpegProcessName = QStringLiteral("ffmpeg"); + const QString ffmpegArgs = QString::fromLatin1("-i %1 -r 20 -f image2pipe -vcodec ppm -").arg(mByzanzOutputFileName); + ProcessWaitResult result = waitForProcessToStart(ffmpegProcess, ffmpegProcessName, ffmpegArgs); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); const QString convertProcessName = QStringLiteral("convert"); const QString convertArgs = QString::fromLatin1("-delay 5 -loop 0 - %1").arg(mGifFileName); - startProcess(convertProcess, convertProcessName, convertArgs); - waitForProcessToFinish(avconvProcess, avconvProcessName, waitDuration); - waitForProcessToFinish(convertProcess, convertProcessName, waitDuration); + result = waitForProcessToStart(convertProcess, convertProcessName, convertArgs); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); + + result = waitForProcessToFinish(ffmpegProcess, ffmpegProcessName, waitDuration); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); + // Conversion can take a bit longer, so double the wait time. + result = waitForProcessToFinish(convertProcess, convertProcessName, waitDuration * 2); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); const QString gifsicleProcessName = QStringLiteral("gifsicle"); const QString verbose = lcGifRecorder().isDebugEnabled() ? QStringLiteral("-V") : QString(); @@ -281,12 +302,15 @@ void GifRecorder::waitForFinish() QProcess gifsicleProcess; if (lcGifRecorder().isDebugEnabled()) gifsicleProcess.setProcessChannelMode(QProcess::ForwardedChannels); - startProcess(gifsicleProcess, gifsicleProcessName, gifsicleArgs); - waitForProcessToFinish(gifsicleProcess, gifsicleProcessName, waitDuration); - - if (QFile::exists(mByzanzOutputFileName)) { + result = waitForProcessToStart(gifsicleProcess, gifsicleProcessName, gifsicleArgs); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); + result = waitForProcessToFinish(gifsicleProcess, gifsicleProcessName, waitDuration); + if (!result.success) + QFAIL(qPrintable(result.errorMessage)); + + if (QFile::exists(mByzanzOutputFileName)) QVERIFY(QFile::remove(mByzanzOutputFileName)); - } } } diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index 2a7d55bd..d7d8f98d 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -733,8 +733,8 @@ void tst_Gifs::checkables() for (int i = 0; i < pressIndices.size(); ++i) { const int pressIndex = pressIndices.at(i); - const char *controlId = qPrintable(QString::fromLatin1("control%1").arg(pressIndex + 1)); - QQuickItem *control = window->property(controlId).value<QQuickItem*>(); + const QString controlId = QString::fromLatin1("control%1").arg(pressIndex + 1); + QQuickItem *control = window->property(qPrintable(controlId)).value<QQuickItem*>(); QVERIFY(control); const QPoint pos = control->mapToScene(QPointF(control->width() / 2, control->height() / 2)).toPoint(); diff --git a/tests/manual/testbench/controls/SplitView.qml b/tests/manual/testbench/controls/SplitView.qml new file mode 100644 index 00000000..7d534de4 --- /dev/null +++ b/tests/manual/testbench/controls/SplitView.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.5 + +QtObject { + property var supportedStates: [ + [] + ] + + property Component component: SplitView { + implicitWidth: 400 + implicitHeight: 100 + + Rectangle { + color: "salmon" + implicitWidth: 25 + implicitHeight: 25 + } + Rectangle { + color: "navajowhite" + implicitWidth: 100 + implicitHeight: 100 + } + Rectangle { + color: "steelblue" + implicitWidth: 200 + implicitHeight: 200 + } + } +} diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index a0927f35..743e6629 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -40,5 +40,6 @@ <file>controls/BusyIndicator.qml</file> <file>testbench.qml</file> <file>controls/MenuBar.qml</file> + <file>controls/SplitView.qml</file> </qresource> </RCC> |