Update qmlobserver with latest qmlviewer patches

Update qmlobserver with changes in qmlviewer until 376e636eccedb8d8bb.
This commit is contained in:
Kai Koehne
2010-12-10 12:27:33 +01:00
parent 77e3bfe845
commit 17d11b7be3
32 changed files with 1625 additions and 481 deletions

View File

@@ -48,7 +48,6 @@
#include <QDir>
#include <QCryptographicHash>
#include <QGraphicsObject>
#ifndef NO_PRIVATE_HEADERS
#include <private/qabstractanimation_p.h>
#include <private/qdeclarativeitem_p.h>
@@ -56,6 +55,7 @@
QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts,
QDeclarativeView *parent)
@@ -67,6 +67,12 @@ QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer
#ifndef NO_PRIVATE_HEADERS
QUnifiedTimer::instance()->setConsistentTiming(true);
#endif
//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();
@@ -75,7 +81,7 @@ QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer
QDeclarativeTester::~QDeclarativeTester()
{
if (!hasFailed &&
options & QDeclarativeViewer::Record &&
options & QDeclarativeViewer::Record &&
options & QDeclarativeViewer::SaveOnExit)
save();
}
@@ -142,8 +148,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()
@@ -155,7 +178,10 @@ void QDeclarativeTester::complete()
hasFailed = true;
}
}
if (options & QDeclarativeViewer::ExitOnComplete)
testSkip();
if (options & QDeclarativeViewer::ExitOnComplete)
QApplication::exit(hasFailed?-1:0);
if (hasCompleted)
@@ -207,7 +233,7 @@ void QDeclarativeTester::save()
}
ts << " }\n";
while (!mouseevents.isEmpty() &&
while (!mouseevents.isEmpty() &&
mouseevents.first().msec == fe.msec) {
MouseEvent me = mouseevents.takeFirst();
@@ -255,7 +281,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);
}
@@ -266,7 +301,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);
@@ -317,14 +352,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();
@@ -336,9 +371,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());
@@ -391,7 +431,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
ke.destination = ViewPort;
}
m_savedKeyEvents.append(ke);
}
}
testscriptidx++;
}