diff options
Diffstat (limited to 'tools/qml/qdeclarativetester.cpp')
-rw-r--r-- | tools/qml/qdeclarativetester.cpp | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index 9864df6..e3a1f59 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) @@ -247,7 +274,16 @@ void QDeclarativeTester::updateCurrentTime(int msec) if (options & QDeclarativeViewer::TestImages) { img.fill(qRgb(255,255,255)); + +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif QPainter p(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif + m_view->render(&p); } @@ -258,7 +294,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 +345,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 +364,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()); |