diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
commit | 802498fcd43558a10bb7477d3957cdd27fd8ec09 (patch) | |
tree | c40ddd859b032ffa7ed9c6df1173312c0bb1947d /tools/qml | |
parent | 901fee7e610ec53f744416aeeca89c4605923120 (diff) | |
parent | 538e7b8ddf45936bb274ed3230b591b3459edfa7 (diff) | |
download | Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.zip Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.gz Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.bz2 |
Merge remote branch 'qt/master' into file-engine-refactor
Conflicts:
demos/declarative/minehunt/minehunt.pro
src/corelib/io/io.pri
src/corelib/io/qfsfileengine.cpp
src/corelib/io/qfsfileengine_unix.cpp
src/corelib/io/qfsfileengine_win.cpp
src/s60installs/bwins/QtCoreu.def
src/s60installs/bwins/QtDeclarativeu.def
src/s60installs/bwins/QtGuiu.def
src/s60installs/eabi/QtCoreu.def
src/s60installs/eabi/QtDeclarativeu.def
src/s60installs/eabi/QtGuiu.def
tests/auto/qapplication/test/test.pro
tests/auto/qaudioinput/qaudioinput.pro
tests/auto/qaudiooutput/qaudiooutput.pro
tests/auto/qchar/qchar.pro
tests/auto/qdiriterator/qdiriterator.pro
tests/auto/qsound/qsound.pro
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/main.cpp | 3 | ||||
-rw-r--r-- | tools/qml/qdeclarativetester.cpp | 46 | ||||
-rw-r--r-- | tools/qml/qdeclarativetester.h | 1 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 3 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 3 |
5 files changed, 48 insertions, 8 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 00d43c1..579f1ab 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -172,6 +172,7 @@ 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(" testskip ................................ test 'skip' 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"); @@ -305,6 +306,8 @@ static void parseScriptOptions() scriptOptions |= QDeclarativeViewer::TestImages; } else if (option == QLatin1String("testerror")) { scriptOptions |= QDeclarativeViewer::TestErrorProperty; + } else if (option == QLatin1String("testskip")) { + scriptOptions |= QDeclarativeViewer::TestSkipProperty; } else if (option == QLatin1String("exitoncomplete")) { scriptOptions |= QDeclarativeViewer::ExitOnComplete; } else if (option == QLatin1String("exitonfailure")) { diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index 9864df6..a516fd7 100644 --- a/tools/qml/qdeclarativetester.cpp +++ b/tools/qml/qdeclarativetester.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE +extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts, QDeclarativeView *parent) @@ -61,6 +62,12 @@ QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer parent->viewport()->installEventFilter(this); parent->installEventFilter(this); QUnifiedTimer::instance()->setConsistentTiming(true); + + //Font antialiasing makes tests system-specific, so disable it + QFont noAA = QApplication::font(); + noAA.setStyleStrategy(QFont::NoAntialias); + QApplication::setFont(noAA); + if (options & QDeclarativeViewer::Play) this->run(); start(); @@ -136,8 +143,25 @@ void QDeclarativeTester::imagefailure() { hasFailed = true; - if (options & QDeclarativeViewer::ExitOnFailure) - exit(-1); + if (options & QDeclarativeViewer::ExitOnFailure){ + testSkip(); + exit(hasFailed?-1:0); + } +} + +void QDeclarativeTester::testSkip() +{ + if (options & QDeclarativeViewer::TestSkipProperty){ + QString e = m_view->rootObject()->property("skip").toString(); + if (!e.isEmpty()) { + if(hasFailed){ + qWarning() << "Test failed, but skipping it: " << e; + }else{ + qWarning() << "Test skipped: " << e; + } + hasFailed = 0; + } + } } void QDeclarativeTester::complete() @@ -149,7 +173,10 @@ void QDeclarativeTester::complete() hasFailed = true; } } - if (options & QDeclarativeViewer::ExitOnComplete) + + + testSkip(); + if (options & QDeclarativeViewer::ExitOnComplete) QApplication::exit(hasFailed?-1:0); if (hasCompleted) @@ -258,7 +285,7 @@ void QDeclarativeTester::updateCurrentTime(int msec) fe.msec = msec; if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) { // Skip first frame, skip if not doing images - } else if (0 == (m_savedFrameEvents.count() % 60) || snapshot) { + } else if (0 == ((m_savedFrameEvents.count()-1) % 60) || snapshot) { fe.image = img; } else { QCryptographicHash hash(QCryptographicHash::Md5); @@ -309,14 +336,14 @@ void QDeclarativeTester::updateCurrentTime(int msec) if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) { if (frame->msec() < msec) { if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) { - qWarning() << "QDeclarativeTester: Extra frame. Seen:" + qWarning() << "QDeclarativeTester(" << m_script << "): Extra frame. Seen:" << msec << "Expected:" << frame->msec(); imagefailure(); } } else if (frame->msec() == msec) { if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) { if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) { - qWarning() << "QDeclarativeTester: Mismatched frame hash at" << msec + qWarning() << "QDeclarativeTester(" << m_script << "): Mismatched frame hash at" << msec << ". Seen:" << fe.hash.toHex() << "Expected:" << frame->hash().toUtf8(); imagefailure(); @@ -328,9 +355,14 @@ void QDeclarativeTester::updateCurrentTime(int msec) if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) { QImage goodImage(frame->image().toLocalFile()); + if (frame->msec() == 16 && goodImage.size() != img.size()){ + //Also an image mismatch, but this warning is more informative. Only checked at start though. + qWarning() << "QDeclarativeTester(" << m_script << "): Size mismatch. This test must be run at " << goodImage.size(); + imagefailure(); + } if (goodImage != img) { QString reject(frame->image().toLocalFile() + ".reject.png"); - qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:" + qWarning() << "QDeclarativeTester(" << m_script << "): Image mismatch. Reject saved to:" << reject; img.save(reject); bool doDiff = (goodImage.size() == img.size()); diff --git a/tools/qml/qdeclarativetester.h b/tools/qml/qdeclarativetester.h index 021869d..0cf508a 100644 --- a/tools/qml/qdeclarativetester.h +++ b/tools/qml/qdeclarativetester.h @@ -228,6 +228,7 @@ private: void imagefailure(); void complete(); + void testSkip(); enum Destination { View, ViewPort }; void addKeyEvent(Destination, QKeyEvent *); diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 5e169d8..78bc409 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -1383,6 +1383,8 @@ void QDeclarativeViewer::appAboutToQuit() // avoid crashes if messages are received after app has closed delete loggerWindow; loggerWindow = 0; + delete tester; + tester = 0; } void QDeclarativeViewer::autoStartRecording() @@ -1518,6 +1520,7 @@ void QDeclarativeViewer::updateSizeHints(bool initial) //qWarning() << "USH: R2V: setting free size "; layout()->setSizeConstraint(QLayout::SetNoConstraint); layout()->activate(); + setMinimumSize(QSize(1,1)); setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index d1ec26d..b43aa54 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -83,7 +83,8 @@ public: SaveOnExit = 0x00000010, ExitOnComplete = 0x00000020, ExitOnFailure = 0x00000040, - Snapshot = 0x00000080 + Snapshot = 0x00000080, + TestSkipProperty = 0x00000100 }; Q_DECLARE_FLAGS(ScriptOptions, ScriptOption) void setScript(const QString &s) { m_script = s; } |