diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-04-12 04:11:32 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-04-14 01:02:12 (GMT) |
commit | ca64874f1a9f6453a0bd5a0f6b8ae61d49900314 (patch) | |
tree | 5fbede3c74dec49e4a443fc7f98edbb80071988a /tools | |
parent | b16e6e70529b8ef86734324c6c6a0e151ddf4bc8 (diff) | |
download | Qt-ca64874f1a9f6453a0bd5a0f6b8ae61d49900314.zip Qt-ca64874f1a9f6453a0bd5a0f6b8ae61d49900314.tar.gz Qt-ca64874f1a9f6453a0bd5a0f6b8ae61d49900314.tar.bz2 |
Support recording visual snapshot tests.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 4 | ||||
-rw-r--r-- | tools/qml/qdeclarativetester.cpp | 11 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 01b3912..341908e 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -121,6 +121,8 @@ void scriptOptsUsage() qWarning(" play ..................................... playback an existing script"); qWarning(" testimages ............................... record images or compare images on playback"); qWarning(" testerror ................................ test 'error' property of root item on playback"); + qWarning(" snapshot ................................. file being recorded is static,"); + qWarning(" only one frame will be recorded or tested"); qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion"); qWarning(" exitonfailure ............................ immediately exit the viewer on script failure"); qWarning(" saveonexit ............................... save recording on viewer exit"); @@ -309,6 +311,8 @@ int main(int argc, char ** argv) scriptOptions |= QDeclarativeViewer::ExitOnFailure; } else if (option == QLatin1String("saveonexit")) { scriptOptions |= QDeclarativeViewer::SaveOnExit; + } else if (option == QLatin1String("snapshot")) { + scriptOptions |= QDeclarativeViewer::Snapshot; } else { scriptOptsUsage(); } diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index 6245124..cf537ee 100644 --- a/tools/qml/qdeclarativetester.cpp +++ b/tools/qml/qdeclarativetester.cpp @@ -240,6 +240,8 @@ void QDeclarativeTester::save() void QDeclarativeTester::updateCurrentTime(int msec) { QDeclarativeItemPrivate::setConsistentTime(msec); + if (!testscript && msec > 16 && options & QDeclarativeViewer::Snapshot) + return; QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32); @@ -249,11 +251,13 @@ void QDeclarativeTester::updateCurrentTime(int msec) m_view->render(&p); } + bool snapshot = msec == 16 && options & QDeclarativeViewer::Snapshot; + FrameEvent fe; fe.msec = msec; if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) { // Skip first frame, skip if not doing images - } else if (0 == (m_savedFrameEvents.count() % 60)) { + } else if (0 == (m_savedFrameEvents.count() % 60) || snapshot) { fe.image = img; } else { QCryptographicHash hash(QCryptographicHash::Md5); @@ -366,8 +370,11 @@ void QDeclarativeTester::updateCurrentTime(int msec) filterEvents = true; - if (testscript && testscript->count() <= testscriptidx) + if (testscript && testscript->count() <= testscriptidx) { + //if (msec == 16) //for a snapshot, leave it up long enough to see + // (void)::sleep(1); complete(); + } } void QDeclarativeTester::registerTypes() diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 6f1e425..b934a70 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -81,7 +81,8 @@ public: TestErrorProperty = 0x00000008, SaveOnExit = 0x00000010, ExitOnComplete = 0x00000020, - ExitOnFailure = 0x00000040 + ExitOnFailure = 0x00000040, + Snapshot = 0x00000080 }; Q_DECLARE_FLAGS(ScriptOptions, ScriptOption) void setScript(const QString &s) { m_script = s; } |