diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-08-10 17:26:23 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-08-11 09:09:34 +0000 |
commit | d5c2e819cffe417813296904ed8ed858a5e111fc (patch) | |
tree | 837748adda2484aaef4a0126a617b0180ad25e3f /tests/manual/gifs | |
parent | 3d2e18aa57f15c8af3ea98c2283cd8253693095a (diff) |
GifRecorder: force view updates.
byzanz-record will cut recordings short if there are no repaints.
Change-Id: Ied7fcfec066aa3d558b5e6909f7abf74628cfa23
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/manual/gifs')
-rw-r--r-- | tests/manual/gifs/gifrecorder.cpp | 26 | ||||
-rw-r--r-- | tests/manual/gifs/gifrecorder.h | 3 |
2 files changed, 23 insertions, 6 deletions
diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp index 9ff4e7c3..78981e78 100644 --- a/tests/manual/gifs/gifrecorder.cpp +++ b/tests/manual/gifs/gifrecorder.cpp @@ -57,13 +57,16 @@ Q_LOGGING_CATEGORY(lcGifRecorder, "qt.gifrecorder") +namespace { + static const char *byzanzProcessName = "byzanz-record"; +} + GifRecorder::GifRecorder() : QObject(Q_NULLPTR), mView(Q_NULLPTR), mHighQuality(false), mRecordingDuration(0), mRecordCursor(false), - mByzanzProcessName(QStringLiteral("byzanz-record")), mByzanzProcessFinished(false) { if (lcGifRecorder().isDebugEnabled()) { @@ -196,15 +199,28 @@ void GifRecorder::start() .arg(QString::number(mView->height())) .arg(mByzanzOutputFileName); - startProcess(mByzanzProcess, mByzanzProcessName, args); + + // https://bugs.launchpad.net/ubuntu/+source/byzanz/+bug/1483581 + // It seems that byzanz-record will cut a recording short if there are no + // screen repaints, no matter what format it outputs. This can be tested + // manually from the command line by recording any section of the screen + // without moving the mouse and then running avprobe on the resulting .flv. + // Our workaround is to force view updates. + connect(&mEventTimer, SIGNAL(timeout()), mView, SLOT(update())); + mEventTimer.start(100); + + startProcess(mByzanzProcess, byzanzProcessName, args); } void GifRecorder::waitForFinish() { // Give it an extra couple of seconds on top of its recording duration. - const int waitDuration = (mRecordingDuration + 2) * 1000; + const int recordingDurationMs = mRecordingDuration * 1000; + const int waitDuration = recordingDurationMs + 2000; QTRY_VERIFY_WITH_TIMEOUT(mByzanzProcessFinished, waitDuration); + mEventTimer.stop(); + if (!QFileInfo::exists(mByzanzOutputFileName)) { const QString message = QString::fromLatin1( "The process said it finished successfully, but %1 was not generated.").arg(mByzanzOutputFileName); @@ -253,11 +269,11 @@ void GifRecorder::waitForFinish() void GifRecorder::onByzanzError() { const QString message = QString::fromLatin1("%1 failed to finish: %2"); - QFAIL(qPrintable(message.arg(mByzanzProcessName).arg(mByzanzProcess.errorString()))); + QFAIL(qPrintable(message.arg(byzanzProcessName).arg(mByzanzProcess.errorString()))); } void GifRecorder::onByzanzFinished() { - qCDebug(lcGifRecorder) << mByzanzProcessName << "finished"; + qCDebug(lcGifRecorder) << byzanzProcessName << "finished"; mByzanzProcessFinished = true; } diff --git a/tests/manual/gifs/gifrecorder.h b/tests/manual/gifs/gifrecorder.h index 4f056ef0..c6ef3e5c 100644 --- a/tests/manual/gifs/gifrecorder.h +++ b/tests/manual/gifs/gifrecorder.h @@ -42,6 +42,7 @@ #include <QQuickView> #include <QDir> #include <QString> +#include <QTimer> class GifRecorder : public QObject { @@ -79,9 +80,9 @@ private: int mRecordingDuration; bool mRecordCursor; - const QString mByzanzProcessName; QProcess mByzanzProcess; bool mByzanzProcessFinished; + QTimer mEventTimer; }; #endif // GIFRECORDER_H |