summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-03 03:04:03 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-03 03:04:03 (GMT)
commit5f19daab6baba7d09853058355a66090a3781430 (patch)
tree203b5a1abbf8c72c448845b399e5708a82ce9cfa /tools/qmlviewer
parent1e8034a10d2496d7fb7aa987357333c6e2c3258d (diff)
downloadQt-5f19daab6baba7d09853058355a66090a3781430.zip
Qt-5f19daab6baba7d09853058355a66090a3781430.tar.gz
Qt-5f19daab6baba7d09853058355a66090a3781430.tar.bz2
Support Visual (interactive) tests without using images for confirmation.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r--tools/qmlviewer/main.cpp5
-rw-r--r--tools/qmlviewer/qfxtester.cpp21
-rw-r--r--tools/qmlviewer/qmlviewer.h7
3 files changed, 24 insertions, 9 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index 23194b2..ac0d732 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -87,7 +87,8 @@ void scriptOptsUsage()
qWarning(" options:");
qWarning(" record ................................... record a new script");
qWarning(" play ..................................... playback an existing script");
- qWarning(" testimages ............................... compare images on playback");
+ qWarning(" testimages ............................... record images or compare images on playback");
+ qWarning(" testerror ................................ test 'error' property of root item on playback");
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");
@@ -235,6 +236,8 @@ int main(int argc, char ** argv)
scriptOptions |= QmlViewer::Record;
} else if (option == QLatin1String("testimages")) {
scriptOptions |= QmlViewer::TestImages;
+ } else if (option == QLatin1String("testerror")) {
+ scriptOptions |= QmlViewer::TestErrorProperty;
} else if (option == QLatin1String("exitoncomplete")) {
scriptOptions |= QmlViewer::ExitOnComplete;
} else if (option == QLatin1String("exitonfailure")) {
diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp
index 77e8124..287771b 100644
--- a/tools/qmlviewer/qfxtester.cpp
+++ b/tools/qmlviewer/qfxtester.cpp
@@ -146,6 +146,13 @@ void QmlGraphicsTester::imagefailure()
void QmlGraphicsTester::complete()
{
+ if ((options & QmlViewer::TestErrorProperty) && !hasFailed) {
+ QString e = m_view->root()->property("error").toString();
+ if (!e.isEmpty()) {
+ qWarning() << "Test failed:" << e;
+ hasFailed = true;
+ }
+ }
if (options & QmlViewer::ExitOnComplete)
QApplication::exit(hasFailed?-1:0);
@@ -240,13 +247,15 @@ void QmlGraphicsTester::updateCurrentTime(int msec)
QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32);
- QPainter p(&img);
- m_view->render(&p);
+ if (options & QmlViewer::TestImages) {
+ QPainter p(&img);
+ m_view->render(&p);
+ }
FrameEvent fe;
fe.msec = msec;
- if (msec == 0) {
- // Skip first frame
+ if (msec == 0 || !(options & QmlViewer::TestImages)) {
+ // Skip first frame, skip if not doing images
} else if (0 == (m_savedFrameEvents.count() % 60)) {
fe.image = img;
} else {
@@ -297,6 +306,8 @@ void QmlGraphicsTester::updateCurrentTime(int msec)
QObject *event = testscript->event(testscriptidx);
if (QmlGraphicsVisualTestFrame *frame = qobject_cast<QmlGraphicsVisualTestFrame *>(event)) {
+ if ((options & QmlViewer::TestImages) && (options & QmlViewer::Record))
+ break; // recording and playing, no point "testing" results
if (frame->msec() < msec) {
if (options & QmlViewer::TestImages) {
qWarning() << "QmlGraphicsTester: Extra frame. Seen:"
@@ -304,7 +315,7 @@ void QmlGraphicsTester::updateCurrentTime(int msec)
imagefailure();
}
} else if (frame->msec() == msec) {
- if (frame->hash().toUtf8() != fe.hash.toHex()) {
+ if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) {
if (options & QmlViewer::TestImages) {
qWarning() << "QmlGraphicsTester: Mismatched frame hash. Seen:"
<< fe.hash.toHex() << "Expected:"
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index a63b938..b366401 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -66,9 +66,10 @@ public:
Play = 0x00000001,
Record = 0x00000002,
TestImages = 0x00000004,
- SaveOnExit = 0x00000008,
- ExitOnComplete = 0x00000010,
- ExitOnFailure = 0x00000020
+ TestErrorProperty = 0x00000008,
+ SaveOnExit = 0x00000010,
+ ExitOnComplete = 0x00000020,
+ ExitOnFailure = 0x00000040
};
Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
void setScript(const QString &s) { m_script = s; }