From deef2e16776c171d4b033257cd4fc3ab2bd005a3 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 25 Aug 2010 13:49:34 +0200 Subject: First shot at a new client-server based autotest of the Arthur 2D rendering system, based on the lance test tool. Hence dubbed lancelot. --- tests/arthur/baselineserver/bin/runserver | 6 + tests/arthur/baselineserver/src/baselineserver.cpp | 188 +++++++ tests/arthur/baselineserver/src/baselineserver.h | 74 +++ tests/arthur/baselineserver/src/baselineserver.pro | 25 + tests/arthur/baselineserver/src/main.cpp | 16 + tests/arthur/common/baselineprotocol.cpp | 219 ++++++++ tests/arthur/common/baselineprotocol.h | 76 +++ tests/arthur/common/baselineprotocol.pri | 9 + tests/auto/lancelot/lancelot.pro | 10 + tests/auto/lancelot/scripts/aliasing.qps | 156 ++++++ tests/auto/lancelot/scripts/arcs.qps | 68 +++ tests/auto/lancelot/scripts/arcs2.qps | 47 ++ tests/auto/lancelot/scripts/background.qps | 136 +++++ tests/auto/lancelot/scripts/background_brush.qps | 5 + tests/auto/lancelot/scripts/beziers.qps | 147 ++++++ tests/auto/lancelot/scripts/bitmaps.qps | 166 ++++++ tests/auto/lancelot/scripts/borderimage.qps | 120 +++++ tests/auto/lancelot/scripts/brush_pens.qps | 104 ++++ tests/auto/lancelot/scripts/brushes.qps | 79 +++ tests/auto/lancelot/scripts/clippaths.qps | 60 +++ tests/auto/lancelot/scripts/clipping.qps | 182 +++++++ tests/auto/lancelot/scripts/clipping_state.qps | 47 ++ tests/auto/lancelot/scripts/cliprects.qps | 59 +++ tests/auto/lancelot/scripts/conical_gradients.qps | 85 ++++ .../scripts/conical_gradients_perspectives.qps | 64 +++ tests/auto/lancelot/scripts/dashes.qps | 268 ++++++++++ tests/auto/lancelot/scripts/degeneratebeziers.qps | 10 + tests/auto/lancelot/scripts/deviceclipping.qps | 48 ++ tests/auto/lancelot/scripts/drawpoints.qps | 101 ++++ tests/auto/lancelot/scripts/ellipses.qps | 86 ++++ tests/auto/lancelot/scripts/filltest.qps | 413 +++++++++++++++ tests/auto/lancelot/scripts/gradients.qps | 44 ++ tests/auto/lancelot/scripts/image_formats.qps | 81 +++ tests/auto/lancelot/scripts/images.qps | 106 ++++ tests/auto/lancelot/scripts/images2.qps | 145 ++++++ tests/auto/lancelot/scripts/join_cap_styles.qps | 63 +++ .../join_cap_styles_duplicate_control_points.qps | 68 +++ tests/auto/lancelot/scripts/linear_gradients.qps | 144 ++++++ .../scripts/linear_gradients_perspectives.qps | 62 +++ .../scripts/linear_resolving_gradients.qps | 66 +++ tests/auto/lancelot/scripts/lineconsistency.qps | 72 +++ tests/auto/lancelot/scripts/linedashes.qps | 94 ++++ tests/auto/lancelot/scripts/linedashes2.qps | 154 ++++++ tests/auto/lancelot/scripts/linedashes2_aa.qps | 5 + tests/auto/lancelot/scripts/lines.qps | 558 +++++++++++++++++++++ tests/auto/lancelot/scripts/lines2.qps | 179 +++++++ tests/auto/lancelot/scripts/pathfill.qps | 38 ++ tests/auto/lancelot/scripts/paths.qps | 34 ++ tests/auto/lancelot/scripts/paths_aa.qps | 4 + tests/auto/lancelot/scripts/pens.qps | 133 +++++ tests/auto/lancelot/scripts/pens_aa.qps | 6 + tests/auto/lancelot/scripts/pens_cosmetic.qps | 110 ++++ tests/auto/lancelot/scripts/perspectives.qps | 72 +++ tests/auto/lancelot/scripts/perspectives2.qps | 309 ++++++++++++ tests/auto/lancelot/scripts/pixmap_rotation.qps | 30 ++ tests/auto/lancelot/scripts/pixmap_scaling.qps | 224 +++++++++ tests/auto/lancelot/scripts/pixmap_subpixel.qps | 117 +++++ tests/auto/lancelot/scripts/pixmaps.qps | 106 ++++ tests/auto/lancelot/scripts/porter_duff.qps | 251 +++++++++ tests/auto/lancelot/scripts/porter_duff2.qps | 261 ++++++++++ tests/auto/lancelot/scripts/primitives.qps | 184 +++++++ tests/auto/lancelot/scripts/radial_gradients.qps | 99 ++++ .../scripts/radial_gradients_perspectives.qps | 62 +++ tests/auto/lancelot/scripts/rasterops.qps | 87 ++++ tests/auto/lancelot/scripts/sizes.qps | 150 ++++++ tests/auto/lancelot/scripts/text.qps | 124 +++++ tests/auto/lancelot/scripts/text_perspectives.qps | 102 ++++ tests/auto/lancelot/scripts/tiled_pixmap.qps | 84 ++++ tests/auto/lancelot/tst_lancelot.cpp | 238 +++++++++ tests/auto/other.pro | 1 + 70 files changed, 7741 insertions(+) create mode 100755 tests/arthur/baselineserver/bin/runserver create mode 100644 tests/arthur/baselineserver/src/baselineserver.cpp create mode 100644 tests/arthur/baselineserver/src/baselineserver.h create mode 100644 tests/arthur/baselineserver/src/baselineserver.pro create mode 100644 tests/arthur/baselineserver/src/main.cpp create mode 100644 tests/arthur/common/baselineprotocol.cpp create mode 100644 tests/arthur/common/baselineprotocol.h create mode 100644 tests/arthur/common/baselineprotocol.pri create mode 100644 tests/auto/lancelot/lancelot.pro create mode 100644 tests/auto/lancelot/scripts/aliasing.qps create mode 100644 tests/auto/lancelot/scripts/arcs.qps create mode 100644 tests/auto/lancelot/scripts/arcs2.qps create mode 100644 tests/auto/lancelot/scripts/background.qps create mode 100644 tests/auto/lancelot/scripts/background_brush.qps create mode 100644 tests/auto/lancelot/scripts/beziers.qps create mode 100644 tests/auto/lancelot/scripts/bitmaps.qps create mode 100644 tests/auto/lancelot/scripts/borderimage.qps create mode 100644 tests/auto/lancelot/scripts/brush_pens.qps create mode 100644 tests/auto/lancelot/scripts/brushes.qps create mode 100644 tests/auto/lancelot/scripts/clippaths.qps create mode 100644 tests/auto/lancelot/scripts/clipping.qps create mode 100644 tests/auto/lancelot/scripts/clipping_state.qps create mode 100644 tests/auto/lancelot/scripts/cliprects.qps create mode 100644 tests/auto/lancelot/scripts/conical_gradients.qps create mode 100644 tests/auto/lancelot/scripts/conical_gradients_perspectives.qps create mode 100644 tests/auto/lancelot/scripts/dashes.qps create mode 100644 tests/auto/lancelot/scripts/degeneratebeziers.qps create mode 100644 tests/auto/lancelot/scripts/deviceclipping.qps create mode 100644 tests/auto/lancelot/scripts/drawpoints.qps create mode 100644 tests/auto/lancelot/scripts/ellipses.qps create mode 100644 tests/auto/lancelot/scripts/filltest.qps create mode 100644 tests/auto/lancelot/scripts/gradients.qps create mode 100644 tests/auto/lancelot/scripts/image_formats.qps create mode 100644 tests/auto/lancelot/scripts/images.qps create mode 100644 tests/auto/lancelot/scripts/images2.qps create mode 100644 tests/auto/lancelot/scripts/join_cap_styles.qps create mode 100644 tests/auto/lancelot/scripts/join_cap_styles_duplicate_control_points.qps create mode 100644 tests/auto/lancelot/scripts/linear_gradients.qps create mode 100644 tests/auto/lancelot/scripts/linear_gradients_perspectives.qps create mode 100644 tests/auto/lancelot/scripts/linear_resolving_gradients.qps create mode 100644 tests/auto/lancelot/scripts/lineconsistency.qps create mode 100644 tests/auto/lancelot/scripts/linedashes.qps create mode 100644 tests/auto/lancelot/scripts/linedashes2.qps create mode 100644 tests/auto/lancelot/scripts/linedashes2_aa.qps create mode 100644 tests/auto/lancelot/scripts/lines.qps create mode 100644 tests/auto/lancelot/scripts/lines2.qps create mode 100644 tests/auto/lancelot/scripts/pathfill.qps create mode 100644 tests/auto/lancelot/scripts/paths.qps create mode 100644 tests/auto/lancelot/scripts/paths_aa.qps create mode 100644 tests/auto/lancelot/scripts/pens.qps create mode 100644 tests/auto/lancelot/scripts/pens_aa.qps create mode 100644 tests/auto/lancelot/scripts/pens_cosmetic.qps create mode 100644 tests/auto/lancelot/scripts/perspectives.qps create mode 100644 tests/auto/lancelot/scripts/perspectives2.qps create mode 100644 tests/auto/lancelot/scripts/pixmap_rotation.qps create mode 100644 tests/auto/lancelot/scripts/pixmap_scaling.qps create mode 100644 tests/auto/lancelot/scripts/pixmap_subpixel.qps create mode 100644 tests/auto/lancelot/scripts/pixmaps.qps create mode 100644 tests/auto/lancelot/scripts/porter_duff.qps create mode 100644 tests/auto/lancelot/scripts/porter_duff2.qps create mode 100644 tests/auto/lancelot/scripts/primitives.qps create mode 100644 tests/auto/lancelot/scripts/radial_gradients.qps create mode 100644 tests/auto/lancelot/scripts/radial_gradients_perspectives.qps create mode 100644 tests/auto/lancelot/scripts/rasterops.qps create mode 100644 tests/auto/lancelot/scripts/sizes.qps create mode 100644 tests/auto/lancelot/scripts/text.qps create mode 100644 tests/auto/lancelot/scripts/text_perspectives.qps create mode 100644 tests/auto/lancelot/scripts/tiled_pixmap.qps create mode 100644 tests/auto/lancelot/tst_lancelot.cpp diff --git a/tests/arthur/baselineserver/bin/runserver b/tests/arthur/baselineserver/bin/runserver new file mode 100755 index 0000000..52feb86 --- /dev/null +++ b/tests/arthur/baselineserver/bin/runserver @@ -0,0 +1,6 @@ +#!/bin/bash + +while true; do + ./baselineserver + sleep 5 +done diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp new file mode 100644 index 0000000..bba2cd8 --- /dev/null +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -0,0 +1,188 @@ +#include "baselineserver.h" +#include +#include +#include +#include +#include +#include + +QString BaselineServer::storage; + +BaselineServer::BaselineServer(QObject *parent) + : QTcpServer(parent) +{ + QFileInfo me(QCoreApplication::applicationFilePath()); + meLastMod = me.lastModified(); + heartbeatTimer = new QTimer(this); + connect(heartbeatTimer, SIGNAL(timeout()), this, SLOT(heartbeat())); + heartbeatTimer->start(HEARTBEAT*1000); +} + +QString BaselineServer::storagePath() +{ + if (storage.isEmpty()) { + QDir dir(QCoreApplication::applicationDirPath()); + dir.cdUp(); + storage = dir.path() + QLatin1String("/storage/"); + } + return storage; +} + +void BaselineServer::incomingConnection(int socketDescriptor) +{ + qDebug() << "Server: New connection!"; + BaselineThread *thread = new BaselineThread(socketDescriptor, this); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + thread->start(); +} + +void BaselineServer::heartbeat() +{ + // The idea is to exit to be restarted when modified, as soon as not actually serving + QFileInfo me(QCoreApplication::applicationFilePath()); + if (me.lastModified() == meLastMod) + return; + + // (could close() here to avoid accepting new connections, to avoid livelock) + // also, could check for a timeout to force exit, to avoid hung threads blocking + bool isServing = false; + foreach(BaselineThread *thread, findChildren()) { + if (thread->isRunning()) { + isServing = true; + break; + } + } + + if (!isServing) + QCoreApplication::exit(); +} + +BaselineThread::BaselineThread(int socketDescriptor, QObject *parent) + : QThread(parent), socketDescriptor(socketDescriptor) +{ +} + +void BaselineThread::run() +{ + BaselineHandler handler(socketDescriptor); + exec(); +} + + +BaselineHandler::BaselineHandler(int socketDescriptor) + : QObject(), connectionEstablished(false) +{ + runId = QDateTime::currentDateTime().toString(QLatin1String("MMMdd-hhmmss")); + + connect(&proto.socket, SIGNAL(readyRead()), this, SLOT(receiveRequest())); + connect(&proto.socket, SIGNAL(disconnected()), this, SLOT(receiveDisconnect())); + proto.socket.setSocketDescriptor(socketDescriptor); +} + + +void BaselineHandler::receiveRequest() +{ + if (!connectionEstablished) { + if (!proto.acceptConnection(&plat)) { + qWarning() << runId << "Accepting new connection failed. " << proto.errorMessage(); + QThread::currentThread()->exit(1); + return; + } + connectionEstablished = true; + qDebug() << runId << "Connection established with" << plat.hostname << "Qt version:" << plat.qtVersion << plat.buildKey; + return; + } + + QByteArray block; + BaselineProtocol::Command cmd; + if (!proto.receiveBlock(&cmd, &block)) { + qWarning() << runId << "Command reception failed. "<< proto.errorMessage(); + QThread::currentThread()->exit(1); + return; + } + + switch(cmd) { + case BaselineProtocol::RequestBaseline: + provideBaseline(block); + break; + case BaselineProtocol::AcceptNewBaseline: + storeImage(block, true); + break; + case BaselineProtocol::AcceptMismatch: + storeImage(block, false); + break; + default: + qWarning() << runId << "Unknown command received. " << proto.errorMessage(); + QThread::currentThread()->exit(1); + } +} + + +void BaselineHandler::provideBaseline(const QByteArray &caseId) +{ + qDebug() << runId << "Received request for baseline" << caseId; + + QFile file(pathForCaseId(caseId)); + if (!file.open(QIODevice::ReadOnly)) { + qDebug() << runId << "baseline not found."; + proto.sendBlock(BaselineProtocol::BaselineNotPresent, caseId); + return; + } + proto.sendBlock(BaselineProtocol::AcceptBaseline, file.readAll()); +} + + +void BaselineHandler::storeImage(const QByteArray &imageBlock, bool isBaseline) +{ + QBuffer buf; + buf.setData(imageBlock); + buf.open(QIODevice::ReadOnly); + QDataStream ds(&buf); + QByteArray caseId; + ds >> caseId; + //# For futuresafeness, should make caseId FS-safe - but revertable... + QFile file(pathForCaseId(caseId, isBaseline)); + qDebug() << runId << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << caseId << "Storing in" << file.fileName(); + QString path = file.fileName().section(QDir::separator(), 0, -2); + QDir cwd; + if (!cwd.exists(path)) + cwd.mkpath(path); + if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + qWarning() << runId << "Failed to store" << file.fileName(); + return; + } + file.write(imageBlock.constData()+buf.pos(), imageBlock.size()-buf.pos()); + + QByteArray msg(isBaseline ? "Mismatching" : "Baseline"); + msg += " image stored in " + + QHostInfo::localHostName().toLatin1() + '.' + + QHostInfo::localDomainName().toLatin1() + ':' + + QFileInfo(file).absoluteFilePath().toLatin1(); + proto.sendBlock(BaselineProtocol::Ack, msg); + qDebug() << runId << "Storing done."; +} + + +void BaselineHandler::receiveDisconnect() +{ + qDebug() << runId << "Client disconnected."; + QThread::currentThread()->exit(0); +} + + +QString BaselineHandler::pathForCaseId(const QByteArray &caseId, bool isBaseline) +{ + QString storePath = BaselineServer::storagePath(); + storePath += plat.buildKey.section(QLatin1Char(' '), 1, 1) + QLatin1String("_Qt-") + + plat.qtVersion + QDir::separator(); + if (isBaseline) + storePath += QLatin1String("baselines") + QDir::separator(); + else + storePath += runId + QDir::separator(); + return storePath + caseId + QLatin1Char('.') + QLatin1String(FileFormat); +} + + +// - transferring and comparing checksums instead of images +// - then we could now if multiple error/imgs are really the same (and just store it once) +// - e.g. using db diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h new file mode 100644 index 0000000..8cd9f56 --- /dev/null +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -0,0 +1,74 @@ +#ifndef BASELINESERVER_H +#define BASELINESERVER_H + +#include +#include +#include +#include +#include "baselineprotocol.h" +#include +#include +#include + +// #seconds between update checks +#define HEARTBEAT 10 + +class BaselineServer : public QTcpServer +{ + Q_OBJECT + +public: + BaselineServer(QObject *parent = 0); + + static QString storagePath(); + +protected: + void incomingConnection(int socketDescriptor); + +private slots: + void heartbeat(); + +private: + QTimer *heartbeatTimer; + QDateTime meLastMod; + static QString storage; +}; + + + +class BaselineThread : public QThread +{ + Q_OBJECT + +public: + BaselineThread(int socketDescriptor, QObject *parent); + void run(); + +private: + int socketDescriptor; +}; + + +class BaselineHandler : public QObject +{ + Q_OBJECT + +public: + BaselineHandler(int socketDescriptor); + +private slots: + void receiveRequest(); + void receiveDisconnect(); + +private: + void provideBaseline(const QByteArray &caseId); + void storeImage(const QByteArray &imageBlock, bool isBaseline); + QString pathForCaseId(const QByteArray &caseId, bool isBaseline = true); + + BaselineProtocol proto; + PlatformInfo plat; + bool connectionEstablished; + QString runId; +}; + +#endif // BASELINESERVER_H diff --git a/tests/arthur/baselineserver/src/baselineserver.pro b/tests/arthur/baselineserver/src/baselineserver.pro new file mode 100644 index 0000000..2065d4a --- /dev/null +++ b/tests/arthur/baselineserver/src/baselineserver.pro @@ -0,0 +1,25 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-08-11T11:51:09 +# +#------------------------------------------------- + +QT += core network + +# gui needed for QImage +# QT -= gui + +TARGET = baselineserver +DESTDIR = ../bin +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +include(../../common/baselineprotocol.pri) + +SOURCES += main.cpp \ + baselineserver.cpp + +HEADERS += \ + baselineserver.h diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp new file mode 100644 index 0000000..46048db --- /dev/null +++ b/tests/arthur/baselineserver/src/main.cpp @@ -0,0 +1,16 @@ +#include +#include "baselineserver.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + BaselineServer server; + if (!server.listen(QHostAddress::Any, BaselineProtocol::ServerPort)) { + qWarning("Failed to listen!"); + return 1; + } + + qDebug() << "Listening for connections"; + return a.exec(); +} diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp new file mode 100644 index 0000000..fb4f06d --- /dev/null +++ b/tests/arthur/common/baselineprotocol.cpp @@ -0,0 +1,219 @@ + +#include "baselineprotocol.h" +#include +#include +#include +#include + +PlatformInfo::PlatformInfo(bool useLocal) +{ + if (useLocal) { + buildKey = QLibraryInfo::buildKey(); + qtVersion = QLatin1String(qVersion()); + hostname = QHostInfo::localHostName(); + } +} + +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pinfo) +{ + stream << pinfo.buildKey << pinfo.qtVersion << pinfo.hostname; + return stream; +} + +QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo) +{ + stream >> pinfo.buildKey >> pinfo.qtVersion >> pinfo.hostname; + return stream; +} + +BaselineProtocol::~BaselineProtocol() +{ + socket.close(); + if (socket.state() != QTcpSocket::UnconnectedState) + socket.waitForDisconnected(Timeout); +} + + +bool BaselineProtocol::connect() +{ + errMsg.clear(); + //TBD: determine server address; for now localhost + QLatin1String serverName("localhost"); + + socket.connectToHost(serverName, ServerPort); + + if (!socket.waitForConnected(Timeout)) { + errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); + return false; + } + + PlatformInfo pi(true); + QByteArray block; + QDataStream ds(&block, QIODevice::ReadWrite); + ds << pi; + if (!sendBlock(AcceptPlatformInfo, block)) { + errMsg += QLatin1String("Failed to send data to server."); + return false; + } + + Command cmd = Ack; + if (!receiveBlock(&cmd, &block) || cmd != Ack) { + errMsg += QLatin1String("Failed to get response from server."); + return false; + } + + return true; +} + + +bool BaselineProtocol::acceptConnection(PlatformInfo *pi) +{ + errMsg.clear(); + + QByteArray block; + Command cmd = AcceptPlatformInfo; + if (!receiveBlock(&cmd, &block) || cmd != AcceptPlatformInfo) + return false; + + if (pi) { + QDataStream ds(block); + ds >> *pi; + } + + if (!sendBlock(Ack, QByteArray())) + return false; + return true; +} + + +bool BaselineProtocol::requestBaseline(const QString &caseId, Command *response, QImage *baseline) +{ + errMsg.clear(); + if (!sendBlock(RequestBaseline, caseId.toLatin1())) + return false; + QByteArray imgData; + Command cmd; + if (!receiveBlock(&cmd, &imgData)) + return false; + if (response) + *response = cmd; + if (cmd == BaselineNotPresent || cmd == IgnoreCase) + return true; + else if (cmd == AcceptBaseline) { + if (baseline) { + // hm, get the name also, for checking? + *baseline = QImage::fromData(imgData); + if (baseline->isNull()) { + errMsg.prepend(QLatin1String("Invalid baseline image data received. ")); + return false; + } + } + return true; + } + errMsg.prepend(QLatin1String("Unexpected reply from server on baseline request. ")); + return false; +} + + +bool BaselineProtocol::submitNewBaseline(const QString &caseId, const QImage &baseline) +{ + errMsg.clear(); + QBuffer buf; + buf.open(QIODevice::WriteOnly); + QDataStream ds(&buf); + ds << caseId.toLatin1(); + if (!baseline.save(&buf, FileFormat)) { + errMsg = QLatin1String("Failed to convert new baseline image to ") + QLatin1String(FileFormat); + return false; + } + if (!sendBlock(AcceptNewBaseline, buf.data())) { + errMsg.prepend(QLatin1String("Failed to submit new baseline to server. ")); + return false; + } + Command cmd; + receiveBlock(&cmd, 0); // Just wait for the pong; ignore reply contents + return true; +} + + +bool BaselineProtocol::submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg) +{ + errMsg.clear(); + QBuffer buf; + buf.open(QIODevice::WriteOnly); + QDataStream ds(&buf); + ds << caseId.toLatin1(); + if (!mismatch.save(&buf, FileFormat)) { + errMsg = QLatin1String("Failed to convert mismatched image to ") + QLatin1String(FileFormat); + return false; + } + if (!sendBlock(AcceptMismatch, buf.data())) { + errMsg.prepend(QLatin1String("Failed to submit mismatched image to server. ")); + return false; + } + Command cmd; + if (!receiveBlock(&cmd, failMsg)) { + errMsg.prepend(QLatin1String("Failed to receive response on mismatched image from server. ")); + return false; + } + return true; +} + + +bool BaselineProtocol::sendBlock(Command cmd, const QByteArray &block) +{ + QDataStream s(&socket); + // TBD: set qds version as a constant + s << quint16(ProtocolVersion) << quint16(cmd); + s.writeBytes(block.constData(), block.size()); + return true; +} + + +bool BaselineProtocol::receiveBlock(Command *cmd, QByteArray *block) +{ + while (socket.bytesAvailable() < int(2*sizeof(quint16) + sizeof(quint32))) { + if (!socket.waitForReadyRead(Timeout)) + return false; + } + QDataStream ds(&socket); + quint16 rcvProtocolVersion, rcvCmd; + ds >> rcvProtocolVersion >> rcvCmd; + if (rcvProtocolVersion != ProtocolVersion) { + // TBD: More resilient handling of this case; the server should accept client's version + errMsg = QLatin1String("Server protocol version mismatch, received:") + QString::number(rcvProtocolVersion); + + return false; + } + if (cmd) + *cmd = Command(rcvCmd); + + QByteArray uMsg; + quint32 remaining; + ds >> remaining; + uMsg.resize(remaining); + int got = 0; + char* uMsgBuf = uMsg.data(); + do { + got = ds.readRawData(uMsgBuf, remaining); + remaining -= got; + uMsgBuf += got; + } while (remaining && got >= 0 && socket.waitForReadyRead(Timeout)); + + if (got < 0) + return false; + + if (block) + *block = uMsg; + + return true; +} + + +QString BaselineProtocol::errorMessage() +{ + QString ret = errMsg; + if (socket.error() >= 0) + ret += QLatin1String(" Socket state: ") + socket.errorString(); + return ret; +} diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h new file mode 100644 index 0000000..8740413 --- /dev/null +++ b/tests/arthur/common/baselineprotocol.h @@ -0,0 +1,76 @@ +#ifndef BASELINEPROTOCOL_H +#define BASELINEPROTOCOL_H + +#include +#include + +#define FileFormat "png" + +struct PlatformInfo +{ +public: + PlatformInfo(bool useLocal = false); + + QString buildKey; + QString qtVersion; + QString hostname; +}; + + + +class BaselineProtocol +{ +public: + BaselineProtocol() {} + ~BaselineProtocol(); + + // **************************************************** + // Important constants here + // **************************************************** + enum Constant { + ProtocolVersion = 1, + ServerPort = 54129, + Timeout = 100000 + }; + + enum Command { + UnknownError = 0, + // Queries + AcceptPlatformInfo = 1, + RequestBaseline = 2, + AcceptNewBaseline = 3, + AcceptMismatch = 4, + // Responses + Ack = 128, + AcceptBaseline = 129, + BaselineNotPresent = 130, + IgnoreCase = 131 + }; + + // For client: + bool connect(); + bool requestBaseline(const QString &caseId, Command *response, QImage *baseline); + bool submitNewBaseline(const QString &caseId, const QImage &baseline); + bool submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg); + + // For server: + bool acceptConnection(PlatformInfo *pi); + + QString errorMessage(); + +private: + bool sendBlock(Command cmd, const QByteArray &block); + bool receiveBlock(Command *cmd, QByteArray *block); + QString errMsg; + QTcpSocket socket; + + friend class BaselineThread; + friend class BaselineHandler; +}; + + +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pinfo); + +QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo); + +#endif // BASELINEPROTOCOL_H diff --git a/tests/arthur/common/baselineprotocol.pri b/tests/arthur/common/baselineprotocol.pri new file mode 100644 index 0000000..338339e --- /dev/null +++ b/tests/arthur/common/baselineprotocol.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +QT *= network + +SOURCES += \ + $$PWD/baselineprotocol.cpp + +HEADERS += \ + $$PWD/baselineprotocol.h diff --git a/tests/auto/lancelot/lancelot.pro b/tests/auto/lancelot/lancelot.pro new file mode 100644 index 0000000..d0138bd --- /dev/null +++ b/tests/auto/lancelot/lancelot.pro @@ -0,0 +1,10 @@ +load(qttest_p4) +QT += xml svg +contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl + +SOURCES += tst_lancelot.cpp + +include($$QT_SOURCE_TREE/tests/arthur/common/common.pri) +include($$QT_SOURCE_TREE/tests/arthur/common/baselineprotocol.pri) + +!symbian:!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/lancelot/scripts/aliasing.qps b/tests/auto/lancelot/scripts/aliasing.qps new file mode 100644 index 0000000..59878f9 --- /dev/null +++ b/tests/auto/lancelot/scripts/aliasing.qps @@ -0,0 +1,156 @@ + +path_moveTo convexPath 25 0 +path_lineTo convexPath 50 50 +path_lineTo convexPath 25 25 +path_lineTo convexPath 0 50 +path_closeSubpath convexPath + +pixmap_load border.png pixmap + +setRenderHint LineAntialiasing false +translate 10 10 + +begin_block drawing + setPen black 1 + setBrush 7f7fff + drawPath convexPath + + setFont "monospace" 8 + setPen black + drawText 0 68 "QwErTy@" + + + setPen black 1 + setBrush 7f7fff + drawRect 0 80 10 5 + + setPen black 1 + setBrush noBrush + drawRect 20 80 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 80 10 5 + + + setPen black 2 + setBrush 7f7fff + drawRect 0 90 10 5 + + setPen black 2 + setBrush noBrush + drawRect 20 90 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 90 10 5 + + + setPen black 3 + setBrush 7f7fff + drawRect 0 100 10 5 + + setPen black 3 + setBrush noBrush + drawRect 20 100 10 5 + + setPen noPen + setBrush 7f7fff + drawRect 40 100 10 5 + + + setPen black 1 + setBrush noBrush + drawLine 10 110 20 120 + drawLine 30 120 40 110 + + setPen black 2 + setBrush noBrush + drawLine 10 120 20 130 + drawLine 30 130 40 120 + + setPen black 3 + setBrush noBrush + drawLine 10 130 20 140 + drawLine 30 140 40 130 + + drawPixmap pixmap 0 150 + + setRenderHint SmoothPixmapTransform false + drawPixmap pixmap 20 150 15 15 0 0 10 10 + +end_block + +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +drawText 15 185 "0.0" + +resetMatrix +translate 70.2 10.2 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.2 -0.2 +drawText 15 185 "0.2" + + +resetMatrix +translate 130.4 10.4 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.4 -0.4 +drawText 15 185 "0.4" + + +resetMatrix +translate 190.5 10.5 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.5 -0.5 +drawText 15 185 "0.5" + + +resetMatrix +translate 250.6 10.6 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.6 -0.6 +drawText 15 185 "0.6" + + +resetMatrix +translate 310.8 10.8 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +translate -0.8 -0.8 +drawText 15 185 "0.8" + + +resetMatrix +translate 371 11 +setRenderHint LineAntialiasing false +repeat_block drawing +translate 0 180 +setRenderHint LineAntialiasing true +repeat_block drawing +drawText 15 185 "1.0" + + +resetMatrix +drawText 430 95 "Aliased" +drawText 430 275 "Anti-Aliased" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/arcs.qps b/tests/auto/lancelot/scripts/arcs.qps new file mode 100644 index 0000000..8a7a468 --- /dev/null +++ b/tests/auto/lancelot/scripts/arcs.qps @@ -0,0 +1,68 @@ +# Version: 1 +# CheckVsReference: 5 + +setRenderHint LineAntialiasing + +setPen red + +drawEllipse 0 0 600 400 + +path_moveTo arcs 300 200 +path_arcTo arcs 0 0 600 400 0 10 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 0 0 600 400 20 30 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 0 0 600 400 60 45 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 0 0 600 400 115 60 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 0 0 600 400 180 90 +path_closeSubpath arcs + +path_moveTo arcs 590 200 +path_arcTo arcs 10 10 580 380 0 360 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 20 20 560 360 0 -10 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 20 20 560 360 -20 -30 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 20 20 560 360 -60 -45 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 20 20 560 360 -115 -60 +path_closeSubpath arcs + +path_moveTo arcs 300 200 +path_arcTo arcs 20 20 560 360 -180 -90 +path_closeSubpath arcs + +setPen black 1 solidline +setBrush #3f00ff00 +drawPath arcs + +# Then again with a matrix set... +translate 200 400 +rotate 10 +scale 0.5 0.5 +setPen red +setBrush nobrush +drawEllipse 0 0 600 400 + +setPen black 1 solidline +setBrush #3f0000ff +drawPath arcs \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/arcs2.qps b/tests/auto/lancelot/scripts/arcs2.qps new file mode 100644 index 0000000..411ff08 --- /dev/null +++ b/tests/auto/lancelot/scripts/arcs2.qps @@ -0,0 +1,47 @@ +# Version: 1 +# CheckVsReference: 5 + +drawArc 100 100 100 100 0 1440 +drawArc 100 100 100 100 1440 1440 +drawArc 100 100 100 100 2880 1440 +drawArc 100 100 100 100 4320 1440 + +drawArc 100 200 100 100 0 -1440 +drawArc 100 200 100 100 -1440 -1440 +drawArc 100 200 100 100 -2880 -1440 +drawArc 100 200 100 100 -4320 -1440 + +drawArc 200 100 100 100 720 1440 +drawArc 200 100 100 100 2160 1440 +drawArc 200 100 100 100 3600 1440 +drawArc 200 100 100 100 5040 1440 + +drawArc 200 200 100 100 -720 -1440 +drawArc 200 200 100 100 -2160 -1440 +drawArc 200 200 100 100 -3600 -1440 +drawArc 200 200 100 100 -5040 -1440 + + +drawArc 300 100 100 100 3840 480 +drawArc 300 200 100 100 -3840 -480 + +drawArc 300 100 100 100 1600 1340 + +setPen black +drawArc 400 100 200 200 0 5760 +setPen white +drawArc 400 100 200 200 960 960 +drawArc 400 100 200 200 2880 960 +drawArc 400 100 200 200 4800 960 + +setPen black +drawArc 100 350 300 300 160 5760 +drawArc 100 350 300 300 320 5760 +drawArc 100 350 300 300 1920 5760 +drawArc 100 350 300 300 2080 5760 +drawArc 100 350 300 300 3680 5760 +drawArc 100 350 300 300 3840 5760 +drawArc 100 350 300 300 5440 5760 +drawArc 100 350 300 300 5600 5760 +setPen white +drawArc 100 350 300 300 0 5760 diff --git a/tests/auto/lancelot/scripts/background.qps b/tests/auto/lancelot/scripts/background.qps new file mode 100644 index 0000000..000cfcd --- /dev/null +++ b/tests/auto/lancelot/scripts/background.qps @@ -0,0 +1,136 @@ +# Version: 1 +# CheckVsReference: 5% + +translate 10 30 +setBackground 7f7fff +setBackgroundMode Transparent +setPen ff7f7f + +path_moveTo path 0 0 +path_lineTo path 25 0 +path_cubicTo path 50 0 25 25 25 50 +path_lineTo path 0 50 + +bitmap_load bitmap.png bitmap + +begin_block drawing + save + drawRect 0 0 50 50 + + translate 60 0 + drawEllipse 0 0 50 50 + + translate 60 0 + drawPolygon [0 0 50 0 25 50 25 25] + + translate 60 0 + drawPath path + + translate 60 0 + drawPie 0 0 50 50 1440 2000 + + translate 60 0 + drawChord 0 0 50 50 1440 2000 + + translate 60 0 + drawLine 0 0 50 0 + drawLine 0 0 50 50 + drawLine 0 0 0 50 + + translate 60 0 + drawPolyline [0 0 50 0 25 50 25 25] + + translate 60 0 + drawArc 0 0 50 50 1440 2000 + + translate 60 0 + drawText 0 10 "Jambi-Bambi" + + translate 80 0 + drawPixmap bitmap 0 0 + restore + + save + setRenderHint Antialiasing + translate 5 55 + drawRect 0 0 50 50 + + translate 60 0 + drawEllipse 0 0 50 50 + + translate 60 0 + drawPolygon [0 0 50 0 25 50 25 25] + + translate 60 0 + drawPath path + + translate 60 0 + drawPie 0 0 50 50 1440 2000 + + translate 60 0 + drawChord 0 0 50 50 1440 2000 + + translate 60 0 + drawLine 0 0 50 0 + drawLine 0 0 50 50 + drawLine 0 0 0 50 + + translate 60 0 + drawPolyline [0 0 50 0 25 50 25 25] + + translate 60 0 + drawArc 0 0 50 50 1440 2000 + + translate 60 0 + drawText 0 10 "Jambi-Bambi" + + translate 80 0 + drawPixmap bitmap 0 0 + restore +end_block + +translate 0 160 +setBackgroundMode Transparent +setPen ff7f7f 0 dotline flatcap beveljoin +repeat_block drawing + +translate 0 160 +setBackgroundMode Opaque +setPen ff7f7f 0 dotline flatcap beveljoin +repeat_block drawing + +translate 0 160 +setBackgroundMode Transparent +setPen ff7f7f 4 dashline flatcap beveljoin +repeat_block drawing + +translate 0 160 +setBackgroundMode OpaqueMode +setPen ff7f7f 4 dashline flatcap beveljoin +repeat_block drawing + +resetMatrix + +translate 5 5 + +setBrush nobrush +setPen black +setBackgroundMode transparent +drawText 10 15 "TransparentMode with solid 0-width pen" +drawRect 0 0 685 135 + +translate 0 160 +drawText 10 15 "TransparentMode with dotted 0-width pen" +drawRect 0 0 685 135 + +translate 0 160 +drawText 10 15 "OpaqueMode with dotted 0-width pen" +drawRect 0 0 685 135 + +translate 0 160 +drawText 10 15 "TransparentMode with dotted 4-width pen" +drawRect 0 0 685 135 + +translate 0 160 +drawText 10 15 "OpaqueMode with solid 4-width pen" +drawRect 0 0 685 135 diff --git a/tests/auto/lancelot/scripts/background_brush.qps b/tests/auto/lancelot/scripts/background_brush.qps new file mode 100644 index 0000000..ca1f944 --- /dev/null +++ b/tests/auto/lancelot/scripts/background_brush.qps @@ -0,0 +1,5 @@ +# Version: 1 +# CheckVsReference: 5% + +setBrush #00ff00 crosspattern +import "background.qps" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/beziers.qps b/tests/auto/lancelot/scripts/beziers.qps new file mode 100644 index 0000000..9b47cd0 --- /dev/null +++ b/tests/auto/lancelot/scripts/beziers.qps @@ -0,0 +1,147 @@ +# Version: 1 +# CheckVsReference: 5% + + +setRenderHint LineAntialiasing + +translate 20 20 +path_moveTo fullSize 0 0 +path_cubicTo fullSize 200 100 -100 100 100 0 + +path_moveTo fullSize 0 200 +path_cubicTo fullSize 0 100 100 100 100 200 + +path_moveTo fullSize 0 250 +path_cubicTo fullSize 50 200 50 200 100 250 +drawPath fullSize + +translate 110 0 +scale 10 10 +path_moveTo medSize 0 0 +path_cubicTo medSize 20 10 -10 10 10 0 + +path_moveTo medSize 0 20 +path_cubicTo medSize 0 10 10 10 10 20 + +path_moveTo medSize 0 25 +path_cubicTo medSize 5 20 5 20 10 25 +drawPath medSize + +resetMatrix +translate 240 20 +scale 100 100 +path_moveTo smallSize 0 0 +path_cubicTo smallSize 2 1 -1 1 1 0 + +path_moveTo smallSize 0 2 +path_cubicTo smallSize 0 1 1 1 1 2 + +path_moveTo smallSize 0 2.5 +path_cubicTo smallSize 0.5 2 0.5 2 1 2.5 +drawPath smallSize + +resetMatrix +translate 20 300 +drawPath medSize + +resetMatrix +translate 250 -100 +path_moveTo maxSize 0 500 +path_cubicTo maxSize 1000 0 -500 0 500 500 +drawPath maxSize + +setRenderHint Antialiasing off +resetMatrix + +path_moveTo path1 0 0 +path_cubicTo path1 10 10 0 10 10 0 + +path_moveTo path2 0 0 +path_cubicTo path2 15 15 -5 15 10 0 + +path_moveTo path3 0 0 +path_cubicTo path3 20 20 -10 20 10 0 + +path_moveTo path4 0 0 +path_cubicTo path4 0 5 10 10 0 15 + +path_moveTo path5 0 10 +path_cubicTo path5 10 10 -10 20 0 0 + +path_moveTo path6 0 0 +path_cubicTo path6 10 5 -10 10 0 15 + +setPen black 2 +setBrush nobrush + +translate 10 500 +scale 3 3 +begin_block paths +save +drawPath path1 +translate 20 0 +drawPath path2 +translate 20 0 +drawPath path3 +translate 20 0 +drawPath path4 +translate 20 0 +drawPath path5 +translate 20 0 +drawPath path6 +restore +end_block + +setPen nopen +setBrush black + +translate 0 20 +repeat_block paths + +setRenderHint Antialiasing + +setPen black 2 +setBrush nobrush + +translate 120 -20 +repeat_block paths + +setPen nopen +setBrush black + +translate 0 20 +repeat_block paths + +resetMatrix +path_moveTo miterPath 20 0 +path_cubicTo miterPath 20 20 0 0 1 0 +path_lineTo miterPath -1 -0.2 + +setBrush nobrush + +translate 50 660 +scale 5 5 + +setPen black 4 solidline flatcap miterjoin +drawPath miterPath +setPen red 0 +drawPath miterPath + +path_moveTo miterPath2 21 0.2 +path_lineTo miterPath2 19 0 +path_cubicTo miterPath2 20 0 0 20 0 0 + +translate 30 0 +setPen black 4 solidline flatcap miterjoin +drawPath miterPath2 +setPen red 0 +drawPath miterPath2 + +path_moveTo wonkyPath 0 0 +path_cubicTo wonkyPath 5 15 20 0 17 0 + +translate 30 0 +setPen black 4 solidline flatcap miterjoin +drawPath wonkyPath +setPen red 0 +drawPath wonkyPath diff --git a/tests/auto/lancelot/scripts/bitmaps.qps b/tests/auto/lancelot/scripts/bitmaps.qps new file mode 100644 index 0000000..a816b9d --- /dev/null +++ b/tests/auto/lancelot/scripts/bitmaps.qps @@ -0,0 +1,166 @@ +# Version: 1 +# CheckVsReference: 5% + + +#setRenderHint SmoothPixmapTransform + +translate 10 50 +setBackground ff7f7f +setPen 3f3f9f + +bitmap_load dome_mono.png the_pixmap + +save + # Draw with opaque pen/bg in transparent/opaque mode + setBackgroundMode Transparent + drawPixmap the_pixmap 0 0 + setBackgroundMode Opaque + drawPixmap the_pixmap 110 0 + + translate 220 0 + + # Draw with alpha pen/bg in transparent/opaque mode + save + setBackground 7fff7f7f + setPen 7f3f3f9f + setBackgroundMode Transparent + drawPixmap the_pixmap 0 0 + setBackgroundMode Opaque + drawPixmap the_pixmap 110 0 + restore + + translate 220 0 + + # Draw with rotated opaque pen/bg in transparent/opaque mode + setBackgroundMode Transparent + save + translate 50 50 + rotate 10 + translate -50 -50 + drawPixmap the_pixmap 0 0 + restore + setBackgroundMode Opaque + translate 110 0 + save + translate 50 50 + rotate 10 + translate -50 -50 + drawPixmap the_pixmap 0 0 + restore +restore + +translate 0 150 + +save + setBackgroundMode Transparent + drawTiledPixmap the_pixmap 0 0 200 100 + setBackgroundMode Opaque + drawTiledPixmap the_pixmap 210 0 200 100 + + translate 440 -10 + save + rotate 10 + drawTiledPixmap the_pixmap 0 0 200 100 + restore +restore + +translate 0 150 +save + setBackgroundMode Transparent + drawTiledPixmap the_pixmap 0 0 200 100 10 20 + setBackgroundMode Opaque + drawTiledPixmap the_pixmap 210 0 200 100 10 20 + + translate 440 -10 + save + rotate 10 + drawTiledPixmap the_pixmap 0 0 200 100 10 20 + restore +restore + + +pixmap_setMask the_pixmap mask_100.png +drawPixmap the_pixmap 0 150 +setBackgroundMode Opaque +drawPixmap the_pixmap 110 150 + +translate 220 150 +save + translate 50 50 + rotate 10 + translate -50 -50 + setBackgroundMode Transparent + drawPixmap the_pixmap 0 0 +restore + +translate 110 0 +save + translate 50 50 + rotate 10 + translate -50 -50 + setBackgroundMode Opaque + drawPixmap the_pixmap 0 0 +restore + +resetMatrix +translate 10 650 +bitmap_load dome_mono.png the_bitmap +setBackgroundMode Transparent + +begin_block draw_subrected + drawPixmap the_bitmap 0 0 50 50 0 0 50 50 + drawPixmap the_bitmap 50 0 50 50 50 0 50 50 + drawPixmap the_bitmap 0 50 50 50 0 50 50 50 + drawPixmap the_bitmap 50 50 50 50 50 50 50 50 +end_block + +translate 110 0 +setBackgroundMode Opaque +repeat_block draw_subrected + +translate 110 0 +save + translate 20 -10 + rotate 10 + setBackgroundMode Transparent + repeat_block draw_subrected +restore + +translate 110 0 +save + translate 20 -10 + rotate 10 + setBackgroundMode Opaque + repeat_block draw_subrected +restore + +# Some helpful texts + +resetMatrix +setPen black +drawText 10 40 "Transparent" +drawText 120 40 "Opaque" +drawText 230 40 "Trans w/alpha" +drawText 340 40 "Opaque w/alpha" +drawText 450 40 "Trans w/xform" +drawText 560 40 "Opaque w/xform" + +drawText 10 190 "Transparent tiled" +drawText 220 190 "Opaque tiled" +drawText 440 190 "Opaque w/xform" + +drawText 10 340 "Transparent tiled w/offset" +drawText 220 340 "Opaque tiled w/offset" +drawText 440 340 "Opaque w/xform w/offset" + +drawText 10 490 "Trans masked" +drawText 120 490 "Opaque masked" +drawText 230 490 "masked w/xform" +drawText 340 490 "masked w/xform" + +drawText 10 640 "Subrected" +drawText 110 640 "Subrected opaque" +drawText 220 640 "subrect w/xform" +drawText 330 640 "subrect w/xform opaque" + + diff --git a/tests/auto/lancelot/scripts/borderimage.qps b/tests/auto/lancelot/scripts/borderimage.qps new file mode 100644 index 0000000..ebd4f4d --- /dev/null +++ b/tests/auto/lancelot/scripts/borderimage.qps @@ -0,0 +1,120 @@ +# Version: 1 +# CheckVsReference: 10% + +image_load borderimage.png borderimage +translate -128 -128 +begin_block draw_border +# top +drawImage borderimage 0 0 16 16 0 0 16 16 +drawImage borderimage 16 0 36 16 16 0 32 16 +drawImage borderimage 52 0 16 16 48 0 16 16 +# sides +drawImage borderimage 0 16 16 16 0 16 16 32 +drawImage borderimage 52 16 16 16 48 16 16 32 +#bottom +drawImage borderimage 0 32 16 16 0 48 16 16 +drawImage borderimage 16 32 36 16 16 48 32 16 +drawImage borderimage 52 32 16 16 48 48 16 16 +end_block draw_border +resetMatrix +begin_block draw_column +translate 1 1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +end_block draw_column +setRenderHint Antialiasing +resetMatrix +translate 72 0 +repeat_block draw_column +resetMatrix +scale 1.25 1.25 +translate 144 0 +repeat_block draw_border +resetMatrix +scale 1.25 1.25 +translate 246 0 +rotate 30 +repeat_block draw_border +setRenderHint SmoothPixmapTransform +resetMatrix +scale 1.25 1.25 +translate 144 120 +repeat_block draw_border +resetMatrix +scale 1.25 1.25 +translate 246 120 +rotate 30 +repeat_block draw_border +resetMatrix +translate 215 260 +scale 3.55 3.55 +rotate 30 +repeat_block draw_border +resetMatrix +setRenderHint SmoothPixmapTransform off +setRenderHint Antialiasing off +translate 480 627 +rotate 180 +repeat_block draw_column +resetMatrix +setRenderHint Antialiasing +translate 552 627 +rotate 180 +repeat_block draw_column +resetMatrix +setRenderHint Antialiasing off +translate 200.1 520.1 +begin_block one_pixel_border +drawImage borderimage 0 0 16 16 0 0 16 16 +drawImage borderimage 16 0 64 16 16 0 1 1 +drawImage borderimage 80 0 16 16 48 0 16 16 +drawImage borderimage 0 16 16 64 16 0 1 1 +drawImage borderimage 80 16 16 64 16 0 1 1 +drawImage borderimage 0 80 16 16 0 48 16 16 +drawImage borderimage 16 80 64 16 16 0 1 1 +drawImage borderimage 80 80 16 16 48 48 16 16 +end_block one_pixel_border +resetMatrix +translate 205.1 626.1 +scale 0.4 0.4 +repeat_block one_pixel_border +resetMatrix +translate 255.1 624.1 +scale 0.4 0.4 +rotate 10 +repeat_block one_pixel_border +resetMatrix +setPen red +drawRect 0 0 70 680 +drawText 10 670 "aa off" +drawRect 72 0 70 680 +drawText 80 670 "aa on" +drawRect 409 0 70 680 +drawText 419 650 "rot 180" +drawText 419 670 "aa off" +drawRect 481 0 70 680 +drawText 491 650 "rot 180" +drawText 491 670 "aa on" +drawRect 164 0 224 124 +drawText 174 114 "smoothpixmaptransform off" +drawRect 164 128 224 134 +drawText 174 252 "smoothpixmaptransform on" +drawRect 200 520 97 188 +drawText 210 698 "1x1 edges" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/brush_pens.qps b/tests/auto/lancelot/scripts/brush_pens.qps new file mode 100644 index 0000000..b9a2bc0 --- /dev/null +++ b/tests/auto/lancelot/scripts/brush_pens.qps @@ -0,0 +1,104 @@ +# Version: 1 +# CheckVsReference: 5% + +path_addRect p 0 0 75 75 +path_addEllipse p 25 25 75 75 + +translate 10 10 + +begin_block setup_gradient + gradient_clearStops + gradient_appendStop 0 red + gradient_appendStop 0.1 blue + gradient_appendStop 0.2 yellow + gradient_appendStop 0.3 cyan + gradient_appendStop 0.4 magenta + gradient_appendStop 0.5 green + gradient_appendStop 0.6 black + gradient_appendStop 0.7 indianred + gradient_appendStop 0.8 white + gradient_appendStop 0.9 orange + gradient_appendStop 1 blue + gradient_setLinear 0 0 100 100 +end_block + +setPen brush 0 +setBrush nobrush + +begin_block drawing + save + drawLine 0 0 100 100 + + translate 0 100 + drawPath p + + translate 0 110 + drawRect 0 0 100 100 + + translate 0 110 + drawPolyline [0 0 100 0 50 50] + + drawPoint 40 40 + drawPoint 41 40 + drawPoint 42 40 + drawPoint 43 40 + drawPoint 44 40 + drawPoint 45 40 + drawPoint 46 40 + drawPoint 47 40 + drawPoint 48 40 + drawPoint 49 40 + drawPoint 50 40 + + restore +end_block + +save + translate 110 0 + save + setRenderHint Antialiasing + repeat_block drawing + restore + + setBrush dome_rgb32.png + setPen brush 0 + setBrush nobrush + + translate 110 0 + repeat_block drawing + + translate 110 0 + save + setRenderHint Antialiasing + repeat_block drawing + restore +restore + +translate 0 0 + +save + repeat_block setup_gradient + setPen brush 5 + setBrush nobrush + translate 0 350 + repeat_block drawing + + translate 110 0 + save + setRenderHint Antialiasing + repeat_block drawing + restore + + setBrush dome_rgb32.png + setPen brush 5 + setBrush nobrush + + translate 110 0 + repeat_block drawing + + translate 110 0 + save + setRenderHint Antialiasing + repeat_block drawing + restore +restore \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/brushes.qps b/tests/auto/lancelot/scripts/brushes.qps new file mode 100644 index 0000000..82cbff4 --- /dev/null +++ b/tests/auto/lancelot/scripts/brushes.qps @@ -0,0 +1,79 @@ +# Version: 1 +# CheckVsReference: 5% + +# Fill the background +drawRect 0 0 width height + +setRenderHint Antialiasing +setRenderHint SmoothPixmapTransform + +translate 10 10 +# Draw all the pattern types as 40x40 rects using green, transparent background +begin_block drawrects +setBrush green Dense1Pattern +drawRect 0 0 40 40 +setBrush green Dense2Pattern +drawRect 40 0 40 40 +setBrush green Dense3Pattern +drawRect 80 0 40 40 +setBrush green Dense4Pattern +drawRect 120 0 40 40 +setBrush green Dense5Pattern +drawRect 160 0 40 40 +setBrush green Dense6Pattern +drawRect 200 0 40 40 +setBrush green Dense7Pattern +drawRect 240 0 40 40 +setBrush green HorPattern +drawRect 280 0 40 40 +setBrush green VerPattern +drawRect 320 0 40 40 +setBrush green CrossPattern +drawRect 360 0 40 40 +setBrush green BDiagPattern +drawRect 400 0 40 40 +setBrush green FDiagPattern +drawRect 440 0 40 40 +setBrush green DiagCrossPattern +drawRect 480 0 40 40 +setBrush green SolidPattern +drawRect 520 0 40 40 +setBrush green NoBrush +drawRect 560 0 40 40 +gradient_setLinear 0 0 0 40 +drawRect 600 0 40 40 +setBrush face.png +drawRect 640 0 80 40 +end_block + +# Switch to opaque mode +setBackground #7fff7f +setBackgroundMode OpaqueMode +translate 0 50 + +# Draw all the pattern types as 40x40 rects using green, opaque background +repeat_block drawrects + +translate 50 50 +rotate 10 + + +setBackgroundMode TransparentMode +repeat_block drawrects +setBackgroundMode OpaqueMode +translate 0 40 +repeat_block drawrects + + +setBrush dot.png +setPen nopen +resetMatrix +drawRect 0 200 50 50 +drawRect 50 200 50 50 + +setPen red +setBrushOrigin 0 250 +drawRect 0 250 50 50 +setBrushOrigin 50 250 +drawRect 50 250 50 50 + diff --git a/tests/auto/lancelot/scripts/clippaths.qps b/tests/auto/lancelot/scripts/clippaths.qps new file mode 100644 index 0000000..fba8978 --- /dev/null +++ b/tests/auto/lancelot/scripts/clippaths.qps @@ -0,0 +1,60 @@ +# Version: 1 +# CheckVsReference: 5% + +path_addRect hor 0 0 50 10 +path_addRect ver 0 0 10 50 + +translate 10 10 +setPen NoPen + +begin_block clipping +save + + setBrush 0x7f7fff + save + setClipPath hor + drawRect 0 0 100 100 + + setClipPath ver IntersectClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + + translate 100 0 + save + setClipPath hor + drawRect 0 0 100 100 + + setClipPath ver ReplaceClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + + translate 100 0 + save + setClipPath hor + drawRect 0 0 100 100 + + setClipPath ver UniteClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + +restore +end_block + +translate 300 0 +setRenderHint Antialiasing +repeat_block clipping + +translate -300 100 +setRenderHint Antialiasing false +scale 1.2 1.2 +repeat_block clipping + +translate 300 0 +setRenderHint Antialiasing +setRenderHint SmoothPixmapTransform +repeat_block clipping + + diff --git a/tests/auto/lancelot/scripts/clipping.qps b/tests/auto/lancelot/scripts/clipping.qps new file mode 100644 index 0000000..3694ff2 --- /dev/null +++ b/tests/auto/lancelot/scripts/clipping.qps @@ -0,0 +1,182 @@ +# Version: 1 +# CheckVsReference: 5% + +region_addRect clip 50 0 90 190 +region_addRect clip 0 50 180 90 + +region_addRect clip2 30 30 60 60 + +region_addRect clip3 10 10 60 60 + +path_cubicTo path 90 0 50 50 90 90 +path_cubicTo path 0 90 50 50 0 0 + +path_addRect path2 0 0 90 90 +path_moveTo path2 90 45 +path_arcTo path2 0 0 90 90 0 -360 + +path_addRect emptypath 0 0 0 0 +region_addRect emptyregion 0 0 0 0 + +# Normal clip rect +setClipRect 0 0 50 150 +begin_block repaint +save +setBrush red +setPen nopen +resetMatrix +region_getClipRegion tmpclip +path_getClipPath tmpclippath +drawRect 0 0 width height +setBrush #3f0000ff +setClipRegion tmpclip +drawRect 0 0 width height +setClipPath tmpclippath +setBrush #3f00ff00 +drawRect 0 0 width height +restore +end_block + +# Rotated clip rect +translate 100 0 +rotate 10 +setClipRect 0 0 50 150 +repeat_block repaint + +# simple clip region +resetMatrix +translate 0 200 +setClipRegion clip +repeat_block repaint + +# simle rotated clip region +translate 250 -10 +rotate 10 +setClipRegion clip +repeat_block repaint + +# verify that clip is not xformed with painter +resetMatrix +translate 200 0 +setClipRegion clip +rotate 30 +setBrush red +setPen nopen +drawRect 0 0 width height + +resetMatrix +translate 0 400 +save +setClipRegion clip +setClipRegion clip2 IntersectClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipRegion clip +setClipRegion clip2 IntersectClip +restore + +translate 100 0 +save +setClipRegion clip3 +setClipRegion clip2 UniteClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipRegion clip3 +setClipRegion clip2 UniteClip +repeat_block repaint +restore + +translate 100 0 +save +setClipPath path +repeat_block repaint +translate 50 100 +rotate 45 +setClipPath path +repeat_block repaint +restore + +translate 100 0 +save +setClipPath path +setClipPath path2 IntersectClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipPath path +setClipPath path2 IntersectClip +repeat_block repaint +restore + +translate 100 0 +save +setClipPath path +setClipPath path2 UniteClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipPath path +setClipPath path2 UniteClip +repeat_block repaint +restore + +translate 100 0 +save +setClipPath path +setClipRegion clip3 IntersectClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipRegion clip3 +setClipPath path IntersectClip +repeat_block repaint +restore + +translate 100 0 +save +setClipPath path +setClipRegion clip3 UniteClip +repeat_block repaint +translate 0 100 +rotate 10 +setClipRegion clip3 +setClipPath path UniteClip +repeat_block repaint +restore + +# test that an empty region is not drawn. +resetMatrix +setClipRegion emptyregion +setBrush #3f00ff00 +drawRect 0 0 300 300 +drawText 50 50 "Text should be clipped away by region" +setClipping false + +setClipPath emptypath +setBrush #3fffff00 +drawRect 50 50 300 300 +drawText 70 80 "Text should be clipped away by path" + +# Test that we can extract a clipregion when a matrix is set too +resetMatrix +translate 500 10 +scale 2 1 +setBrush blue +setClipping false +rotate 5 +drawRect 0 0 100 100 +setClipRect 0 0 100 100 +resetMatrix +rotate 10 +region_getClipRegion xclip +setClipRegion xclip +resetMatrix +setBrush #7f00ff00 +drawRect 0 0 width height + +# the below used to assert in debug mode +setClipRect 10 10 20 20 +setClipping false +setClipping true \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/clipping_state.qps b/tests/auto/lancelot/scripts/clipping_state.qps new file mode 100644 index 0000000..a29d373 --- /dev/null +++ b/tests/auto/lancelot/scripts/clipping_state.qps @@ -0,0 +1,47 @@ +# Version: 1 +# CheckVsReference: 5% + +path_addRect path1 10 10 50 50 +path_addRect path2 30 30 50 50 +# enable/disable a clip path +setPen nopen +setBrush red +setClipPath path1 +setClipPath path2 UniteClip +drawRect 0 0 100 100 +setClipping false +setBrush #630000ff +drawRect 0 0 100 100 +setClipping true +setBrush #6300ff00 +drawRect 0 0 100 100 +# enable/disable noclip +translate 150 0 +setClipPath path1 NoClip +setClipping false +setBrush #630000ff +drawRect 0 0 100 100 +setClipping true +setBrush #6300ff00 +drawRect 25 25 50 50 +# enable/disable full clipping +translate 150 0 +path_addRect path3 0 0 10 10 +path_addRect path4 20 20 10 10 +setClipPath path3 +setClipPath path4 IntersectClip +setClipping false +setBrush #630000ff +drawRect 0 0 100 100 +setClipping true +setBrush #6300ff00 +drawRect 25 25 50 50 +# disable clipping followed by setClipRect +translate 150 0 +setClipRect 0 0 50 50 ReplaceClip +setClipping false +setBrush #630000ff +drawRect 0 0 100 100 +setClipRect 25 25 75 75 IntersectClip +setBrush #6300ff00 +drawRect 25 25 50 50 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/cliprects.qps b/tests/auto/lancelot/scripts/cliprects.qps new file mode 100644 index 0000000..0d28b03 --- /dev/null +++ b/tests/auto/lancelot/scripts/cliprects.qps @@ -0,0 +1,59 @@ +# Version: 1 +# CheckVsReference: 5% + + + +translate 10 10 +setPen NoPen + +begin_block clipping +save + + setBrush 0x7f7fff + save + setClipRect 0 0 50 10 + drawRect 0 0 100 100 + + setClipRect 0 0 10 50 IntersectClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + + translate 100 0 + save + setClipRect 0 0 50 10 + drawRect 0 0 100 100 + + setClipRect 0 0 10 50 ReplaceClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + + translate 100 0 + save + setClipRect 0 0 50 10 + drawRect 0 0 100 100 + + setClipRect 0 0 10 50 UniteClip + setBrush black CrossPattern + drawRect 0 0 100 100 + restore + +restore +end_block + +translate 300 0 +setRenderHint Antialiasing +repeat_block clipping + +translate -300 100 +setRenderHint Antialiasing false +scale 1.2 1.2 +repeat_block clipping + +translate 300 0 +setRenderHint Antialiasing +setRenderHint SmoothPixmapTransform +repeat_block clipping + + diff --git a/tests/auto/lancelot/scripts/conical_gradients.qps b/tests/auto/lancelot/scripts/conical_gradients.qps new file mode 100644 index 0000000..2e897b1 --- /dev/null +++ b/tests/auto/lancelot/scripts/conical_gradients.qps @@ -0,0 +1,85 @@ +# Version: 1 +# CheckVsReference: 5% + +path_addRect path 300 0 80 80 +path_addEllipse path 340 40 60 60 + +setRenderHint Antialiasing + +setPen black + +begin_block gradients +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setConical 40 40 50 +drawRect 0 0 100 100 + +gradient_setConical 140 40 230 +drawEllipse 100 0 100 100 + +gradient_clearStops +gradient_appendStop 0 3f7f7fff +gradient_appendStop 0.5 dfdfffff +gradient_appendStop 1 7f00007f + +gradient_setConical 240 40 50 +drawPolygon [200 0 290 0 250 99] + +gradient_setConical 340 40 230 +drawPath path + +end_block + +translate 0 100 +scale 1 2 +repeat_block gradients + +resetMatrix +translate 0 300 +brushTranslate 30 0 +brushScale 0.9 0.9 +brushRotate 20 +repeat_block gradients + +# Some helpful info perhaps? +resetMatrix +setPen black + +drawText 410 50 "No XForm" +drawText 410 200 "scale 1x2" +drawText 410 300 "brush transform" +drawText 10 450 "50 deg" +drawText 110 450 "230 deg" +drawText 210 450 "50 deg w/alpha " +drawText 310 450 "230 deg w/alpha" + +setPen 3f000000 +setBrush nobrush + +begin_block ellipse_draw + setClipRect 0 0 100 100 + drawEllipse 35 35 11 11 + save + translate 40 40 + rotate -50 + drawLine -100 0 100 0 + restore + translate 100 0 +end_block + +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw + +resetMatrix +translate 0 100 +scale 1 2 +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/conical_gradients_perspectives.qps b/tests/auto/lancelot/scripts/conical_gradients_perspectives.qps new file mode 100644 index 0000000..a9c14f1 --- /dev/null +++ b/tests/auto/lancelot/scripts/conical_gradients_perspectives.qps @@ -0,0 +1,64 @@ +# Version: 1 +# CheckVsReference: 5% + + +setRenderHint Antialiasing + +setPen #00ff00 + +translate 10 10 +# standard draw +begin_block gradient +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 0.9 cyan +gradient_appendStop 1 red + +gradient_setSpread PadSpread +gradient_setConical 140 140 100 +drawRect 0 0 300 300 +end_block gradient + +# Rotation w/o smooth xform +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 50 0 200 300 300 300 0 + repeat_block gradient +restore +restore + +translate 0 320 + +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 100 300 200 300 300 0 + repeat_block gradient +restore + +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 0 300 300 250 300 50 + repeat_block gradient +restore +restore + + +resetMatrix +setPen black +translate 125 20 +drawText 0 0 "No transform" +translate 350 0 +drawText 0 0 "Left Tilted" +resetMatrix +translate 125 350 +drawText 0 0 "Bottom Tilted" +translate 350 0 +drawText 0 0 "Right Tilted" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/dashes.qps b/tests/auto/lancelot/scripts/dashes.qps new file mode 100644 index 0000000..649f56c --- /dev/null +++ b/tests/auto/lancelot/scripts/dashes.qps @@ -0,0 +1,268 @@ +# Version: 1 +# CheckVsReference: 5% + +translate 20 20 + +begin_block draw +save + save + setPen black 1 SolidLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 SolidLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 SolidLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 SolidLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 SolidLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 SolidLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 6 SolidLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 SolidLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 SolidLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + + + translate 100 0 + save + setPen black 1 DotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 DotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 6 DotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + + translate 100 0 + save + setPen black 1 DashLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 DashLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 6 DashLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DashLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DashLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + + translate 100 0 + + save + setPen black 1 DashDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 DashDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 6 DashDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DashDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 6 DashDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + + translate 100 0 + + save + setPen black 1 DashDotDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashDotDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 DashDotDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 DashDotDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashDotDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 DashDotDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 4 DashDotDotLine FlatCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 4 DashDotDotLine SquareCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 4 DashDotDotLine RoundCap BevelJoin + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + + translate 100 0 + + save + setPen black 1 SolidLine FlatCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 SolidLine SquareCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 1 SolidLine RoundCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 2 SolidLine FlatCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 SolidLine SquareCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 2 SolidLine RoundCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + + setPen black 4 SolidLine FlatCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 4 SolidLine SquareCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + setPen black 4 SolidLine RoundCap BevelJoin + pen_setDashPattern [1 4 9 4 27 4] + drawPolyline [0 0 80 0 80 30 40 20 0 30] + translate 0 40 + restore + +restore +end_block + +translate 0 400 +setRenderHint Antialiasing +repeat_block draw + +translate 0 -20 +drawText 30 0 "Solid" + +translate 100 0 +drawText 20 0 "DotLine" + +translate 100 0 +drawText 10 0 "DashLine" + +translate 100 0 +drawText 0 0 "DashDotLine" + +translate 100 0 +drawText 0 0 "DashDotDotLine" + +translate 100 0 +drawText 0 0 "CustomDashLine" + +resetMatrix + +translate 620 40 + +begin_block width_and_caps_texts + drawText 0 0 "Width=1, FlatCap" + translate 0 40 + drawText 0 0 "Width=1, SquareCap" + translate 0 40 + drawText 0 0 "Width=1, RoundCap" + translate 0 40 + drawText 0 0 "Width=2, FlatCap" + translate 0 40 + drawText 0 0 "Width=2, SquareCap" + translate 0 40 + drawText 0 0 "Width=2, RoundCap" + translate 0 40 + drawText 0 0 "Width=6, FlatCap" + translate 0 40 + drawText 0 0 "Width=6, SqareCap" + translate 0 40 + drawText 0 0 "Width=6, RoundCap" +end_block + +translate 0 80 +repeat_block width_and_caps_texts \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/degeneratebeziers.qps b/tests/auto/lancelot/scripts/degeneratebeziers.qps new file mode 100644 index 0000000..fb223d5 --- /dev/null +++ b/tests/auto/lancelot/scripts/degeneratebeziers.qps @@ -0,0 +1,10 @@ +# Version: 1 +# CheckVsReference: 5% + +path_moveTo degenerate 3427.0918499999997948 3872.1318999999998596 +path_cubicTo degenerate 3427.0918499999997948 3872.1318999999994048 4729.4590867905308187 5176.8613451144155988 5389.9325499999995372 5837.8072499999998399 + +scale 0.05 0.05 +translate -2500 -3000 +setPen black 800 +drawPath degenerate \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/deviceclipping.qps b/tests/auto/lancelot/scripts/deviceclipping.qps new file mode 100644 index 0000000..cedfc1e --- /dev/null +++ b/tests/auto/lancelot/scripts/deviceclipping.qps @@ -0,0 +1,48 @@ +# Version: 1 +# CheckVsReference: 5% + +setBrush 0xff7f7f +setPen 0x7f0000 + +path_moveTo path -1000000 10000 +path_cubicTo path 100 100 100 150 150 400 +path_closeSubpath path + +begin_block drawing + + drawPath ellipse + + drawLine -1000000 200 200 200 + drawLine 200 -1000000 200 200 + drawLine 200 200 1000000 200 + drawLine 200 200 200 1000000 + drawLine -1000000 -1000000 200 200 + + drawPolygon [-1000000 100 100 -1000000 100 100] + drawRect 300 -500000 1000000 1000000 + + drawPath path + +end_block + +save +translate 20 20 +setBrush #0x7f7f7fff +setPen #0x7f00007f +repeat_block drawing + +translate 20 20 +setRenderHint Antialiasing +setBrush #0x7f7fff7f +setPen #0x7f007f00 +repeat_block drawing +restore + +setPen 0x00007f 2 +setRenderHint Antialiasing + +drawLine 0 -200 200 200 + +setPen 0x007f00 10 + +drawLine 0 -200 200 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/drawpoints.qps b/tests/auto/lancelot/scripts/drawpoints.qps new file mode 100644 index 0000000..c02cd85 --- /dev/null +++ b/tests/auto/lancelot/scripts/drawpoints.qps @@ -0,0 +1,101 @@ +# Version: 1 +# CheckVsReference: 5% + +#setRenderHint Antialiasing + +setPen red 0 solidline +begin_block points +drawPoint 00 00 +drawPoint 10 00 +drawPoint 20 00 +drawPoint 30 00 +drawPoint 40 00 +drawPoint 50 00 +drawPoint 00 10 +drawPoint 10 10 +drawPoint 20 10 +drawPoint 30 10 +drawPoint 40 10 +drawPoint 50 10 +drawPoint 00 20 +drawPoint 10 20 +drawPoint 20 20 +drawPoint 30 20 +drawPoint 40 20 +drawPoint 50 20 +drawPoint 00 30 +drawPoint 10 30 +drawPoint 20 30 +drawPoint 30 30 +drawPoint 40 30 +drawPoint 50 30 +drawPoint 00 40 +drawPoint 10 40 +drawPoint 20 40 +drawPoint 30 40 +drawPoint 40 40 +drawPoint 50 40 +drawPoint 00 50 +drawPoint 10 50 +drawPoint 20 50 +drawPoint 30 50 +drawPoint 40 50 +drawPoint 50 50 +end_block points + +translate 100 0 +setPen blue 1 solidline +repeat_block points + +translate 100 0 +setPen green 5 solidline roundcap +repeat_block points + +resetMatrix + +translate 0 100 +scale 3 3 +setPen red 0 solidline roundcap +repeat_block points + +translate 60 0 +setPen blue 1 solidline roundcap +repeat_block points + +translate 60 0 +setPen green 5 solidline roundcap +repeat_block points + +resetMatrix + +translate 0 300 +scale 3 3 +setPen red 0 solidline flatcap +repeat_block points + +translate 60 0 +setPen blue 1 solidline flatcap +repeat_block points + +translate 60 0 +setPen green 5 solidline flatcap +repeat_block points + +resetMatrix +translate 10 500 +setPen black 1 solidline flatcap +drawPoint 0 0 +setPen black 2 solidline flatcap +drawPoint 3 0 +setPen black 3 solidline flatcap +drawPoint 8 0 +setPen black 4 solidline flatcap +drawPoint 15 0 +setPen black 5 solidline flatcap +drawPoint 24 0 +setPen black 6 solidline flatcap +drawPoint 35 0 +setPen black 7 solidline flatcap +drawPoint 48 0 +setPen black 8 solidline flatcap +drawPoint 63 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/ellipses.qps b/tests/auto/lancelot/scripts/ellipses.qps new file mode 100644 index 0000000..e2cffd7 --- /dev/null +++ b/tests/auto/lancelot/scripts/ellipses.qps @@ -0,0 +1,86 @@ +# Version: 1 +# CheckVsReference: 5% + + +surface_begin 0 0 600 600 +translate 0 50 + +setPen nopen +setBrush 0x7f000000 +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setRadial 20 20 220 200 + +drawEllipse 10 10 80 80 +drawEllipse 50 50 120 90 + +translate 100 0 +brushTranslate 40 20 +brushScale 0.25 0.25 + +setPen black + +drawEllipse 10 10 80 80 +setOpacity 0.5 +setCompositionMode SourceIn +drawEllipse 50 50 120 90 +setOpacity 1.0 +setRenderHint Antialiasing +setCompositionMode Xor +brushTranslate 70 0 +translate 100 0 +drawEllipse 10 10 80 80 + +setPen nopen +drawEllipse 50 50 120 90 + +setOpacity 0.7 +setBrush red +translate 100 0 +setCompositionMode SourceOver + +drawEllipse 10 10 80 80 + +setOpacity 0.6 +setPen black 5.0 +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setLinear 20 20 120 100 +drawEllipse 50 50 120 90 + + +translate 100 0 + +setOpacity 1.0 +drawEllipse 10 10 80 80 + +setCompositionMode SourceIn +setOpacity 0.7 +setPen black 3.0 +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setLinear 50 50 80 90 +drawEllipse 50 50 120 90 + +surface_end + +drawText 200 220 "Testing Ellipse drawing with varios combinations" +drawText 200 240 "of features such as brushes, pens and composition modes" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/filltest.qps b/tests/auto/lancelot/scripts/filltest.qps new file mode 100644 index 0000000..2eeba2e --- /dev/null +++ b/tests/auto/lancelot/scripts/filltest.qps @@ -0,0 +1,413 @@ +# Version: 1 +# CheckVsReference: 5% + +setPen nopen +setBrush red +translate 0 4 +begin_block polys +drawPolygon [0 0 2 -2 4 0] +drawPolygon [0 2 2 4 4 2] +end_block polys +translate 6 .5 +repeat_block polys +translate 6.5 0 +repeat_block polys +translate 6 .5 +repeat_block polys + +resetMatrix + +translate 0 12 +setPen black +drawPolygon [0 0 5 0 5 5 0 5] + +translate 10 0 +setPen nopen +drawPolygon [0 0 5 0 5 5 0 5] + +translate 10 0 +drawPolygon [0 0 5 0 5 5 0 5] + +setBrush black +path_addRect stroke -.5 -.5 6 6 +path_addRect stroke .5 .5 4 4 +drawPath stroke + +resetMatrix + +translate 0 65 + +setPen red +drawText 0 0 "path" +drawText 40 0 "rect" +drawText 80 0 "img" +drawText 120 0 "pix" +drawText 160 0 "brush" +setPen nopen + +translate 0 5 + +image_load border.png img +pixmap_load border.png pix + +path_addRect rect 0 0 10 10 +begin_block rects +drawPath rect +drawRect 40 0 10 10 +drawImage img 80 0 +drawPixmap pix 120 0 +setBrush border.png +drawRect 160 0 10 10 +setBrush black +end_block rects + +setPen red +drawText 180 10 "0.0" +setPen nopen + +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.1" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.2" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.3" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.4" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.5" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.6" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.7" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.8" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "0.9" +setPen nopen +translate 0.1 20 +repeat_block rects +setPen red +drawText 180 10 "1.0" +setPen nopen + +resetMatrix + +translate 0 400 + +setPen red +drawText 0 10 "path" +drawText 0 30 "rect" +drawText 0 50 "img" +drawText 0 70 "pix" +drawText 0 90 "brush" +drawText 0 110 "stroke" +drawText 0 130 "scale" +drawText 0 170 "rotate" +setPen nopen + +translate 50 0 + +begin_block rects +drawPath rect +drawRect 0 20 10 10 +drawImage img 0 40 +drawPixmap pix 0 60 +save +setBrush border.png +drawRect 0 80 10 10 +translate 0 100 +setBrush red +setPen black +drawRect 0 0 10 10 +setBrush border.png +setPen nopen +translate 0 20 +scale 2 2 +drawRect 0 0 10 10 +translate 10 20 +rotate 90 +drawRect 0 0 10 10 +restore +end_block rects + +setPen red +drawText -5 -10 "0.0" +setPen nopen + +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.1" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.2" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.3" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.4" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.5" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.6" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.7" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.8" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "0.9" +setPen nopen +translate 40 0.1 +repeat_block rects +setPen red +drawText -5 -10 "1.0" +setPen nopen + +resetMatrix + +translate 0 620 + +setPen red +drawText 0 10 "path" +setPen nopen + +path_addRect rect2 -5 -5 10 10 + +translate 55 5 +drawPath rect2 + +translate 20 0 +rotate 10 +drawPath rect2 +rotate -10 +translate 20 0 +rotate 20 +drawPath rect2 +rotate -20 +translate 20 0 +rotate 30 +drawPath rect2 +rotate -30 +translate 20 0 +rotate 40 +drawPath rect2 +rotate -40 +translate 20 0 +rotate 50 +drawPath rect2 +rotate -50 +translate 20 0 +rotate 60 +drawPath rect2 +rotate -60 +translate 20 0 +rotate 70 +drawPath rect2 +rotate -70 +translate 20 0 +rotate 80 +drawPath rect2 +rotate -80 +translate 20 0 +rotate 90 +drawPath rect2 +rotate -90 + +resetMatrix + +translate 0 600 + +setPen red +drawText 0 10 "rect" +setPen nopen + +translate 55 5 +drawRect -5 -5 10 10 + +translate 20 0 +rotate 10 +drawRect -5 -5 10 10 +rotate -10 +translate 20 0 +rotate 20 +drawRect -5 -5 10 10 +rotate -20 +translate 20 0 +rotate 30 +drawRect -5 -5 10 10 +rotate -30 +translate 20 0 +rotate 40 +drawRect -5 -5 10 10 +rotate -40 +translate 20 0 +rotate 50 +drawRect -5 -5 10 10 +rotate -50 +translate 20 0 +rotate 60 +drawRect -5 -5 10 10 +rotate -60 +translate 20 0 +rotate 70 +drawRect -5 -5 10 10 +rotate -70 +translate 20 0 +rotate 80 +drawRect -5 -5 10 10 +rotate -80 +translate 20 0 +rotate 90 +drawRect -5 -5 10 10 +rotate -90 + +resetMatrix +path_addRect vertical 0.1 0.1 0.2 10 + +translate 0 320 +drawPath vertical +translate 2.2 0 +drawPath vertical +translate 2.2 0 +drawPath vertical +translate 2.2 0 +drawPath vertical +translate 2.2 0 +drawPath vertical + +resetMatrix +path_addRect horizontal 0.1 0.1 10 0.2 + +translate 0 340 +drawPath horizontal +translate 0 2.2 +drawPath horizontal +translate 0 2.2 +drawPath horizontal +translate 0 2.2 +drawPath horizontal +translate 0 2.2 +drawPath horizontal + +setOpacity 0.8 +resetMatrix + +translate 0.1 24.7 +translate 400 0 +#rotate 88.8 +rotate 89.9 +setBrush red +drawPolygon [0 0 300 0 0 173] +setBrush green +drawPolygon [0 173 300 0 300 173] + +resetMatrix + +translate 410 24 +path_lineTo left 0 273 +path_lineTo left 300 273 +path_cubicTo left 50 273 250 0 0 0 + +path_cubicTo right 250 0 50 273 300 273 +path_lineTo right 300 0 + +translate 310 0 +rotate 90 +setBrush red +drawPath left +setBrush green +drawPath right + +resetMatrix +translate 0.1 680.1 +setPen red +setOpacity 1 +drawText 115 -20 "0.1" +drawText 0 0 "pixmap w/ opacity" +setOpacity 0.6 +drawPixmap pix 120 -10 +translate 0 20 +setOpacity 1 +drawText 0 0 "image w/ opacity" +setOpacity 0.6 +drawImage img 120 -10 + +resetMatrix +path_lineTo fillpath 0 50 +path_lineTo fillpath 50 50 +path_moveTo fillpath 70 50 +path_lineTo fillpath 70 100 +path_lineTo fillpath 40 100 +translate 500 400 +drawPath fillpath + +resetMatrix +path_moveTo vectorarne 50 10 +path_lineTo vectorarne 50 50 +path_lineTo vectorarne 100 50 +path_addEllipse vectorarne 350 20 230 230 +path_moveTo vectorarne 500 500 +path_cubicTo vectorarne 20 20 250 30 50 150 +translate 500 550 +scale 0.4 0.4 +setRenderHint antialiasing +drawPath vectorarne + +resetMatrix +translate 200 730 +setRenderHint antialiasing off +setOpacity 1 +setPen red +drawText 0 0 "outline/fill consistency" +setPen red +setBrush green +translate 80 -30 +drawPolygon [13.6965 -99.1837 -71.4767 13.823 32.4596 -33.1847] \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/gradients.qps b/tests/auto/lancelot/scripts/gradients.qps new file mode 100644 index 0000000..eb3cda9 --- /dev/null +++ b/tests/auto/lancelot/scripts/gradients.qps @@ -0,0 +1,44 @@ +# Version: 1 +# CheckVsReference: 5% + +drawText 75 20 "Linear" +drawText 176 20 "Radial" +drawText 277 20 "Conical" +translate 0 30 +drawText 0 50 "AA off" +drawText 0 151 "AA on" + +setPen nopen + +gradient_clearStops +gradient_appendStop 0 0x00000000 +gradient_appendStop 0.001 red +gradient_appendStop 0.2 blue +gradient_appendStop 0.4 yellow +gradient_appendStop 0.6 cyan +gradient_appendStop 0.8 green +gradient_appendStop 0.999 red +gradient_appendStop 1 0x00000000 + +gradient_setSpread PadSpread +gradient_setCoordinateMode ObjectBoundingMode + +begin_block row +save +gradient_setLinear 0.1 0.0 0.9 0.0 +drawRect 50 0 100 100 + +gradient_setRadial 0.5 0.5 0.5 0.5 0.5 +translate 101 0 +drawRect 50 0 100 100 + +gradient_setConical 0.5 0.5 45 +translate 101 0 +drawRect 50 0 100 100 +restore +end_block row + +setRenderHint Antialiasing + +translate 0 101 +repeat_block row \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/image_formats.qps b/tests/auto/lancelot/scripts/image_formats.qps new file mode 100644 index 0000000..d817d04 --- /dev/null +++ b/tests/auto/lancelot/scripts/image_formats.qps @@ -0,0 +1,81 @@ +# Version: 1 +# CheckVsReference: 5% + + +image_load dome_argb32.png the_pixmap +image_convertToFormat the_pixmap the_pixmap ARGB32_Premultiplied + +begin_block draw_stuff + save + image_convertToFormat the_pixmap converted ARGB32_Premultiplied + drawImage converted 0 0 + translate 0 110 + + image_convertToFormat the_pixmap converted ARGB32 + drawImage converted 0 0 + translate 0 110 + + image_convertToFormat the_pixmap converted RGB32 + drawImage converted 0 0 + translate 0 110 + + image_convertToFormat the_pixmap converted Indexed8 + drawImage converted 0 0 + translate 0 110 + + image_convertToFormat the_pixmap converted MonoLSB + drawImage converted 0 0 + translate 0 110 + + image_convertToFormat the_pixmap converted Mono + drawImage converted 0 0 + translate 0 110 + restore +end_block + + +image_load dome_argb32.png the_pixmap +translate 110 0 +repeat_block draw_stuff + + +image_load dome_rgb32.png the_pixmap +translate 110 0 +repeat_block draw_stuff + +image_load dome_indexed.png the_pixmap +translate 110 0 +repeat_block draw_stuff + + +image_load dome_mono.png the_pixmap +translate 110 0 +repeat_block draw_stuff + +image_load dome_mono_palette.png the_pixmap +translate 110 0 +repeat_block draw_stuff + +image_load dome_indexed_mask.png the_pixmap +translate 110 0 +repeat_block draw_stuff + + +# helpful texts +resetMatrix +setPen black + +drawText 10 670 "ARGB32_PM" +drawText 120 670 "ARGB32" +drawText 230 670 "RGB32" +drawText 340 670 "Indexed" +drawText 450 670 "Mono" +drawText 560 670 "Mono w/lut" +drawText 670 670 "Indexed w/mask" + +drawText 770 50 "ARGB32_PM" +drawText 770 160 "ARGB32" +drawText 770 270 "RGB32" +drawText 770 380 "Indexed" +drawText 770 490 "MonoLSB" +drawText 770 600 "Mono" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/images.qps b/tests/auto/lancelot/scripts/images.qps new file mode 100644 index 0000000..3f89240 --- /dev/null +++ b/tests/auto/lancelot/scripts/images.qps @@ -0,0 +1,106 @@ +# Version: 1 +# CheckVsReference: 5% + + +setRenderHint Antialiasing + +setPen #00ff00 + +image_load dome_argb32.png the_image +begin_block draw_stuff + +save + + # standard draw + drawImage the_image 0 0 + + # sub recting + translate 120 0 + drawImage the_image 0 0 40 40 0 0 40 40 + drawImage the_image 60 0 40 40 60 0 40 40 + drawImage the_image 0 60 40 40 0 60 40 40 + drawImage the_image 60 60 40 40 60 60 40 40 + drawImage the_image 0 40 40 20 0 40 40 20 + drawImage the_image 60 40 40 20 60 40 40 20 + drawImage the_image 40 0 20 100 40 0 20 100 + + # subrecting w/scale + translate 120 0 + drawImage the_image 0 0 50 50 0 0 25 25 + drawImage the_image 50 0 50 50 25 0 25 25 + drawImage the_image 0 50 50 50 0 25 25 25 + drawImage the_image 50 50 50 50 25 25 25 25 + + # subrecting w/scale & smooth xform + translate 120 0 + setRenderHint SmoothPixmapTransformation + drawImage the_image 0 0 50 50 0 0 25 25 + drawImage the_image 50 0 50 50 25 0 25 25 + drawImage the_image 0 50 50 50 0 25 25 25 + drawImage the_image 50 50 50 50 25 25 25 25 + + + # Rotation w/o smooth xform + translate 120 0 + save + setRenderHint SmoothPixmapTransform off + rotate 10 + drawImage the_image 0 0 + restore + + # Rotation w smooth xform + translate 120 0 + save + setRenderHint SmoothPixmapTransform + rotate 10 + drawImage the_image 0 0 + restore + +restore + +end_block + + +translate 0 120 +image_load dome_rgb32.png the_image +repeat_block draw_stuff + +translate 0 120 +image_load dome_indexed.png the_image +repeat_block draw_stuff + +translate 0 120 +image_load dome_indexed_mask.png the_image +repeat_block draw_stuff + +translate 0 120 +image_load dome_mono.png the_image +repeat_block draw_stuff + + +resetMatrix +translate 700 60 +setPen black +drawText 0 0 "32 bit w/alpha" +translate 0 120 +drawText 0 0 "32 bit w/o alpha" +translate 0 120 +drawText 0 0 "8 bit indexed" +translate 0 120 +drawText 0 0 "8 bit indexed w/mask" +translate 0 120 +drawText 0 0 "1 bit" +resetMatrix +translate 0 600 +drawText 0 0 "normal" +translate 120 0 +drawText 0 0 "subrect" +translate 120 0 +drawText 0 0 "subrect scale" +translate 120 0 +drawText 0 0 "subrect scale smooth" +translate 120 0 +drawText 0 0 "xform" +translate 120 0 +drawText 0 0 "smooth xform" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/images2.qps b/tests/auto/lancelot/scripts/images2.qps new file mode 100644 index 0000000..5159abc --- /dev/null +++ b/tests/auto/lancelot/scripts/images2.qps @@ -0,0 +1,145 @@ +# Version: 1 +# CheckVsReference: 5% + +image_load dome_argb32.png the_image +begin_block draw_stuff + +save + # standard draw + drawImage the_image 0 0 + + # flip x + translate 220 0 + scale -1 1 + drawImage the_image 0 0 + scale -1 1 + + # flip y + translate 20 100 + scale 1 -1 + drawImage the_image 0 0 + scale 1 -1 + + # flip x and y + translate 220 0 + scale -1 -1 + drawImage the_image 0 0 + scale -1 -1 + + # flip y and scale + translate 20 10 + save + scale 1 -1.1 + drawImage the_image 0 0 + restore + + # flip y and scale + translate 220 -110 + save + scale -1.1 0.9 + drawImage the_image 0 0 + restore +restore +end_block + +setRenderHint Antialiasing + +resetMatrix +translate 0 120 +repeat_block draw_stuff + +resetMatrix +translate 720 60 +setPen black +drawText 0 0 "aliased" +translate 0 120 +drawText 0 0 "antialiased" +resetMatrix +translate 0 260 +drawText 0 0 "normal" +translate 120 0 +drawText 0 0 "flip x" +translate 120 0 +drawText 0 0 "flip y" +translate 120 0 +drawText 0 0 "flip x and y" +translate 120 0 +drawText 0 0 "flip y and scale" +translate 120 0 +drawText 0 0 "flip x and scale" +translate 120 0 + +setRenderHint SmoothPixmapTransform + +resetMatrix +translate 20 300 +drawImage border.png 0 0 100 100 1 1 8 8 +drawText 0 -5 "subrect color bleeding" +translate 0 120 +drawImage border.png 0 0 100 100 0 0 10 10 + +image_load sign.png the_image +resetMatrix +drawText 240 300 "drawImage() with varying sx/sy offsets" +translate 0 10 +drawRect 240 300 50 50 +drawImage the_image 240 300 50 50 20 0 80 80 +drawRect 300 300 50 50 +drawImage the_image 300 300 50 50 -20 0 80 80 +drawRect 240 370 50 50 +drawImage the_image 240 370 50 50 0 20 80 80 +drawRect 300 370 50 50 +drawImage the_image 300 370 50 50 0 -20 80 80 + +pixmap_load sign.png the_pixmap +translate 220 0 +translate 0 -10 +drawText 240 300 "drawPixmap() with varying sx/sy offsets" +translate 0 10 +drawRect 240 300 50 50 +drawPixmap the_pixmap 240 300 50 50 20 0 80 80 +drawRect 300 300 50 50 +drawPixmap the_pixmap 300 300 50 50 -20 0 80 80 +drawRect 240 370 50 50 +drawPixmap the_pixmap 240 370 50 50 0 20 80 80 +drawRect 300 370 50 50 +drawPixmap the_pixmap 300 370 50 50 0 -20 80 80 + + +resetMatrix +translate 0 170 +drawText 240 300 "drawImage() with varying sx/sy offsets" +translate 0 10 +drawRect 240 300 50 50 +drawImage the_image 240 300 50 50 50 0 50 50 +drawRect 300 300 50 50 +drawImage the_image 300 300 50 50 -20 0 50 50 +drawRect 240 370 50 50 +drawImage the_image 240 370 50 50 0 50 50 50 +drawRect 300 370 50 50 +drawImage the_image 300 370 50 50 0 -20 50 50 + +resetMatrix +translate 220 170 +drawText 240 300 "drawPixmap() with varying sx/sy offsets" +translate 0 10 +drawRect 240 300 50 50 +drawPixmap the_pixmap 240 300 50 50 50 0 50 50 +drawRect 300 300 50 50 +drawPixmap the_pixmap 300 300 50 50 -20 0 50 50 +drawRect 240 370 50 50 +drawPixmap the_pixmap 240 370 50 50 0 50 50 50 +drawRect 300 370 50 50 +drawPixmap the_pixmap 300 370 50 50 0 -20 50 50 + +resetMatrix +drawText 10 620 "drawImage/Pixmap() with negative x/y and sx/sy" +setPen red + +translate 20 640 +drawImage the_image -10 -10 -1 -1 -10 -10 0 0 +drawRect 0 0 80 80 + +translate 100 0 +drawPixmap the_pixmap -10 -10 -1 -1 -10 -10 0 0 +drawRect 0 0 80 80 diff --git a/tests/auto/lancelot/scripts/join_cap_styles.qps b/tests/auto/lancelot/scripts/join_cap_styles.qps new file mode 100644 index 0000000..ed823f5 --- /dev/null +++ b/tests/auto/lancelot/scripts/join_cap_styles.qps @@ -0,0 +1,63 @@ +# Version: 1 +# CheckVsReference: 5% + + +setRenderHint Antialiasing + +path_moveTo p 20 20 +path_cubicTo p 100 20 100 180 180 100 +path_lineTo p 20 180 +path_lineTo p 180 20 + +setPen black 20 solidline roundcap roundjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline roundcap miterjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline roundcap beveljoin +drawPath p +setPen red +drawPath p + +translate -400 200 +setPen black 20 solidline squarecap roundjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline squarecap miterjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline squarecap beveljoin +drawPath p +setPen red +drawPath p + +translate -400 200 +setPen black 20 solidline flatcap roundjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline flatcap miterjoin +drawPath p +setPen red +drawPath p + +translate 200 0 +setPen black 20 solidline flatcap beveljoin +drawPath p +setPen red +drawPath p \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/join_cap_styles_duplicate_control_points.qps b/tests/auto/lancelot/scripts/join_cap_styles_duplicate_control_points.qps new file mode 100644 index 0000000..b463014 --- /dev/null +++ b/tests/auto/lancelot/scripts/join_cap_styles_duplicate_control_points.qps @@ -0,0 +1,68 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 600 650) + + +setRenderHint Antialiasing + +path_moveTo p 40 70 +path_lineTo p 20 70 +path_cubicTo p 20 70 40 20 80 80 + +path_moveTo p 20 120 +path_cubicTo p 50 60 80 110 80 110 +path_lineTo p 60 110 + +scale 2 2 + +setPen black 10 solidline roundcap roundjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline roundcap miterjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline roundcap beveljoin +drawPath p +setPen red +drawPath p + +translate -200 100 +setPen black 10 solidline squarecap roundjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline squarecap miterjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline squarecap beveljoin +drawPath p +setPen red +drawPath p + +translate -200 100 +setPen black 10 solidline flatcap roundjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline flatcap miterjoin +drawPath p +setPen red +drawPath p + +translate 100 0 +setPen black 10 solidline flatcap beveljoin +drawPath p +setPen red +drawPath p \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linear_gradients.qps b/tests/auto/lancelot/scripts/linear_gradients.qps new file mode 100644 index 0000000..b1b8dd6 --- /dev/null +++ b/tests/auto/lancelot/scripts/linear_gradients.qps @@ -0,0 +1,144 @@ +# Version: 1 +# CheckVsReference: 2% (0 0 600 750) + +path_addRect path 400 0 80 80 +path_addEllipse path 440 40 60 60 + +setRenderHint Antialiasing + +setPen black + +begin_block gradients +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setLinear 20 20 70 70 +drawRect 0 0 100 100 + +gradient_setSpread ReflectSpread +gradient_setLinear 120 20 170 70 +drawEllipse 100 0 100 100 + +gradient_setSpread RepeatSpread +gradient_setLinear 220 20 270 70 +drawRoundRect 200 0 100 100 + +gradient_clearStops +gradient_appendStop 0 3f7f7fff +gradient_appendStop 0.5 dfdfffff +gradient_appendStop 1 7f00007f + +gradient_setSpread PadSpread +gradient_setLinear 320 20 340 40 +drawPolygon [300 0 390 0 350 99] + +gradient_setSpread ReflectSpread +gradient_setLinear 420 20 440 40 +drawPath path + +gradient_setSpread RepeatSpread +gradient_setLinear 520 20 540 40 +drawPie 500 0 100 100 720 4320 +end_block + +translate 0 100 +scale 1 2 +repeat_block gradients + +resetMatrix +translate 0 300 +brushTranslate 30 0 +brushScale 0.9 0.9 +brushRotate 20 +repeat_block gradients + +# Vertical gradient tests +resetMatrix +setBrush noBrush +translate 0 400 + +begin_block vertical_gradients +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setLinear 20 20 20 70 +drawRect 0 0 100 100 + +gradient_setSpread ReflectSpread +gradient_setLinear 120 20 120 70 +drawEllipse 100 0 100 100 + +gradient_setSpread RepeatSpread +gradient_setLinear 220 20 220 70 +drawRoundRect 200 0 100 100 + +gradient_clearStops +gradient_appendStop 0 3f7f7fff +gradient_appendStop 0.5 dfdfffff +gradient_appendStop 1 7f00007f + +gradient_setSpread PadSpread +gradient_setLinear 320 20 320 40 +drawPolygon [300 0 390 0 350 99] + +gradient_setSpread ReflectSpread +gradient_setLinear 420 20 420 40 +drawPath path + +gradient_setSpread RepeatSpread +gradient_setLinear 520 20 520 40 +drawPie 500 0 100 100 720 4320 +end_block + +translate 0 100 +scale 1 1.5 +repeat_block vertical_gradients + +resetMatrix +translate 0 650 +brushTranslate 30 0 +brushScale 0.9 0.9 +brushRotate 20 +repeat_block vertical_gradients + +# Some helpful info perhaps? +resetMatrix +setPen black +# gradient line indicators +drawLine 20 20 70 70 +drawLine 120 20 170 70 +drawLine 220 20 270 70 +drawLine 320 20 340 40 +drawLine 420 20 440 40 +drawLine 520 20 540 40 + +drawLine 20 140 70 240 +drawLine 120 140 170 240 +drawLine 220 140 270 240 +drawLine 320 140 340 180 +drawLine 420 140 440 180 +drawLine 520 140 540 180 + +drawText 610 50 "No XForm" +drawText 610 200 "scale 1x2" +drawText 610 350 "brush transform" +drawText 610 450 "vertical brush" +drawText 610 570 "vertical brush scale 1x1.5" +drawText 610 700 "vertical brush transform" + +drawText 10 780 "Pad" +drawText 110 780 "Reflect" +drawText 210 780 "Repeat" +drawText 310 780 "Pad w/alpha" +drawText 410 780 "Reflect w/alpha" +drawText 510 780 "Repeat w/alpha" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linear_gradients_perspectives.qps b/tests/auto/lancelot/scripts/linear_gradients_perspectives.qps new file mode 100644 index 0000000..3ea39fb --- /dev/null +++ b/tests/auto/lancelot/scripts/linear_gradients_perspectives.qps @@ -0,0 +1,62 @@ +# Version: 1 + + +setRenderHint Antialiasing + +setPen #00ff00 + +translate 10 10 +# standard draw +begin_block gradient +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setLinear 10 10 290 290 +drawRect 0 0 300 300 +end_block gradient + +# Rotation w/o smooth xform +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 50 0 200 300 300 300 0 + repeat_block gradient +restore +restore + +translate 0 320 + +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 100 300 200 300 300 0 + repeat_block gradient +restore + +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 0 300 300 250 300 50 + repeat_block gradient +restore +restore + + +resetMatrix +setPen black +translate 125 20 +drawText 0 0 "No transform" +translate 350 0 +drawText 0 0 "Left Tilted" +resetMatrix +translate 125 350 +drawText 0 0 "Bottom Tilted" +translate 350 0 +drawText 0 0 "Right Tilted" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linear_resolving_gradients.qps b/tests/auto/lancelot/scripts/linear_resolving_gradients.qps new file mode 100644 index 0000000..779760c --- /dev/null +++ b/tests/auto/lancelot/scripts/linear_resolving_gradients.qps @@ -0,0 +1,66 @@ +# Version: 2 +# CheckVsReference: 2% (0 0 500 400) + +setRenderHint Antialiasing + +setPen black + +begin_block gradients +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setCoordinateMode ObjectBoundingMode +gradient_setLinear 0.2 0.2 0.7 0.7 +drawRect 0 0 100 100 + +gradient_setSpread ReflectSpread +gradient_setLinear 0.2 0.2 0.7 0.7 +drawEllipse 100 0 100 100 + +gradient_setSpread RepeatSpread +gradient_setLinear 0.2 0.2 0.7 0.7 +drawRoundRect 200 0 100 100 + +gradient_clearStops +gradient_appendStop 0 3f7f7fff +gradient_appendStop 0.5 dfdfffff +gradient_appendStop 1 7f00007f + +gradient_setSpread PadSpread +gradient_setLinear 0.2 0.2 0.8 0.4 +drawPolygon [300 0 400 0 350 100] + +gradient_setSpread RepeatSpread +gradient_setLinear 0.2 0.2 0.4 0.4 +drawPie 400 0 100 100 0 4320 +end_block + +translate 0 100 +scale 1 2 +repeat_block gradients + +resetMatrix +translate 0 300 +brushTranslate 30 0 +brushScale 0.9 0.9 +brushRotate 20 +repeat_block gradients + +# Some helpful info perhaps? +resetMatrix +setPen black + +drawText 510 50 "No XForm" +drawText 510 200 "scale 1x2" +drawText 510 350 "brush transform" + +drawText 10 450 "Pad" +drawText 110 450 "Reflect" +drawText 210 450 "Repeat" +drawText 310 450 "Pad w/alpha" +drawText 410 450 "Repeat w/alpha" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/lineconsistency.qps b/tests/auto/lancelot/scripts/lineconsistency.qps new file mode 100644 index 0000000..0b40577 --- /dev/null +++ b/tests/auto/lancelot/scripts/lineconsistency.qps @@ -0,0 +1,72 @@ +# Version: 1 + +begin_block draw +setPen red +drawPolygon [1.1 1 3.3 30.6 23.1 39.2 38.9 6.5] +setPen black +drawLine 1.1 1 3.3 30.6 +drawLine 3.3 30.6 23.1 39.2 +drawLine 23.1 39.2 38.9 6.5 +drawLine 38.9 6.5 1.1 1 +end_block draw +drawText 0 60 "0.0 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.1 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.2 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.3 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.4 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.5 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.6 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.7 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.8 aligned" +translate 0.1 80.1 +repeat_block draw +drawText 0 60 "0.9 aligned" + +resetMatrix +translate 100 0 +setPen black +drawText 0 20 "Line and text, 0.0 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.1 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.2 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.3 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.4 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.5 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.6 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.7 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.8 aligned" +drawLine 0 21 160 21 +translate 0 40.1 +drawText 0 20 "Line and text, 0.9 aligned" +drawLine 0 21 160 21 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linedashes.qps b/tests/auto/lancelot/scripts/linedashes.qps new file mode 100644 index 0000000..ee7d18b --- /dev/null +++ b/tests/auto/lancelot/scripts/linedashes.qps @@ -0,0 +1,94 @@ +# Version: 1 + +translate 10 10 + +setPen 0xffff0000 0 solidline squarecap +translate 50 50 +begin_block draw_lines + save + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + restore +end_block + +setPen 0xffff0000 0 dotline squarecap +translate 100 0 +repeat_block draw_lines +setPen 0xffff0000 0 dashdotline squarecap +translate 100 0 +repeat_block draw_lines +setPen 0xffff0000 0 dashdotdotline squarecap +translate 100 0 +repeat_block draw_lines +setPen 0xffff0000 0 dashline squarecap +translate 100 0 +repeat_block draw_lines \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linedashes2.qps b/tests/auto/lancelot/scripts/linedashes2.qps new file mode 100644 index 0000000..1dc4fd3 --- /dev/null +++ b/tests/auto/lancelot/scripts/linedashes2.qps @@ -0,0 +1,154 @@ +# Version: 1 +# CheckVsReference: 5% (0 0 800 800) + +translate -30 10 + +setPen 0xffff0000 0 dashline squarecap +pen_setDashPattern [10 5] + +save +translate 100 100 +begin_block lines +drawLine 100 100 200 100 +drawLine 100 100 200 200 +drawLine 100 100 100 200 +end_block + +setPen 0xffff0000 2 dashline squarecap +translate 150 0 +repeat_block lines +restore + +save +save +begin_block horizontal +drawLine 0 0 50 0 +drawLine 3 10 53 10 +drawLine 6 20 56 20 +drawLine 9 30 59 30 + +translate 0 50 + +drawLine 0 0 50 5 +drawLine 3 10 53 15 +drawLine 6 20 56 25 +drawLine 9 30 59 35 + +translate 0 50 + +drawLine 0 0 50 -5 +drawLine 3 10 53 5 +drawLine 6 20 56 15 +drawLine 9 30 59 25 +end_block +restore + +save +translate 80 0 +repeat_block horizontal +restore +save +translate 800 0 +repeat_block horizontal +restore + +translate 180 -40 +save +begin_block vertical +drawLine 0 0 0 50 +drawLine 10 3 10 53 +drawLine 20 6 20 56 +drawLine 30 9 30 59 + +translate 50 0 + +drawLine 0 0 5 50 +drawLine 10 3 15 53 +drawLine 20 6 25 56 +drawLine 30 9 35 59 + +translate 50 0 + +drawLine 0 0 -5 50 +drawLine 10 3 5 53 +drawLine 20 6 15 56 +drawLine 30 9 25 59 +end_block +restore + +save +translate 0 80 +repeat_block vertical +restore +translate 0 800 +repeat_block vertical +restore + +translate 0 200 + +setPen 0xffff0000 2 dashline squarecap +save +repeat_block horizontal +restore +save +translate 80 0 +repeat_block horizontal +restore +save +translate 780 0 +repeat_block horizontal +restore + +translate 360 -240 +save +repeat_block vertical +restore +save +translate 0 80 +repeat_block vertical +restore +translate 0 780 +repeat_block vertical + +resetMatrix +translate 40 400 +setPen 0xffff0000 5 dashdotline flatcap +pen_setDashPattern [1 1 4 1 1 4] +pen_setDashOffset -4 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset -2 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 0 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 2 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 4 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 6 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 8 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 10 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 12 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 14 +drawLine 0 0 300 0 +translate 0 8 +pen_setDashOffset 16 +drawLine 0 0 300 0 + +resetMatrix +setPen black 3 dashdotline +pen_setCosmetic true +translate 0 -150 +drawLine 500 160 500 410 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/linedashes2_aa.qps b/tests/auto/lancelot/scripts/linedashes2_aa.qps new file mode 100644 index 0000000..c818ab6 --- /dev/null +++ b/tests/auto/lancelot/scripts/linedashes2_aa.qps @@ -0,0 +1,5 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 800 800) + +setRenderHint LineAntialiasing +import "linedashes2.qps" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/lines.qps b/tests/auto/lancelot/scripts/lines.qps new file mode 100644 index 0000000..c0daffb --- /dev/null +++ b/tests/auto/lancelot/scripts/lines.qps @@ -0,0 +1,558 @@ +# Version: 1 +# CheckVsReference: 5% (0 0 310 425) + + +translate 10 10 + +begin_block draw_lines + save + translate 50 50 + + save + setPen 0x7fff0000 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + restore + + # and then draw the lines the other direction + save + setPen 0x7f0000ff + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + rotate 10 + drawLine 50 0 10 0 + restore + + # and now with a clip + save + setClipRect -30 -30 60 60 + setPen 0x7f00ff00 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + rotate 10 + drawLine 10 0 50 0 + restore + + restore +end_block + +save + translate 100 0 + scale 2 2 + repeat_block draw_lines +restore + +translate 0 10 + +save + translate 0 200 + setRenderHint Antialiasing + repeat_block draw_lines +restore + +save + translate 100 200 + scale 2 2 + setRenderHint Antialiasing + repeat_block draw_lines +restore + +translate 320 0 + +setPen black 0 solidline squarecap + +begin_block lines + +# 0 -> 45 degress +drawLine 100 100 200 90 +drawLine 100 100 200 80 +drawLine 100 100 200 70 +drawLine 100 100 200 60 +drawLine 100 100 200 50 +drawLine 100 100 200 40 +drawLine 100 100 200 30 +drawLine 100 100 200 20 +drawLine 100 100 200 10 + +# 45 +drawLine 100 100 200 0 + +# 45 -> 90 +drawLine 100 100 190 0 +drawLine 100 100 180 0 +drawLine 100 100 170 0 +drawLine 100 100 160 0 +drawLine 100 100 150 0 +drawLine 100 100 140 0 +drawLine 100 100 130 0 +drawLine 100 100 120 0 +drawLine 100 100 110 0 + +# 90 +drawLine 100 100 100 0 + +# 90 -> 135 +drawLine 100 100 90 0 +drawLine 100 100 80 0 +drawLine 100 100 70 0 +drawLine 100 100 60 0 +drawLine 100 100 50 0 +drawLine 100 100 40 0 +drawLine 100 100 30 0 +drawLine 100 100 20 0 +drawLine 100 100 10 0 + +# 135 +drawLine 100 100 0 0 + +# 135 -> 180 degress +drawLine 100 100 0 10 +drawLine 100 100 0 20 +drawLine 100 100 0 30 +drawLine 100 100 0 40 +drawLine 100 100 0 50 +drawLine 100 100 0 60 +drawLine 100 100 0 70 +drawLine 100 100 0 80 +drawLine 100 100 0 90 + +# 180 +drawLine 100 100 0 100 + +# 180 -> 225 +drawLine 100 100 0 110 +drawLine 100 100 0 120 +drawLine 100 100 0 130 +drawLine 100 100 0 140 +drawLine 100 100 0 150 +drawLine 100 100 0 160 +drawLine 100 100 0 170 +drawLine 100 100 0 180 +drawLine 100 100 0 190 + +# 225 +drawLine 100 100 0 200 + +# 225 -> 270 +drawLine 100 100 10 200 +drawLine 100 100 20 200 +drawLine 100 100 30 200 +drawLine 100 100 40 200 +drawLine 100 100 50 200 +drawLine 100 100 60 200 +drawLine 100 100 70 200 +drawLine 100 100 80 200 +drawLine 100 100 90 200 + +# 270 +drawLine 100 100 100 200 + +# 270 -> 315 degrees +drawLine 100 100 110 200 +drawLine 100 100 120 200 +drawLine 100 100 130 200 +drawLine 100 100 140 200 +drawLine 100 100 150 200 +drawLine 100 100 160 200 +drawLine 100 100 170 200 +drawLine 100 100 180 200 +drawLine 100 100 190 200 + +# 315 +drawLine 100 100 200 200 + +# 315 -> 360 degress +drawLine 100 100 200 100 +drawLine 100 100 200 110 +drawLine 100 100 200 120 +drawLine 100 100 200 130 +drawLine 100 100 200 140 +drawLine 100 100 200 150 +drawLine 100 100 200 160 +drawLine 100 100 200 170 +drawLine 100 100 200 180 +drawLine 100 100 200 190 + +end_block + + +setRenderHint Antialiasing +setPen 0x7fff0000 +translate 0.5 0.5 +repeat_block lines + +setPen 0x000000 8 +translate 20 240 +drawText 0 0 "Steep slopes:" + +translate 0 10 + +drawLine 0 0 -8 400 +translate 20 0 +drawLine 0 0 -7 400 +translate 20 0 +drawLine 0 0 -6 400 +translate 20 0 +drawLine 0 0 -5 400 +translate 20 0 +drawLine 0 0 -4 400 +translate 20 0 +drawLine 0 0 -3 400 +translate 20 0 +drawLine 0 0 -2 400 +translate 20 0 +drawLine 0 0 -1 400 +translate 20 0 +drawLine 0 0 0 400 +translate 20 0 +drawLine 0 0 1 400 +translate 20 0 +drawLine 0 0 2 400 +translate 20 0 +drawLine 0 0 3 400 +translate 20 0 +drawLine 0 0 4 400 +translate 20 0 +drawLine 0 0 5 400 +translate 20 0 +drawLine 0 0 6 400 +translate 20 0 +drawLine 0 0 7 400 +translate 20 0 +drawLine 0 0 8 400 + +resetMatrix + +translate 20 450 + +drawText 0 0 "Zero length lines:" + +translate 0 20 +drawText 100 10 "Square cap" +save +begin_block points +setPen 0x000000 1 solidline squarecap +drawLine 0 0 0 0 +setPen 0x000000 2 solidline squarecap +drawLine 8 0 8 0 +setPen 0x000000 3 solidline squarecap +drawLine 16 0 16 0 +setPen 0x000000 4 solidline squarecap +drawLine 24 0 24 0 +setPen 0x000000 5 solidline squarecap +drawLine 32 0 32 0 +setPen 0x000000 6 solidline squarecap +drawLine 40 0 40 0 +setPen 0x000000 7 solidline squarecap +drawLine 48 0 48 0 +setPen 0x000000 8 solidline squarecap +drawLine 57 0 57 0 +setPen 0x000000 9 solidline squarecap +drawLine 67 0 67 0 +setPen 0x000000 10 solidline squarecap +drawLine 78 0 78 0 +end_block points +restore + +translate 0 12 +setRenderHint Antialiasing off +repeat_block points +setRenderHint Antialiasing + +translate 0 20 +drawText 100 10 "Round cap" +save +begin_block points2 +setPen 0x000000 1 solidline roundcap +drawLine 0 0 0 0 +setPen 0x000000 2 solidline roundcap +drawLine 8 0 8 0 +setPen 0x000000 3 solidline roundcap +drawLine 16 0 16 0 +setPen 0x000000 4 solidline roundcap +drawLine 24 0 24 0 +setPen 0x000000 5 solidline roundcap +drawLine 32 0 32 0 +setPen 0x000000 6 solidline roundcap +drawLine 40 0 40 0 +setPen 0x000000 7 solidline roundcap +drawLine 48 0 48 0 +setPen 0x000000 8 solidline roundcap +drawLine 57 0 57 0 +setPen 0x000000 9 solidline roundcap +drawLine 67 0 67 0 +setPen 0x000000 10 solidline roundcap +drawLine 78 0 78 0 +end_block points2 +restore + +translate 0 12 +setRenderHint Antialiasing off +repeat_block points2 +setRenderHint Antialiasing + +translate 0 20 +drawText 100 10 "Flat cap" +save +begin_block points3 +setPen 0x000000 1 solidline flatcap +drawLine 0 0 0 0 +setPen 0x000000 2 solidline flatcap +drawLine 8 0 8 0 +setPen 0x000000 3 solidline flatcap +drawLine 16 0 16 0 +setPen 0x000000 4 solidline flatcap +drawLine 24 0 24 0 +setPen 0x000000 5 solidline flatcap +drawLine 32 0 32 0 +setPen 0x000000 6 solidline flatcap +drawLine 40 0 40 0 +setPen 0x000000 7 solidline flatcap +drawLine 48 0 48 0 +setPen 0x000000 8 solidline flatcap +drawLine 57 0 57 0 +setPen 0x000000 9 solidline flatcap +drawLine 67 0 67 0 +setPen 0x000000 10 solidline flatcap +drawLine 78 0 78 0 +end_block points3 +restore + +translate 0 12 +setRenderHint Antialiasing off +repeat_block points3 + +resetMatrix +translate -220 667.226 +drawText 230 -80 "Task 194266 (should see only one line):" +setPen black +drawRect 230.5 -70.5 122 12 +setRenderHint Antialiasing +setPen red +drawLine 236.842105263 -63.775117299 247.368421053 -63.775437504 + +setRenderHint Antialiasing off +resetMatrix +translate 10 640 +setPen black +drawText 0 -10 "Task 207147 (should see two lines):" +drawRect 0.5 0.5 64 64 +setRenderHint Antialiasing +setPen red + +drawLine 4.5 4.5 4.5001 60.5 +drawLine 4.5 4.5 60.5 4.5001 + +setRenderHint Antialiasing off +resetMatrix +translate 10 730 +setPen black +drawText 0 -10 "Task 229459 (should see one diagonal line):" +drawRect 0.5 0.5 64 64 +setPen red 2 solidline flatcap + +setClipRect 2 2 63 63 +drawLine 1.5 1.5 33560000 33560000 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/lines2.qps b/tests/auto/lancelot/scripts/lines2.qps new file mode 100644 index 0000000..af6ad65 --- /dev/null +++ b/tests/auto/lancelot/scripts/lines2.qps @@ -0,0 +1,179 @@ +# Version: 1 +# CheckVsReference: 5% + +translate 10 20 +drawText 0 0 "Thin lines" + +translate 60 70 + +save +begin_block lines +translate 0 -60 +translate 0 5 +setPen 0x000000 0.05 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.1 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.15 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.2 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.25 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.3 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.35 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.2 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.25 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.5 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.55 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.6 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.65 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.7 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.75 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.8 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.85 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.9 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 0.95 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.05 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.1 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.15 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.2 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.25 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.3 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.35 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.2 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.25 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.5 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.55 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.6 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.65 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.7 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.75 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.8 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.85 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.9 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 1.95 +drawLine -60 -2 60 2 +translate 0 5 +setPen 0x000000 2 +drawLine -60 -2 60 2 +end_block +restore + +save +translate 150 0 +scale -1 1 +repeat_block lines +restore + +save +translate 80 220 +rotate 90 +repeat_block lines +restore + +save +translate 80 370 +rotate 90 +scale -1 1 +repeat_block lines +restore + +setRenderHint Antialiasing + +translate 300 0 + +save +repeat_block lines +restore + +save +translate 150 0 +scale -1 1 +repeat_block lines +restore + +save +translate 80 220 +rotate 90 +repeat_block lines +restore + +save +translate 80 370 +rotate 90 +scale -1 1 +repeat_block lines +restore \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/pathfill.qps b/tests/auto/lancelot/scripts/pathfill.qps new file mode 100644 index 0000000..821b468 --- /dev/null +++ b/tests/auto/lancelot/scripts/pathfill.qps @@ -0,0 +1,38 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 850 420) + +setPen afff0000 4 + +setBrush dome_rgb32.png +drawEllipse 10 10 200 200 + +setBrush dome_argb32.png +drawEllipse 220 10 200 200 + +setPen NoPen + +setBrush dome_rgb32.png +drawEllipse 10 220 200 200 + +setBrush dome_argb32.png +drawEllipse 220 220 200 200 + +setBrushOrigin -30 -30 + +setPen afff0000 4 +setBrush dome_rgb32.png +drawEllipse 430 10 200 200 + +setBrush dome_argb32.png +drawEllipse 640 10 200 200 + +setPen NoPen +setBrush dome_rgb32.png +drawEllipse 430 220 200 200 + +setBrush dome_argb32.png +drawEllipse 640 220 200 200 + +setPen black +drawText 150 450 "No offset RGB/ARGB" +drawText 550 450 "-30 offset RGB/ARGB" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/paths.qps b/tests/auto/lancelot/scripts/paths.qps new file mode 100644 index 0000000..083026e --- /dev/null +++ b/tests/auto/lancelot/scripts/paths.qps @@ -0,0 +1,34 @@ +# Version: 1 + +setPen black +setBrush 7f7fff + +path_moveTo star 50 0 +path_lineTo star 30 90 +path_lineTo star 100 60 +path_lineTo star 0 20 +path_lineTo star 80 100 + +setFont "times" 50 +path_addText text 0 50 "ABCD, 1234, abcd, #¤%&" + +path_addRect rectncircle 0 0 75 75 +path_addEllipse rectncircle 25 25 75 75 +path_setFillRule rectncircle winding + +path_moveTo curve 100 0 +path_cubicTo curve 100 100 50 50 0 100 + +begin_block drawing +drawPath star +translate 100 0 +drawPath rectncircle +translate 100 0 +drawPath curve +translate -200 100 +drawPath text +end_block + +translate 50 100 +rotate 10 +repeat_block drawing diff --git a/tests/auto/lancelot/scripts/paths_aa.qps b/tests/auto/lancelot/scripts/paths_aa.qps new file mode 100644 index 0000000..4812e2f --- /dev/null +++ b/tests/auto/lancelot/scripts/paths_aa.qps @@ -0,0 +1,4 @@ +# Version: 1 + +setRenderHint LineAntialiasing +import "paths.qps" diff --git a/tests/auto/lancelot/scripts/pens.qps b/tests/auto/lancelot/scripts/pens.qps new file mode 100644 index 0000000..c72636d --- /dev/null +++ b/tests/auto/lancelot/scripts/pens.qps @@ -0,0 +1,133 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 800 800) + + +translate 10 10 + +begin_block penstyles +setPen black 0 solidline flatcap +drawLine 0 0 100 0 +setPen black 0 dashline flatcap +drawLine 100 0 100 40 +setPen black 0 dotline flatcap +drawLine 100 40 200 0 +setPen black 0 dashdotline flatcap +drawLine 200 0 300 0 +setPen black 0 dashdotdotline flatcap +drawLine 300 0 400 40 + +translate 0 50 +setPen blue 2 solidline flatcap +drawLine 0 0 100 0 +setPen blue 2 dashline flatcap +drawLine 100 0 100 40 +setPen blue 2 dotline flatcap +drawLine 100 40 200 0 +setPen blue 2 dashdotline flatcap +drawLine 200 0 300 0 +setPen blue 2 dashdotdotline flatcap +drawLine 300 0 400 40 + +translate 0 50 +setPen red 5 solidline flatcap +drawLine 0 0 100 0 +setPen red 5 dashline flatcap +drawLine 100 0 100 40 +setPen red 5 dotline flatcap +drawLine 100 40 200 0 +setPen red 5 dashdotline flatcap +drawLine 200 0 300 0 +setPen red 5 dashdotdotline flatcap +drawLine 300 0 400 40 +end_block + +translate 0 50 +scale 1 2 +repeat_block penstyles + + +# Test cap styles +resetMatrix +translate 420 10 +setPen green 5 dashdotline flatcap +drawLine 0 0 200 0 +setPen green 5 dashdotline roundcap +drawLine 0 20 200 20 +setPen green 5 dashdotline squarecap +drawLine 0 40 200 40 + + +# Test join styles +resetMatrix +translate 420 80 +setBrush nobrush +begin_block joinstyles +setPen orange 10 solidline flatcap miterjoin +drawPolyline [ 0 0 80 0 80 80 0 80 ] + +translate 0 100 +setPen aquamarine 10 solidline squarecap beveljoin +drawPolyline [ 0 0 80 0 80 80 0 80 ] + +translate 0 100 +setPen purple 10 solidline roundcap roundjoin +drawPolyline [ 0 0 80 0 80 80 0 80 ] +end_block + +translate 130 -200 +scale 2 1 +rotate 1 +repeat_block joinstyles + +# transparent lines +resetMatrix +translate 10 400 +setPen #7f000000 +drawLine 0 0 50 0 +setPen #7f000000 1 SolidLine +drawLine 0 10 50 10 +setPen #7f000000 5 SolidLine +drawLine 0 20 50 20 +setPen #7f000000 10 SolidLine +drawLine 0 30 50 30 +setPen #7f000000 +drawLine 0 0 0 50 +setPen #7f000000 1 SolidLine +drawLine 10 0 10 50 +setPen #7f000000 5 SolidLine +drawLine 20 0 20 50 +setPen #7f000000 10 SolidLine +drawLine 30 0 30 50 + +# pen styles +resetMatrix +translate 0 500 +setPen black 0 DashLine +drawLine 20 20 100 20 +translate 0 10 +setPen black 0 DotLine +drawLine 20 20 100 20 +translate 0 10 +setPen black 0 DashDotLine +drawLine 20 20 100 20 +translate 0 10 +setPen black 0 DashDotDotLine +drawLine 20 20 100 20 + +# scaling ellipse +resetMatrix +setPen black 0.008 DashLine +translate 250 550 +rotate 30 +scale 250 250 +drawEllipse -0.4 -0.4 0.8 0.8 + +# scaling path +path_addEllipse star -0.3 -0.3 0.6 0.6 + +resetMatrix +setPen black 0.008 DashLine +translate 250 550 +rotate 30 +scale 250 250 +drawPath star diff --git a/tests/auto/lancelot/scripts/pens_aa.qps b/tests/auto/lancelot/scripts/pens_aa.qps new file mode 100644 index 0000000..066cac3 --- /dev/null +++ b/tests/auto/lancelot/scripts/pens_aa.qps @@ -0,0 +1,6 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 800 800) + +setRenderHint LineAntialiasing + +import "pens.qps" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/pens_cosmetic.qps b/tests/auto/lancelot/scripts/pens_cosmetic.qps new file mode 100644 index 0000000..d1a60d1 --- /dev/null +++ b/tests/auto/lancelot/scripts/pens_cosmetic.qps @@ -0,0 +1,110 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 585 470) + +path_addEllipse path 22 0 7 7 +path_addRect path 25 5 4 4 + +translate 20 20 + +begin_block lines + save + drawLine 0 0 10 10 + drawLine 2 0 10 0 + drawLine 0 2 0 10 + drawPolygon [12 0 20 0 15 10] + drawPath path + drawEllipse 32 0 8 8 + drawPoint 36 4 + + translate 100 0 + save + scale 4 1 + drawLine 0 0 10 10 + drawLine 2 0 10 0 + drawLine 0 2 0 10 + drawPolygon [12 0 20 0 15 10] + drawPath path + drawEllipse 32 0 8 8 + drawPoint 36 4 + restore + + translate 200 0 + save + scale 1 4 + drawLine 0 0 10 10 + drawLine 2 0 10 0 + drawLine 0 2 0 10 + drawPolygon [12 0 20 0 15 10] + drawPath path + drawEllipse 32 0 8 8 + drawPoint 36 4 + restore + + translate 100 0 + save + scale 4 4 + drawLine 0 0 10 10 + drawLine 2 0 10 0 + drawLine 0 2 0 10 + drawPolygon [12 0 20 0 15 10] + drawPath path + drawEllipse 32 0 8 8 + drawPoint 36 4 + restore + restore +end_block + +drawText 580 15 "non-cosmetic, 0-width" +translate 0 50 + +setPen black 2 +repeat_block lines +drawText 580 15 "non-cosmetic, 2-width" + +translate 0 20 +translate 0 50 +setPen black 0 +pen_setCosmetic true +repeat_block lines +drawText 580 15 "cosmetic, 0-width" + +translate 0 50 +setPen black 2 +pen_setCosmetic true +repeat_block lines +drawText 580 15 "cosmetic, 2-width" + + +setRenderHint Antialiasing +translate 0 20 + +translate 0 50 +setPen black 0 +repeat_block lines +drawText 580 15 "non-cosmetic, 0-width" + +translate 0 50 + +setPen black 2 +repeat_block lines +drawText 580 15 "non-cosmetic, 2-width" + +translate 0 20 +translate 0 50 +setPen black 0 +pen_setCosmetic true +repeat_block lines +drawText 580 15 "cosmetic, 0-width" + +translate 0 50 +setPen black 2 +pen_setCosmetic true +repeat_block lines +drawText 580 15 "cosmetic, 2-width" + + +translate 0 70 +drawText 0 0 "scale(1, 1)" +drawText 150 0 "scale(4, 1)" +drawText 300 0 "scale(1, 4)" +drawText 450 0 "scale(4, 4)" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/perspectives.qps b/tests/auto/lancelot/scripts/perspectives.qps new file mode 100644 index 0000000..0b903e5 --- /dev/null +++ b/tests/auto/lancelot/scripts/perspectives.qps @@ -0,0 +1,72 @@ +# Version: 1 + + +setRenderHint Antialiasing + +setPen #00ff00 + +image_load image.png the_image + +translate 10 10 +# standard draw +drawImage the_image 0 0 + +# Rotation w/o smooth xform +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 50 0 200 300 300 300 0 + drawImage the_image 0 0 +restore +restore + +translate 0 320 + +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 100 300 200 300 300 0 + drawImage the_image 0 0 +restore + +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 0 300 300 250 300 50 + drawImage the_image 0 0 +restore +restore + +setRenderHint SmoothPixmapTransform on +setBrush red +setPen black +resetMatrix +translate 100 720 +rotate_y 85 +scale 7 0.01 +drawRect -150 -150 300 300 + +resetMatrix +setBrush gam030.png +setPen black 30 +translate 700 700 +rotate_y -85 +scale 7 0.01 +drawRect -150 -150 300 300 + +resetMatrix +setPen black +translate 125 20 +drawText 0 0 "No transform" +translate 350 0 +drawText 0 0 "Left Tilted" +resetMatrix +translate 125 350 +drawText 0 0 "Bottom Tilted" +translate 350 0 +drawText 0 0 "Right Tilted" +translate 120 0 +resetMatrix +translate 300 760 +drawText 0 0 "Perspective Clipping" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/perspectives2.qps b/tests/auto/lancelot/scripts/perspectives2.qps new file mode 100644 index 0000000..2f6d1d6 --- /dev/null +++ b/tests/auto/lancelot/scripts/perspectives2.qps @@ -0,0 +1,309 @@ +# Version: 1 + +setRenderHint Antialiasing + +image_load zebra.png zebra_png + +image_convertToFormat zebra_png zebra ARGB32_Premultiplied + +translate 75 100 +# standard draw +begin_block row +drawImage zebra -50 -50 + +translate 90 0 +save +rotate_y 50 +drawImage zebra -50 -50 +restore + +translate 65 0 +save +rotate_y 60 +drawImage zebra -50 -50 +restore + +translate 50 0 +save +rotate_y 70 +drawImage zebra -50 -50 +restore + +translate 30 0 +save +rotate_y 80 +drawImage zebra -50 -50 +restore + +translate 24 0 +save +rotate_y 82 +drawImage zebra -50 -50 +restore + +translate 20 0 +save +rotate_y 84 +drawImage zebra -50 -50 +restore + +translate 16 0 +save +rotate_y 86 +drawImage zebra -50 -50 +restore + +translate 12 0 +save +rotate_y 87 +drawImage zebra -50 -50 +restore + +translate 8 0 +save +rotate_y 88 +drawImage zebra -50 -50 +restore + +translate 6 0 +save +rotate_y 89 +drawImage zebra -50 -50 +restore + +translate 6 0 +save +rotate_y 91 +drawImage zebra -50 -50 +restore + +translate 6 0 +save +rotate_y 92 +drawImage zebra -50 -50 +restore + +translate 8 0 +save +rotate_y 93 +drawImage zebra -50 -50 +restore + +translate 12 0 +save +rotate_y 94 +drawImage zebra -50 -50 +restore + +translate 16 0 +save +rotate_y 96 +drawImage zebra -50 -50 +restore + +translate 20 0 +save +rotate_y 98 +drawImage zebra -50 -50 +restore + +translate 24 0 +save +rotate_y 100 +drawImage zebra -50 -50 +restore + +translate 30 0 +save +rotate_y 110 +drawImage zebra -50 -50 +restore + +translate 50 0 +save +rotate_y 120 +drawImage zebra -50 -50 +restore + +translate 65 0 +save +rotate_y 130 +drawImage zebra -50 -50 +restore + +translate 90 0 +save +rotate_y 180 +drawImage zebra -50 -50 +restore +end_block + +resetMatrix +translate 75 280 +setRenderHint SmoothPixmapTransform +repeat_block row + +resetMatrix +setPen black +translate 300 20 +drawText 0 0 "Fast Pixmap Transform" +resetMatrix +translate 300 210 +drawText 0 0 "Smooth Pixmap Transform" + +resetMatrix +translate 0 400 + +image_load dome_argb32.png the_pixmap + +image_convertToFormat the_pixmap dome ARGB32 + +setRenderHint SmoothPixmapTransform false + +translate 75 100 +# standard draw +begin_block row +drawImage dome -50 -50 + +translate 90 0 +save +rotate_y 50 +drawImage dome -50 -50 +restore + +translate 65 0 +save +rotate_y 60 +drawImage dome -50 -50 +restore + +translate 50 0 +save +rotate_y 70 +drawImage dome -50 -50 +restore + +translate 30 0 +save +rotate_y 80 +drawImage dome -50 -50 +restore + +translate 24 0 +save +rotate_y 82 +drawImage dome -50 -50 +restore + +translate 20 0 +save +rotate_y 84 +drawImage dome -50 -50 +restore + +translate 16 0 +save +rotate_y 86 +drawImage dome -50 -50 +restore + +translate 12 0 +save +rotate_y 87 +drawImage dome -50 -50 +restore + +translate 8 0 +save +rotate_y 88 +drawImage dome -50 -50 +restore + +translate 6 0 +save +rotate_y 89 +drawImage dome -50 -50 +restore + +translate 6 0 +save +rotate_y 91 +drawImage dome -50 -50 +restore + +translate 6 0 +save +rotate_y 92 +drawImage dome -50 -50 +restore + +translate 8 0 +save +rotate_y 93 +drawImage dome -50 -50 +restore + +translate 12 0 +save +rotate_y 94 +drawImage dome -50 -50 +restore + +translate 16 0 +save +rotate_y 96 +drawImage dome -50 -50 +restore + +translate 20 0 +save +rotate_y 98 +drawImage dome -50 -50 +restore + +translate 24 0 +save +rotate_y 100 +drawImage dome -50 -50 +restore + +translate 30 0 +save +rotate_y 110 +drawImage dome -50 -50 +restore + +translate 50 0 +save +rotate_y 120 +drawImage dome -50 -50 +restore + +translate 65 0 +save +rotate_y 130 +drawImage dome -50 -50 +restore + +translate 90 0 +save +rotate_y 180 +drawImage dome -50 -50 +restore +end_block + +resetMatrix +translate 0 400 +translate 75 280 +setRenderHint SmoothPixmapTransform +repeat_block row + +resetMatrix +setPen black +translate 0 400 +translate 300 20 +drawText 0 0 "Fast Pixmap Transform" +resetMatrix +translate 0 400 +translate 300 210 +drawText 0 0 "Smooth Pixmap Transform" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/pixmap_rotation.qps b/tests/auto/lancelot/scripts/pixmap_rotation.qps new file mode 100644 index 0000000..2f1ffb5 --- /dev/null +++ b/tests/auto/lancelot/scripts/pixmap_rotation.qps @@ -0,0 +1,30 @@ +# Version: 1 +# CheckVsReference: 0% (0 0 440 220) + +translate 120 120 + +begin_block drawing +save + rotate 90 + drawPixmap solid.png 0 0 + + rotate 90 + drawPixmap solid.png 0 0 + + rotate 90 + drawPixmap solid.png 0 0 + + rotate 90 + drawPixmap solid.png 0 0 +restore +end_block + +resetMatrix + +translate 340 120 +repeat_block drawing + +resetMatrix + +drawText 50 240 "Normal X form" +drawText 270 240 "Smooth xform" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/pixmap_scaling.qps b/tests/auto/lancelot/scripts/pixmap_scaling.qps new file mode 100644 index 0000000..651896f --- /dev/null +++ b/tests/auto/lancelot/scripts/pixmap_scaling.qps @@ -0,0 +1,224 @@ +# Version: 1 +# CheckVsReference: 0% (0 30 600 70) +# CheckVsReference: 0% (290 130 280 60) +# CheckVsReference: 0% (0 180 250 90) + +# Hurra! Force line endings (?) + +translate 5 25 +setFont "arial" 8 + +save + drawText 15 0 "opaque image" + translate 50 50 + save + translate 1 1 + scale 20 20 + drawImage solid2x2.png 0 0 + restore + save + translate -1 1 + scale -20 20 + drawImage solid2x2.png 0 0 + restore + save + translate 1 -1 + scale 20 -20 + drawImage solid2x2.png 0 0 + restore + save + translate -1 -1 + scale -20 -20 + drawImage solid2x2.png 0 0 + restore + + +restore + +save + translate 150 0 + drawText 15 0 "alpha image" + translate 50 50 + save + translate 1 1 + scale 20 20 + drawImage alpha2x2.png 0 0 + restore + save + translate -1 1 + scale -20 20 + drawImage alpha2x2.png 0 0 + restore + save + translate 1 -1 + scale 20 -20 + drawImage alpha2x2.png 0 0 + restore + save + translate -1 -1 + scale -20 -20 + drawImage alpha2x2.png 0 0 + restore +restore + + +save + translate 0 150 + drawText 15 0 "solid pixmap" + translate 50 50 + save + translate 1 1 + scale 20 20 + drawPixmap solid2x2.png 0 0 + restore + save + translate -1 1 + scale -20 20 + drawPixmap solid2x2.png 0 0 + restore + save + translate 1 -1 + scale 20 -20 + drawPixmap solid2x2.png 0 0 + restore + save + translate -1 -1 + scale -20 -20 + drawPixmap solid2x2.png 0 0 + restore +restore + + +save + translate 150 150 + drawText 15 0 "alpha pixmap" + translate 50 50 + save + translate 1 1 + scale 20 20 + drawPixmap alpha2x2.png 0 0 + restore + save + translate -1 1 + scale -20 20 + drawPixmap alpha2x2.png 0 0 + restore + save + translate 1 -1 + scale 20 -20 + drawPixmap alpha2x2.png 0 0 + restore + save + translate -1 -1 + scale -20 -20 + drawPixmap alpha2x2.png 0 0 + restore +restore + + +save + translate 300 10 + save + drawText 0 -10 "subrect solid image" + drawImage solid2x2.png 0 0 50 5 0 0.0 2 0.2 + drawImage solid2x2.png 0 5 50 5 0 0.2 2 0.2 + drawImage solid2x2.png 0 10 50 5 0 0.4 2 0.2 + drawImage solid2x2.png 0 15 50 5 0 0.6 2 0.2 + drawImage solid2x2.png 0 20 50 5 0 0.8 2 0.2 + drawImage solid2x2.png 0 25 50 5 0 1.0 2 0.2 + drawImage solid2x2.png 0 30 50 5 0 1.2 2 0.2 + drawImage solid2x2.png 0 35 50 5 0 1.4 2 0.2 + drawImage solid2x2.png 0 40 50 5 0 1.6 2 0.2 + drawImage solid2x2.png 0 45 50 5 0 1.8 2 0.2 + translate 60 0 + drawImage solid2x2.png 0 0 5 50 0.0 0 0.2 2 + drawImage solid2x2.png 5 0 5 50 0.2 0 0.2 2 + drawImage solid2x2.png 10 0 5 50 0.4 0 0.2 2 + drawImage solid2x2.png 15 0 5 50 0.6 0 0.2 2 + drawImage solid2x2.png 20 0 5 50 0.8 0 0.2 2 + drawImage solid2x2.png 25 0 5 50 1.0 0 0.2 2 + drawImage solid2x2.png 30 0 5 50 1.2 0 0.2 2 + drawImage solid2x2.png 35 0 5 50 1.4 0 0.2 2 + drawImage solid2x2.png 40 0 5 50 1.6 0 0.2 2 + drawImage solid2x2.png 45 0 5 50 1.8 0 0.2 2 + restore + + save + translate 150 0 + drawText 0 -10 "subrect solid image" + drawImage alpha2x2.png 0 0 50 5 0 0.0 2 0.2 + drawImage alpha2x2.png 0 5 50 5 0 0.2 2 0.2 + drawImage alpha2x2.png 0 10 50 5 0 0.4 2 0.2 + drawImage alpha2x2.png 0 15 50 5 0 0.6 2 0.2 + drawImage alpha2x2.png 0 20 50 5 0 0.8 2 0.2 + drawImage alpha2x2.png 0 25 50 5 0 1.0 2 0.2 + drawImage alpha2x2.png 0 30 50 5 0 1.2 2 0.2 + drawImage alpha2x2.png 0 35 50 5 0 1.4 2 0.2 + drawImage alpha2x2.png 0 40 50 5 0 1.6 2 0.2 + drawImage alpha2x2.png 0 45 50 5 0 1.8 2 0.2 + translate 60 0 + drawImage alpha2x2.png 0 0 5 50 0.0 0 0.2 2 + drawImage alpha2x2.png 5 0 5 50 0.2 0 0.2 2 + drawImage alpha2x2.png 10 0 5 50 0.4 0 0.2 2 + drawImage alpha2x2.png 15 0 5 50 0.6 0 0.2 2 + drawImage alpha2x2.png 20 0 5 50 0.8 0 0.2 2 + drawImage alpha2x2.png 25 0 5 50 1.0 0 0.2 2 + drawImage alpha2x2.png 30 0 5 50 1.2 0 0.2 2 + drawImage alpha2x2.png 35 0 5 50 1.4 0 0.2 2 + drawImage alpha2x2.png 40 0 5 50 1.6 0 0.2 2 + drawImage alpha2x2.png 45 0 5 50 1.8 0 0.2 2 + restore + + save + translate 0 100 + drawText 0 -10 "subrect alpha pixmap" + drawPixmap solid2x2.png 0 0 50 5 0 0.0 2 0.2 + drawPixmap solid2x2.png 0 5 50 5 0 0.2 2 0.2 + drawPixmap solid2x2.png 0 10 50 5 0 0.4 2 0.2 + drawPixmap solid2x2.png 0 15 50 5 0 0.6 2 0.2 + drawPixmap solid2x2.png 0 20 50 5 0 0.8 2 0.2 + drawPixmap solid2x2.png 0 25 50 5 0 1.0 2 0.2 + drawPixmap solid2x2.png 0 30 50 5 0 1.2 2 0.2 + drawPixmap solid2x2.png 0 35 50 5 0 1.4 2 0.2 + drawPixmap solid2x2.png 0 40 50 5 0 1.6 2 0.2 + drawPixmap solid2x2.png 0 45 50 5 0 1.8 2 0.2 + translate 60 0 + drawPixmap solid2x2.png 0 0 5 50 0.0 0 0.2 2 + drawPixmap solid2x2.png 5 0 5 50 0.2 0 0.2 2 + drawPixmap solid2x2.png 10 0 5 50 0.4 0 0.2 2 + drawPixmap solid2x2.png 15 0 5 50 0.6 0 0.2 2 + drawPixmap solid2x2.png 20 0 5 50 0.8 0 0.2 2 + drawPixmap solid2x2.png 25 0 5 50 1.0 0 0.2 2 + drawPixmap solid2x2.png 30 0 5 50 1.2 0 0.2 2 + drawPixmap solid2x2.png 35 0 5 50 1.4 0 0.2 2 + drawPixmap solid2x2.png 40 0 5 50 1.6 0 0.2 2 + drawPixmap solid2x2.png 45 0 5 50 1.8 0 0.2 2 + restore + + save + translate 150 100 + drawText 0 -10 "subrect alpha pixmap" + drawPixmap alpha2x2.png 0 0 50 5 0 0.0 2 0.2 + drawPixmap alpha2x2.png 0 5 50 5 0 0.2 2 0.2 + drawPixmap alpha2x2.png 0 10 50 5 0 0.4 2 0.2 + drawPixmap alpha2x2.png 0 15 50 5 0 0.6 2 0.2 + drawPixmap alpha2x2.png 0 20 50 5 0 0.8 2 0.2 + drawPixmap alpha2x2.png 0 25 50 5 0 1.0 2 0.2 + drawPixmap alpha2x2.png 0 30 50 5 0 1.2 2 0.2 + drawPixmap alpha2x2.png 0 35 50 5 0 1.4 2 0.2 + drawPixmap alpha2x2.png 0 40 50 5 0 1.6 2 0.2 + drawPixmap alpha2x2.png 0 45 50 5 0 1.8 2 0.2 + translate 60 0 + drawPixmap alpha2x2.png 0 0 5 50 0.0 0 0.2 2 + drawPixmap alpha2x2.png 5 0 5 50 0.2 0 0.2 2 + drawPixmap alpha2x2.png 10 0 5 50 0.4 0 0.2 2 + drawPixmap alpha2x2.png 15 0 5 50 0.6 0 0.2 2 + drawPixmap alpha2x2.png 20 0 5 50 0.8 0 0.2 2 + drawPixmap alpha2x2.png 25 0 5 50 1.0 0 0.2 2 + drawPixmap alpha2x2.png 30 0 5 50 1.2 0 0.2 2 + drawPixmap alpha2x2.png 35 0 5 50 1.4 0 0.2 2 + drawPixmap alpha2x2.png 40 0 5 50 1.6 0 0.2 2 + drawPixmap alpha2x2.png 45 0 5 50 1.8 0 0.2 2 + restore + +restore \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/pixmap_subpixel.qps b/tests/auto/lancelot/scripts/pixmap_subpixel.qps new file mode 100644 index 0000000..908f7c3 --- /dev/null +++ b/tests/auto/lancelot/scripts/pixmap_subpixel.qps @@ -0,0 +1,117 @@ +# Version: 1 +# CheckVsReference: 5% + + +translate 50 50 + +# Pixmaps at 0.1 offset, unclipped +begin_block draw_pixmaps +save + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 + drawPixmap border.png 0 0 + translate 20.1 0.1 +restore +end_block + +# Tiled pixmaps at 0.1 offsets, unclipped +translate 0 50 +begin_block draw_tiled +save + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 + drawTiledPixmap border.png 0 0 16 16 0 0 + translate 20.1 0.1 +restore +end_block + + +path_moveTo clip 0 0 +path_lineTo clip width 0 +path_lineTo clip width 400 +path_lineTo clip 0 height +setClipPath clip + +translate 0 50 +# Pixmaps at 0.1 offset, clipped +repeat_block draw_pixmaps + + +# Tiled pixmaps at 0.1 offsets... +translate 0 50 +repeat_block draw_tiled + diff --git a/tests/auto/lancelot/scripts/pixmaps.qps b/tests/auto/lancelot/scripts/pixmaps.qps new file mode 100644 index 0000000..8e60997 --- /dev/null +++ b/tests/auto/lancelot/scripts/pixmaps.qps @@ -0,0 +1,106 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 690 580) + + +setRenderHint Antialiasing + +setPen #00ff00 + +pixmap_load dome_argb32.png the_pixmap +begin_block draw_stuff + +save + + # standard draw + drawPixmap the_pixmap 0 0 + + # sub recting + translate 120 0 + drawPixmap the_pixmap 0 0 40 40 0 0 40 40 + drawPixmap the_pixmap 60 0 40 40 60 0 40 40 + drawPixmap the_pixmap 0 60 40 40 0 60 40 40 + drawPixmap the_pixmap 60 60 40 40 60 60 40 40 + drawPixmap the_pixmap 0 40 40 20 0 40 40 20 + drawPixmap the_pixmap 60 40 40 20 60 40 40 20 + drawPixmap the_pixmap 40 0 20 100 40 0 20 100 + + # subrecting w/scale + translate 120 0 + drawPixmap the_pixmap 0 0 50 50 0 0 25 25 + drawPixmap the_pixmap 50 0 50 50 25 0 25 25 + drawPixmap the_pixmap 0 50 50 50 0 25 25 25 + drawPixmap the_pixmap 50 50 50 50 25 25 25 25 + + # subrecting w/scale & smooth xform + translate 120 0 + setRenderHint SmoothPixmapTransformation + drawPixmap the_pixmap 0 0 50 50 0 0 25 25 + drawPixmap the_pixmap 50 0 50 50 25 0 25 25 + drawPixmap the_pixmap 0 50 50 50 0 25 25 25 + drawPixmap the_pixmap 50 50 50 50 25 25 25 25 + + + # Rotation w/o smooth xform + translate 120 0 + save + setRenderHint SmoothPixmapTransform off + rotate 10 + drawPixmap the_pixmap 0 0 + restore + + # Rotation w smooth xform + translate 120 0 + save + setRenderHint SmoothPixmapTransform + rotate 10 + drawPixmap the_pixmap 0 0 + restore + +restore + +end_block + + +translate 0 120 +pixmap_load dome_rgb32.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_indexed.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_indexed_mask.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_mono.png the_pixmap +repeat_block draw_stuff + + +resetMatrix +translate 700 60 +setPen black +drawText 0 0 "32 bit w/alpha" +translate 0 120 +drawText 0 0 "32 bit w/o alpha" +translate 0 120 +drawText 0 0 "8 bit indexed" +translate 0 120 +drawText 0 0 "8 bit indexed w/mask" +translate 0 120 +drawText 0 0 "1 bit" +resetMatrix +translate 0 600 +drawText 0 0 "normal" +translate 120 0 +drawText 0 0 "subrect" +translate 120 0 +drawText 0 0 "subrect scale" +translate 120 0 +drawText 0 0 "subrect scale smooth" +translate 120 0 +drawText 0 0 "xform" +translate 120 0 +drawText 0 0 "smooth xform" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/porter_duff.qps b/tests/auto/lancelot/scripts/porter_duff.qps new file mode 100644 index 0000000..166e48a --- /dev/null +++ b/tests/auto/lancelot/scripts/porter_duff.qps @@ -0,0 +1,251 @@ +# Version: 1 +# CheckVsReference: 5% + + +translate 0 50 + +surface_begin 0 0 100 100 + +begin_block predraw +setRenderHint Antialiasing +setPen nopen +setBrush 0x7f000000 +drawEllipse 10 10 80 80 +end_block + +setCompositionMode SourceOver + +begin_block postdraw + + +setBrush 0x1fff0000 +drawRect 0 0 50 50 + +setBrush 0xdf00ff00 +drawRect 50 50 50 50 + +setBrush 0x7f0000ff +drawEllipse 30 30 40 40 + +# a black rectangle around +setCompositionMode SourceOver +setPen black +setBrush nobrush +drawRect 0.5 0.5 99 99 + +end_block +surface_end + + +# Destination over +surface_begin 100 0 100 100 +repeat_block predraw +setCompositionMode DestinationOver +repeat_block postdraw +surface_end + + +# Clear +surface_begin 200 0 100 100 +repeat_block predraw +setCompositionMode Clear +repeat_block postdraw +surface_end + + +# Source +surface_begin 300 0 100 100 +repeat_block predraw +setCompositionMode Source +repeat_block postdraw +surface_end + + +# Destination +surface_begin 400 0 100 100 +repeat_block predraw +setCompositionMode Destination +repeat_block postdraw +surface_end + + +# Source In +surface_begin 500 0 100 100 +repeat_block predraw +setCompositionMode SourceIn +repeat_block postdraw +surface_end + +translate 0 50 + +# Destination In +surface_begin 0 100 100 100 +repeat_block predraw +setCompositionMode DestinationIn +repeat_block postdraw +surface_end + + +# Source Out +surface_begin 100 100 100 100 +repeat_block predraw +setCompositionMode SourceOut +repeat_block postdraw +surface_end + + +# Destination Out +surface_begin 200 100 100 100 +repeat_block predraw +setCompositionMode DestinationOut +repeat_block postdraw +surface_end + + +# SourceAtop +surface_begin 300 100 100 100 +repeat_block predraw +setCompositionMode SourceAtop +repeat_block postdraw +surface_end + + +# DestinationAtop +surface_begin 400 100 100 100 +repeat_block predraw +setCompositionMode DestinationAtop +repeat_block postdraw +surface_end + + +# Xor +surface_begin 500 100 100 100 +repeat_block predraw +setCompositionMode Xor +repeat_block postdraw +surface_end + +translate 0 50 + +# Plus +surface_begin 0 200 100 100 +repeat_block predraw +setCompositionMode Plus +repeat_block postdraw +surface_end + + +# Multiply +surface_begin 100 200 100 100 +repeat_block predraw +setCompositionMode Multiply +repeat_block postdraw +surface_end + + +# Screen +surface_begin 200 200 100 100 +repeat_block predraw +setCompositionMode Screen +repeat_block postdraw +surface_end + + +# Overlay +surface_begin 300 200 100 100 +repeat_block predraw +setCompositionMode Overlay +repeat_block postdraw +surface_end + + +# Darken +surface_begin 400 200 100 100 +repeat_block predraw +setCompositionMode Darken +repeat_block postdraw +surface_end + + +# Lighten +surface_begin 500 200 100 100 +repeat_block predraw +setCompositionMode Lighten +repeat_block postdraw +surface_end + +translate 0 50 + +# ColorDodge +surface_begin 0 300 100 100 +repeat_block predraw +setCompositionMode ColorDodge +repeat_block postdraw +surface_end + + +# Multiply +surface_begin 100 300 100 100 +repeat_block predraw +setCompositionMode ColorBurn +repeat_block postdraw +surface_end + + +# Screen +surface_begin 200 300 100 100 +repeat_block predraw +setCompositionMode HardLight +repeat_block postdraw +surface_end + + +# Overlay +surface_begin 300 300 100 100 +repeat_block predraw +setCompositionMode SoftLight +repeat_block postdraw +surface_end + + +# Darken +surface_begin 400 300 100 100 +repeat_block predraw +setCompositionMode Difference +repeat_block postdraw +surface_end + + +# Lighten +surface_begin 500 300 100 100 +repeat_block predraw +setCompositionMode Exclusion +repeat_block postdraw +surface_end + +resetMatrix + +drawText 0 50 "SourceOver" +drawText 100 50 "DestinationOver" +drawText 200 50 "Clear" +drawText 300 50 "Source" +drawText 400 50 "Destination" +drawText 500 50 "SourceIn" +drawText 0 200 "DestinationIn" +drawText 100 200 "SourceOut" +drawText 200 200 "DestinationOut" +drawText 300 200 "SourceAtop" +drawText 400 200 "DestinationAtop" +drawText 500 200 "Xor" +drawText 0 350 "Plus" +drawText 100 350 "Multiply" +drawText 200 350 "Screen" +drawText 300 350 "Overlay" +drawText 400 350 "Darken" +drawText 500 350 "Lighten" +drawText 0 500 "ColorDodge" +drawText 100 500 "ColorBurn" +drawText 200 500 "HardLight" +drawText 300 500 "SoftLight" +drawText 400 500 "Difference" +drawText 500 500 "Exclusion" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/porter_duff2.qps b/tests/auto/lancelot/scripts/porter_duff2.qps new file mode 100644 index 0000000..a792d9b --- /dev/null +++ b/tests/auto/lancelot/scripts/porter_duff2.qps @@ -0,0 +1,261 @@ +# Version: 1 +# CheckVsReference: 1% (0 50 600 100) +# CheckVsReference: 1% (0 200 600 100) +# CheckVsReference: 1% (0 350 600 100) +# CheckVsReference: 1% (0 500 600 100) + +translate 0 50 + +surface_begin 0 0 100 100 + +begin_block predraw +setRenderHint Antialiasing +setPen nopen +gradient_clearStops +gradient_appendStop 0 efff0000 +gradient_appendStop 0.5 dfffff00 +gradient_appendStop 1 ef00ff00 + +gradient_setSpread PadSpread +gradient_setLinear 10 10 90 90 +drawEllipse 10 10 80 80 +end_block + +setCompositionMode SourceOver + +begin_block postdraw + +gradient_clearStops +gradient_appendStop 0 afff0000 +gradient_appendStop 0.5 cf0000ff +gradient_appendStop 1 bf00ff00 + +gradient_setSpread PadSpread +gradient_setLinear 0 0 100 0 +drawEllipse 10 10 30 30 +drawEllipse 10 60 30 30 +drawEllipse 60 60 30 30 +drawEllipse 60 10 30 30 +drawEllipse 35 35 30 30 + +# a black rectangle around +setCompositionMode SourceOver +setPen black +setBrush nobrush +drawRect 0.5 0.5 99 99 + +end_block +surface_end + +# Destination over +surface_begin 100 0 100 100 +repeat_block predraw +setCompositionMode DestinationOver +repeat_block postdraw +surface_end + + +# Clear +surface_begin 200 0 100 100 +repeat_block predraw +setCompositionMode Clear +repeat_block postdraw +surface_end + + +# Source +surface_begin 300 0 100 100 +repeat_block predraw +setCompositionMode Source +repeat_block postdraw +surface_end + + +# Destination +surface_begin 400 0 100 100 +repeat_block predraw +setCompositionMode Destination +repeat_block postdraw +surface_end + + +# Source In +surface_begin 500 0 100 100 +repeat_block predraw +setCompositionMode SourceIn +repeat_block postdraw +surface_end + +translate 0 50 + +# Destination In +surface_begin 0 100 100 100 +repeat_block predraw +setCompositionMode DestinationIn +repeat_block postdraw +surface_end + + +# Source Out +surface_begin 100 100 100 100 +repeat_block predraw +setCompositionMode SourceOut +repeat_block postdraw +surface_end + + +# Destination Out +surface_begin 200 100 100 100 +repeat_block predraw +setCompositionMode DestinationOut +repeat_block postdraw +surface_end + + +# SourceAtop +surface_begin 300 100 100 100 +repeat_block predraw +setCompositionMode SourceAtop +repeat_block postdraw +surface_end + + +# DestinationAtop +surface_begin 400 100 100 100 +repeat_block predraw +setCompositionMode DestinationAtop +repeat_block postdraw +surface_end + + +# Xor +surface_begin 500 100 100 100 +repeat_block predraw +setCompositionMode Xor +repeat_block postdraw +surface_end + +translate 0 50 + +# Plus +surface_begin 0 200 100 100 +repeat_block predraw +setCompositionMode Plus +repeat_block postdraw +surface_end + + +# Multiply +surface_begin 100 200 100 100 +repeat_block predraw +setCompositionMode Multiply +repeat_block postdraw +surface_end + + +# Screen +surface_begin 200 200 100 100 +repeat_block predraw +setCompositionMode Screen +repeat_block postdraw +surface_end + + +# Overlay +surface_begin 300 200 100 100 +repeat_block predraw +setCompositionMode Overlay +repeat_block postdraw +surface_end + + +# Darken +surface_begin 400 200 100 100 +repeat_block predraw +setCompositionMode Darken +repeat_block postdraw +surface_end + + +# Lighten +surface_begin 500 200 100 100 +repeat_block predraw +setCompositionMode Lighten +repeat_block postdraw +surface_end + +translate 0 50 + +# ColorDodge +surface_begin 0 300 100 100 +repeat_block predraw +setCompositionMode ColorDodge +repeat_block postdraw +surface_end + + +# Multiply +surface_begin 100 300 100 100 +repeat_block predraw +setCompositionMode ColorBurn +repeat_block postdraw +surface_end + + +# Screen +surface_begin 200 300 100 100 +repeat_block predraw +setCompositionMode HardLight +repeat_block postdraw +surface_end + + +# Overlay +surface_begin 300 300 100 100 +repeat_block predraw +setCompositionMode SoftLight +repeat_block postdraw +surface_end + + +# Darken +surface_begin 400 300 100 100 +repeat_block predraw +setCompositionMode Difference +repeat_block postdraw +surface_end + + +# Lighten +surface_begin 500 300 100 100 +repeat_block predraw +setCompositionMode Exclusion +repeat_block postdraw +surface_end + +resetMatrix + +drawText 0 50 "SourceOver" +drawText 100 50 "DestinationOver" +drawText 200 50 "Clear" +drawText 300 50 "Source" +drawText 400 50 "Destination" +drawText 500 50 "SourceIn" +drawText 0 200 "DestinationIn" +drawText 100 200 "SourceOut" +drawText 200 200 "DestinationOut" +drawText 300 200 "SourceAtop" +drawText 400 200 "DestinationAtop" +drawText 500 200 "Xor" +drawText 0 350 "Plus" +drawText 100 350 "Multiply" +drawText 200 350 "Screen" +drawText 300 350 "Overlay" +drawText 400 350 "Darken" +drawText 500 350 "Lighten" +drawText 0 500 "ColorDodge" +drawText 100 500 "ColorBurn" +drawText 200 500 "HardLight" +drawText 300 500 "SoftLight" +drawText 400 500 "Difference" +drawText 500 500 "Exclusion" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/primitives.qps b/tests/auto/lancelot/scripts/primitives.qps new file mode 100644 index 0000000..f44ba27 --- /dev/null +++ b/tests/auto/lancelot/scripts/primitives.qps @@ -0,0 +1,184 @@ +# Version: 1#Version: 1 +# CheckVsReference: 5% + + +# CheckVsReference: 5% + +setBrush #ff7f7fff +setPen black 1 solidline +translate 20 20 +begin_block testblock +save +drawRect 0 0 10 10 +drawRect 20 0 20 10 +drawRect 0 20 10 20 +drawRect 20 20 20 20 +translate 50 0 +setPen NoPen +drawRect 0 0 10 10 +drawRect 20 0 20 10 +drawRect 0 20 10 20 +drawRect 20 20 20 20 +restore +save +translate 0 50 +drawEllipse 0 0 10 10 +drawEllipse 20 0 20 10 +drawEllipse 0 20 10 20 +drawEllipse 20 20 20 20 +translate 50 0 +setPen NoPen +drawEllipse 0 0 10 10 +drawEllipse 20 0 20 10 +drawEllipse 0 20 10 20 +drawEllipse 20 20 20 20 +restore +save +translate 0 100 +drawPolygon [ 0 0 30 0 30 30 10 30 10 10 40 10 40 40 0 40 ] +save +translate 0 50 +drawPolygon [ 0 0 30 0 30 30 10 30 10 10 40 10 40 40 0 40 ] Winding +translate 0 45 +drawPolyline [ 0 0 50 0 25 25 ] +restore +setPen NoPen +translate 50 0 +drawPolygon [ 0 0 30 0 30 30 10 30 10 10 40 10 40 40 0 40 ] +save +translate 0 50 +drawPolygon [ 0 0 30 0 30 30 10 30 10 10 40 10 40 40 0 40 ] Winding +restore +save +translate -20 100 +drawPie 0 0 50 50 0 1500 +restore +restore +end_block +setPen black 1 SolidLine FlatCap +translate 200 0 +scale 2 1 +rotate 10 +repeat_block testblock +resetMatrix +translate 0 250 +setBrush 7f7f7fff +translate 20 20 +repeat_block testblock +setPen black 1 SolidLine FlatCap +translate 200 0 +scale 2 1 +rotate 10 +repeat_block testblock +resetMatrix +save +setRenderHint LineAntialiasing +setBrush 7f7fff +translate 20 500 +repeat_block testblock +translate 200 0 +scale 2 1 +rotate 10 +repeat_block testblock +restore +setRenderHint LineAntialiasing false +translate 420 20 +begin_block lines +drawLine 0 0 100 0 +drawLine 0 0 100 10 +drawLine 0 0 100 20 +drawLine 0 0 100 30 +drawLine 0 0 100 40 +drawLine 0 0 100 50 +drawLine 0 0 100 60 +drawLine 0 0 100 70 +drawLine 0 0 100 80 +drawLine 0 0 100 90 +drawLine 0 0 100 100 +drawLine 0 0 90 100 +drawLine 0 0 80 100 +drawLine 0 0 70 100 +drawLine 0 0 60 100 +drawLine 0 0 50 100 +drawLine 0 0 40 100 +drawLine 0 0 30 100 +drawLine 0 0 20 100 +drawLine 0 0 10 100 +drawLine 0 0 0 100 +end_block +setRenderHint LineAntialiasing +translate 0 120 +repeat_block lines +translate 0 120 +scale 5 2 +repeat_block lines +resetMatrix +translate 420 500 +begin_block roundedrects +save +drawRoundedRect 0 0 50 30 5 5 +translate 60 0 +drawRoundedRect 0 0 50 30 7.5 7.5 +translate 60 0 +drawRoundedRect 0 0 50 30 10 10 +translate 60 0 +drawRoundedRect 0 0 50 30 12.5 12.5 +translate 60 0 +drawRoundedRect 0 0 50 30 15 15 +restore +save +translate 0 40 +drawRoundedRect 0 0 50 30 20 20 RelativeSize +translate 60 0 +drawRoundedRect 0 0 50 30 40 40 RelativeSize +translate 60 0 +drawRoundedRect 0 0 50 30 60 60 RelativeSize +translate 60 0 +drawRoundedRect 0 0 50 30 80 80 RelativeSize +translate 60 0 +drawRoundedRect 0 0 50 30 100 100 RelativeSize +restore +end_block +translate 0.5 80.5 +repeat_block roundedrects +translate -0.5 79.5 +setRenderHint Antialiasing off +repeat_block roundedrects +resetMatrix +setRenderHint Antialiasing off +setPen black 1 +begin_block drawShapes +translate 550.5 25 +rotate 45 +setBrush nobrush +drawEllipse -10 -10 20 20 +drawLine 10 0 50 0 +drawRect 50 -7 14 14 +resetMatrix +end_block +setPen black 2 +translate 25 0 +repeat_block drawShapes +setPen black 3 +translate 50 0 +repeat_block drawShapes +setPen black 4 +translate 75 0 +repeat_block drawShapes +resetMatrix +setRenderHint Antialiasing off +setPen nopen +translate 550 100 +setBrush #7f7f7fff +drawRect -0.5 -0.5 21 21 +setBrush red +drawEllipse 0 0 20 20 +setBrush nobrush +setPen black +drawEllipse 0 0 20 20 +translate 25 0 +setPen nopen +setBrush #7f7f7fff +drawRect 0 0 20 20 +setBrush red +drawEllipse 0 0 20 20 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/radial_gradients.qps b/tests/auto/lancelot/scripts/radial_gradients.qps new file mode 100644 index 0000000..b55df8b --- /dev/null +++ b/tests/auto/lancelot/scripts/radial_gradients.qps @@ -0,0 +1,99 @@ +# Version: 1 +# CheckVsReference: 5% (0 0 600 400) + +path_addRect path 400 0 80 80 +path_addEllipse path 440 40 60 60 + +setRenderHint Antialiasing + +setPen black + +begin_block gradients +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setRadial 20 20 50 40 40 +drawRect 0 0 100 100 + +gradient_setSpread ReflectSpread +gradient_setRadial 120 20 50 140 40 +drawEllipse 100 0 100 100 + +gradient_setSpread RepeatSpread +gradient_setRadial 220 20 50 240 40 +drawRoundRect 200 0 100 100 + +gradient_clearStops +gradient_appendStop 0 3f7f7fff +gradient_appendStop 0.5 dfdfffff +gradient_appendStop 1 7f00007f + +gradient_setSpread PadSpread +gradient_setRadial 320 20 50 340 40 +drawPolygon [300 0 390 0 350 99] + +gradient_setSpread ReflectSpread +gradient_setRadial 420 20 50 440 40 +drawPath path + +gradient_setSpread RepeatSpread +gradient_setRadial 520 20 50 540 40 +drawPie 500 0 100 100 720 4320 +end_block + +translate 0 100 +scale 1 2 +repeat_block gradients + +resetMatrix +translate 0 300 +brushTranslate 30 0 +brushScale 0.9 0.9 +brushRotate 20 +repeat_block gradients + +# Some helpful info perhaps? +resetMatrix +setPen black + +drawText 610 50 "No XForm" +drawText 610 200 "scale 1x2" +drawText 610 300 "brush transform" +drawText 10 450 "Pad" +drawText 110 450 "Reflect" +drawText 210 450 "Repeat" +drawText 310 450 "Pad w/alpha" +drawText 410 450 "Reflect w/alpha" +drawText 510 450 "Repeat w/alpha" + +# Radius and focal indicators +setPen 3f000000 +setBrush nobrush + +begin_block ellipse_draw +setClipRect 0 0 100 100 +drawEllipse -30 -30 100 100 +drawEllipse 35 35 11 11 +translate 100 0 +end_block + +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw + +resetMatrix +translate 0 100 +scale 1 2 +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw +repeat_block ellipse_draw \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/radial_gradients_perspectives.qps b/tests/auto/lancelot/scripts/radial_gradients_perspectives.qps new file mode 100644 index 0000000..4557354 --- /dev/null +++ b/tests/auto/lancelot/scripts/radial_gradients_perspectives.qps @@ -0,0 +1,62 @@ +# Version: 1 + + +setRenderHint Antialiasing + +setPen #00ff00 + +translate 10 10 +# standard draw +begin_block gradient +gradient_clearStops +gradient_appendStop 0 red +gradient_appendStop 0.25 orange +gradient_appendStop 0.5 yellow +gradient_appendStop 0.8 green +gradient_appendStop 1 cyan + +gradient_setSpread PadSpread +gradient_setRadial 110 100 230 230 240 +drawRect 0 0 300 300 +end_block gradient + +# Rotation w/o smooth xform +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 50 0 200 300 300 300 0 + repeat_block gradient +restore +restore + +translate 0 320 + +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 100 300 200 300 300 0 + repeat_block gradient +restore + +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 0 300 300 250 300 50 + repeat_block gradient +restore +restore + + +resetMatrix +setPen black +translate 125 20 +drawText 0 0 "No transform" +translate 350 0 +drawText 0 0 "Left Tilted" +resetMatrix +translate 125 350 +drawText 0 0 "Bottom Tilted" +translate 350 0 +drawText 0 0 "Right Tilted" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/rasterops.qps b/tests/auto/lancelot/scripts/rasterops.qps new file mode 100644 index 0000000..21f943b --- /dev/null +++ b/tests/auto/lancelot/scripts/rasterops.qps @@ -0,0 +1,87 @@ +# Version: 1 +# CheckVsReference: 5% + +setPen NoPen + +setBrush black +drawRect 10 10 60 500 + +setCompositionMode SourceOrDestination +translate 20 20 + +begin_block drawShape + setBrush 0xffff0000 + drawEllipse 5 5 30 30 + setBrush 0xff00ff00 + drawRect 0 0 20 20 + setBrush 0xff0000ff + drawRect 20 20 20 20 +end_block + +begin_block loop + setCompositionMode SourceAndDestination + translate 0 50 +repeat_block drawShape + +setCompositionMode SourceXorDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceAndNotDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceOrNotDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceXorDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSource +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceAndDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode SourceAndNotDestination +translate 0 50 +repeat_block drawShape +end_block + +resetMatrix +setCompositionMode Source +setBrush white +drawRect 100 10 60 500 +translate 110 20 +repeat_block loop + +resetMatrix +setCompositionMode Source +translate 190 20 +repeat_block loop + +resetMatrix +setPen black +setCompositionMode SourceOver +translate 250 45 +drawText 20 0 "Or ROP" +translate 0 50 +drawText 20 0 "And ROP" +translate 0 50 +drawText 20 0 "Xor ROP" +translate 0 50 +drawText 20 0 "Nor ROP" +translate 0 50 +drawText 20 0 "Nand ROP" +translate 0 50 +drawText 0 0 "NSrcXorDst ROP" +translate 0 50 +drawText 20 0 "NSrc ROP" +translate 0 50 +drawText 0 0 "NSrcAndDst ROP" +translate 0 50 +drawText 0 0 "SrcAndNDst ROP" \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/sizes.qps b/tests/auto/lancelot/scripts/sizes.qps new file mode 100644 index 0000000..b923881 --- /dev/null +++ b/tests/auto/lancelot/scripts/sizes.qps @@ -0,0 +1,150 @@ +# Version: 1 +# CheckVsReference: 5% + +setPen NoPen +setBrush black + +translate 10 10 + +begin_block testblock +drawRect 0 0 10 10 +drawRect 20 0 11 11 +drawRect 40 0 12 12 +drawRect 60 0 13 13 +drawRect 80 0 14 14 +drawRect 100 0 15 15 +drawRect 120 0 16 16 +drawRect 140 0 17 17 +drawRect 160 0 18 18 +drawRect 180 0 19 19 +qt3_drawRect 200 0 10 10 +qt3_drawRect 220 0 11 11 +qt3_drawRect 240 0 12 12 +qt3_drawRect 260 0 13 13 +qt3_drawRect 280 0 14 14 +qt3_drawRect 300 0 15 15 +qt3_drawRect 320 0 16 16 +qt3_drawRect 340 0 17 17 +qt3_drawRect 360 0 18 18 +qt3_drawRect 380 0 19 19 + +drawEllipse 0 20 10 10 +drawEllipse 20 20 11 11 +drawEllipse 40 20 12 12 +drawEllipse 60 20 13 13 +drawEllipse 80 20 14 14 +drawEllipse 100 20 15 15 +drawEllipse 120 20 16 16 +drawEllipse 140 20 17 17 +drawEllipse 160 20 18 18 +drawEllipse 180 20 19 19 +qt3_drawEllipse 200 20 10 10 +qt3_drawEllipse 220 20 11 11 +qt3_drawEllipse 240 20 12 12 +qt3_drawEllipse 260 20 13 13 +qt3_drawEllipse 280 20 14 14 +qt3_drawEllipse 300 20 15 15 +qt3_drawEllipse 320 20 16 16 +qt3_drawEllipse 340 20 17 17 +qt3_drawEllipse 360 20 18 18 +qt3_drawEllipse 380 20 19 19 + +drawRoundRect 0 40 10 10 +drawRoundRect 20 40 11 11 +drawRoundRect 40 40 12 12 +drawRoundRect 60 40 13 13 +drawRoundRect 80 40 14 14 +drawRoundRect 100 40 15 15 +drawRoundRect 120 40 16 16 +drawRoundRect 140 40 17 17 +drawRoundRect 160 40 18 18 +drawRoundRect 180 40 19 19 +qt3_drawRoundRect 200 40 10 10 +qt3_drawRoundRect 220 40 11 11 +qt3_drawRoundRect 240 40 12 12 +qt3_drawRoundRect 260 40 13 13 +qt3_drawRoundRect 280 40 14 14 +qt3_drawRoundRect 300 40 15 15 +qt3_drawRoundRect 320 40 16 16 +qt3_drawRoundRect 340 40 17 17 +qt3_drawRoundRect 360 40 18 18 +qt3_drawRoundRect 380 40 19 19 + +drawPie 0 60 10 10 0 4320 +drawPie 20 60 11 11 0 4320 +drawPie 40 60 12 12 0 4320 +drawPie 60 60 13 13 0 4320 +drawPie 80 60 14 14 0 4320 +drawPie 100 60 15 15 0 4320 +drawPie 120 60 16 16 0 4320 +drawPie 140 60 17 17 0 4320 +drawPie 160 60 18 18 0 4320 +drawPie 180 60 19 19 0 4320 +qt3_drawPie 200 60 10 10 0 4320 +qt3_drawPie 220 60 11 11 0 4320 +qt3_drawPie 240 60 12 12 0 4320 +qt3_drawPie 260 60 13 13 0 4320 +qt3_drawPie 280 60 14 14 0 4320 +qt3_drawPie 300 60 15 15 0 4320 +qt3_drawPie 320 60 16 16 0 4320 +qt3_drawPie 340 60 17 17 0 4320 +qt3_drawPie 360 60 18 18 0 4320 +qt3_drawPie 380 60 19 19 0 4320 + +drawArc 0 80 10 10 0 4320 +drawArc 20 80 11 11 0 4320 +drawArc 40 80 12 12 0 4320 +drawArc 60 80 13 13 0 4320 +drawArc 80 80 14 14 0 4320 +drawArc 100 80 15 15 0 4320 +drawArc 120 80 16 16 0 4320 +drawArc 140 80 17 17 0 4320 +drawArc 160 80 18 18 0 4320 +drawArc 180 80 19 19 0 4320 +qt3_drawArc 200 80 10 10 0 4320 +qt3_drawArc 220 80 11 11 0 4320 +qt3_drawArc 240 80 12 12 0 4320 +qt3_drawArc 260 80 13 13 0 4320 +qt3_drawArc 280 80 14 14 0 4320 +qt3_drawArc 300 80 15 15 0 4320 +qt3_drawArc 320 80 16 16 0 4320 +qt3_drawArc 340 80 17 17 0 4320 +qt3_drawArc 360 80 18 18 0 4320 +qt3_drawArc 380 80 19 19 0 4320 + +drawChord 0 100 10 10 0 4320 +drawChord 20 100 11 11 0 4320 +drawChord 40 100 12 12 0 4320 +drawChord 60 100 13 13 0 4320 +drawChord 80 100 14 14 0 4320 +drawChord 100 100 15 15 0 4320 +drawChord 120 100 16 16 0 4320 +drawChord 140 100 17 17 0 4320 +drawChord 160 100 18 18 0 4320 +drawChord 180 100 19 19 0 4320 +qt3_drawChord 200 100 10 10 0 4320 +qt3_drawChord 220 100 11 11 0 4320 +qt3_drawChord 240 100 12 12 0 4320 +qt3_drawChord 260 100 13 13 0 4320 +qt3_drawChord 280 100 14 14 0 4320 +qt3_drawChord 300 100 15 15 0 4320 +qt3_drawChord 320 100 16 16 0 4320 +qt3_drawChord 340 100 17 17 0 4320 +qt3_drawChord 360 100 18 18 0 4320 +qt3_drawChord 380 100 19 19 0 4320 + +end_block + +setPen red +translate 0 150 +repeat_block testblock + +setRenderHint LineAntialiasing + +setPen nopen +translate 0 150 +repeat_block testblock + +setPen red +translate 0 150 +repeat_block testblock \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/text.qps b/tests/auto/lancelot/scripts/text.qps new file mode 100644 index 0000000..d7ee832 --- /dev/null +++ b/tests/auto/lancelot/scripts/text.qps @@ -0,0 +1,124 @@ +# Version: 1 + +drawText -5 5 "Text that is drawn outside the bounds..." + +translate 20 20 +begin_block text_drawing +save + setFont "sansserif" 10 normal + drawText 0 20 "sansserif 10pt, normal" + + setFont "sansserif" 12 normal + drawText 0 40 "sansserif 12pt, normal" + + setFont "sansserif" 10 bold + drawText 0 60 "sansserif 12pt, bold" + + setFont "sansserif" 10 bold italic + drawText 0 80 "sansserif 10pt, bold italic" + + + translate 0 100 + setPen #7fff0000 + + setFont "sansserif" 10 normal + drawText 0 20 "alpha sansserif 10pt, normal" + + setFont "sansserif" 12 normal + drawText 0 40 "alpha sansserif 12pt, normal" + + setFont "sansserif" 10 bold + drawText 0 60 "alpha sansserif 12pt, bold" + + setFont "sansserif" 10 bold italic + drawText 0 80 "alpha sansserif 10pt, bold italic" + + + translate 0 100 + setPen black + save + scale 0.9 0.9 + + setFont "sansserif" 10 normal + drawText 0 20 "scaled sansserif 10pt, normal" + + setFont "sansserif" 12 normal + drawText 0 40 "scaled sansserif 12pt, normal" + + setFont "sansserif" 10 bold + drawText 0 60 "scaled sansserif 12pt, bold" + + setFont "sansserif" 10 bold italic + drawText 0 80 "scaled sansserif 10pt, bold italic" + restore + + translate 0 100 + setPen black + save + translate 200 90 + rotate 185 + + setFont "sansserif" 10 normal + drawText 0 20 "scaled sansserif 10pt, normal" + + setFont "sansserif" 12 normal + drawText 0 40 "scaled sansserif 12pt, normal" + + setFont "sansserif" 10 bold + drawText 0 60 "scaled sansserif 12pt, bold" + + setFont "sansserif" 10 bold italic + drawText 0 80 "scaled sansserif 10pt, bold italic" + restore + + translate 0 100 + gradient_appendStop 0 red + gradient_appendStop 0.5 #00ff00 + gradient_appendStop 1 blue + gradient_setLinear 0 0 200 0 + setPen brush + + setFont "sansserif" 10 normal + drawText 0 0 "gradient sansserif 10pt, normal" + + setFont "sansserif" 12 normal + drawText 0 20 "gradient sansserif 12pt, normal" + + setFont "sansserif" 10 bold + drawText 0 40 "gradient sansserif 12pt, bold" + + setFont "sansserif" 10 bold italic + drawText 0 60 "gradient sansserif 10pt, bold italic" +restore +end_block + +translate 250 0 +drawText 25 520 "clipped to rectangle" +save + setPen #3f000000 + setBrush nobrush + drawRect 20 0 100 500 + setClipRect 20 0 100 500 + setPen black + repeat_block text_drawing +restore + +translate 150 0 +drawText 25 520 "clipped to path" +save + path_moveTo clip 20 0 + path_cubicTo clip 0 200 40 400 20 400 + path_lineTo clip 30 500 + path_lineTo clip 30 0 + path_lineTo clip 40 0 + path_lineTo clip 40 500 + path_lineTo clip 120 500 + path_lineTo clip 120 0 + path_lineTo clip 20 0 + setPen #3f000000 + setBrush nobrush + drawPath clip + setClipPath clip + setPen black + repeat_block text_drawing +restore \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/text_perspectives.qps b/tests/auto/lancelot/scripts/text_perspectives.qps new file mode 100644 index 0000000..4c74306 --- /dev/null +++ b/tests/auto/lancelot/scripts/text_perspectives.qps @@ -0,0 +1,102 @@ +# Version: 1 + + +setRenderHint Antialiasing + +setPen black + +translate 10 10 +# standard draw +begin_block text +setBrush gray +drawRect 0 0 300 300 + +setFont "times" 3 +drawText 10 10 "Hello World...." + +setFont "times" 4 +drawText 10 20 "Hello World...." + +setFont "times" 5 +drawText 10 30 "Hello World...." + +setFont "times" 6 +drawText 10 40 "Hello World...." + +setFont "times" 7 +drawText 10 50 "Hello World...." + +setFont "times" 8 +drawText 10 60 "Hello World...." + +setFont "times" 9 +drawText 10 70 "Hello World...." + +setFont "times" 10 +drawText 10 80 "Hello World...." + +setFont "times" 16 +drawText 10 100 "Hello World...." + +setFont "times" 17 +drawText 10 120 "Hello World...." + +setFont "times" 18 +drawText 10 140 "Hello World...." + +setFont "times" 20 +drawText 10 160 "Hello World...." + +setFont "times" 22 +drawText 10 180 "Hello World...." + +setFont "times" 24 +drawText 10 205 "Hello World...." + +setFont "times" 26 +drawText 10 230 "Hello World...." + +setFont "times" 32 +drawText 10 260 "Hello World...." +end_block text + +# Rotation w/o smooth xform +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 50 0 200 300 300 300 0 + repeat_block text +restore +restore + +translate 0 320 + +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 100 300 200 300 300 0 + repeat_block text +restore + +save +translate 350 0 +save + setRenderHint SmoothPixmapTransform on + mapQuadToQuad 0 0 0 300 300 300 300 0 0 0 0 300 300 250 300 50 + repeat_block text +restore +restore + + +resetMatrix +setPen black +translate 125 20 +drawText 0 0 "No transform" +translate 350 0 +drawText 0 0 "Left Tilted" +resetMatrix +translate 125 350 +drawText 0 0 "Bottom Tilted" +translate 350 0 +drawText 0 0 "Right Tilted" +translate 120 0 \ No newline at end of file diff --git a/tests/auto/lancelot/scripts/tiled_pixmap.qps b/tests/auto/lancelot/scripts/tiled_pixmap.qps new file mode 100644 index 0000000..9cb5e0d --- /dev/null +++ b/tests/auto/lancelot/scripts/tiled_pixmap.qps @@ -0,0 +1,84 @@ +# Version: 1 +# CheckVsReference: 5% (0 0 639 638) + + +translate 0 10 +setRenderHint Antialiasing + +pixmap_load dome_argb32 the_pixmap + +begin_block draw_stuff +save + + # Standard draw + drawTiledPixmap the_pixmap 0 0 150 100 0 0 + + # Standard draw with offset + translate 160 0 + drawTiledPixmap the_pixmap 0 0 150 100 25 25 + + # xformed + translate 160 0 + save + translate 10 -10 + rotate 10 + setRenderHint SmoothPixmapTransform false + drawTiledPixmap the_pixmap 0 0 150 100 25 25 + restore + + # xformed with smooth xform + translate 160 0 + save + translate 10 -10 + rotate 10 + setRenderHint SmoothPixmapTransform + drawTiledPixmap the_pixmap 0 0 150 100 25 25 + restore +restore +end_block + +translate 0 120 +pixmap_load dome_rgb32 the_pixmap +repeat_block draw_stuff + + +translate 0 120 +pixmap_load dome_indexed the_pixmap +repeat_block draw_stuff + + +translate 0 120 +pixmap_load dome_indexed_mask the_pixmap +repeat_block draw_stuff + + +translate 0 120 +pixmap_load dome_mono the_pixmap +repeat_block draw_stuff + + +################################################################################ +# Some helpful text... +# + +resetMatrix +translate 650 80 +drawText 0 0 "32 bit w/alpha" +translate 0 120 +drawText 0 0 "32 bit w/o alpha" +translate 0 120 +drawText 0 0 "8 bit indexed" +translate 0 120 +drawText 0 0 "8 bit indexed w/mask" +translate 0 120 +drawText 0 0 "1 bit" + +resetMatrix +translate 10 630 +drawText 0 0 "normal" +translate 160 0 +drawText 0 0 "offset" +translate 160 0 +drawText 0 0 "xformed" +translate 160 0 +drawText 0 0 "smooth xformed" diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp new file mode 100644 index 0000000..1b832c6 --- /dev/null +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Generalization dimensions TBD: +// ImageFormat: Rendering to different bit formats +// Engine: Rendering with different engines +// Painter renderhints? (set in qps itself) + +#include +#include +#include +#include +#include + +#ifndef SRCDIR +#define SRCDIR "." +#endif + +static const QLatin1String scriptsDir(SRCDIR "/scripts/"); + +class tst_Lancelot : public QObject +{ +Q_OBJECT + +public: + tst_Lancelot(); + +private: + QImage getBaseline(const QString &fileName, bool *created); + QImage render(const QString &fileName); + QStringList loadScriptFile(const QString &filePath); + + QString errorMsg; + BaselineProtocol proto; + +private slots: + void initTestCase(); + void cleanupTestCase() {} + + void testRendering_data(); + void testRendering(); +}; + +tst_Lancelot::tst_Lancelot() +{ +} + +void tst_Lancelot::initTestCase() +{ +#if !defined(Q_OS_LINUX) + QSKIP("For the moment, this test is only supported on Linux.", SkipAll); +#endif + + // Check the environment here, so that we can just skip on trouble! + if (!proto.connect()) { + QWARN(qPrintable(proto.errorMessage())); + QSKIP("Communication with baseline image server failed.", SkipAll); + } + + // TBD: preload scripts, to confirm reading and generate checksums +} + +void tst_Lancelot::testRendering_data() +{ + // search the data directory for qps files and make a row for each. + // filter out those marked as blacklisted (in the file itself?) + // Rather do the above in initTestCase. Can load & split them all also. + // And baselines too? + + QTest::addColumn("fileName"); + + // ### no, don't do it like this, we want opt-in, not opt-out, for stability + QDir qpsDir(scriptsDir); + QStringList files = qpsDir.entryList(QStringList() << QLatin1String("*.qps"), QDir::Files | QDir::Readable); + files.removeOne(QLatin1String("porter_duff.qps")); + files.removeOne(QLatin1String("porter_duff2.qps")); + files.removeOne(QLatin1String("images.qps")); + files.removeOne(QLatin1String("sizes.qps")); + + if (files.isEmpty()) { + QWARN("No qps files found in " + qpsDir.path().toLatin1()); + QSKIP("Aborted due to errors.", SkipAll); + } + + foreach(QString fileName, files) { + QString baseName = fileName.section('.', 0, -2); + QTest::newRow(baseName.toLatin1()) << fileName; + } +} + + +// We treat failures because of test environment +// (e.g. script files not found) as just warnings, and not +// QFAILs, to avoid false negatives caused by environment +// or server instability + +void tst_Lancelot::testRendering() +{ + errorMsg.clear(); + QFETCH(QString, fileName); + + bool newBaselineCreated = false; + QImage baseline = getBaseline(fileName, &newBaselineCreated); + if (newBaselineCreated) + QSKIP("Baseline not found; new baseline created.", SkipSingle); + if (!errorMsg.isNull() || baseline.isNull()) { + QWARN("Error: Failed to get baseline image. " + errorMsg.toLatin1()); + QSKIP("Aborted due to errors.", SkipSingle); + } + + QImage rendered = render(fileName); + if (!errorMsg.isNull() || rendered.isNull()) { + // Indicates that it's an error in the test environment, not Qt + QWARN("Error: Failed to render image. " + errorMsg.toLatin1()); + QSKIP("Aborted due to errors.", SkipSingle); + } + + if (rendered.format() != baseline.format()) + baseline = baseline.convertToFormat(rendered.format()); + + // The actual check: + if (rendered != baseline) { + QByteArray failMsg; + proto.submitMismatch(fileName, rendered, &failMsg); + failMsg.prepend("Rendered image differs from baseline. "); + QFAIL(failMsg.constData()); + } +} + + +QImage tst_Lancelot::getBaseline(const QString &fileName, bool *created) +{ + QImage baseline; + BaselineProtocol::Command response; + if (!proto.requestBaseline(fileName, &response, &baseline)) { + errorMsg = QLatin1String("Error downloading baseline from server. ") + proto.errorMessage(); + return QImage(); + } + + if (response == BaselineProtocol::BaselineNotPresent) { + // Here: Create new baseline! + baseline = render(fileName); + if (!errorMsg.isNull() || baseline.isNull()) { + errorMsg.prepend(QLatin1String("Failed to render new baseline. ")); + return QImage(); + } + if (!proto.submitNewBaseline(fileName, baseline)) { + errorMsg = QLatin1String("Failed to submit new baseline to server. ") + proto.errorMessage(); + return QImage(); + } + if (created) + *created = true; + } + else if (response == BaselineProtocol::IgnoreCase) { + // Blacklisted or similar, signal back that this item should be skipped + // Will effectively happen with this: + errorMsg = QLatin1String("Baseline server says skip this"); + return QImage(); + } + else if (response != BaselineProtocol::AcceptBaseline) { + errorMsg = QLatin1String("Unknown response from baseline server. "); + return QImage(); + } + return baseline; +} + + +QImage tst_Lancelot::render(const QString &fileName) +{ + QString filePath = scriptsDir + fileName; + QStringList script = loadScriptFile(filePath); + if (script.isEmpty()) + return QImage(); + + QImage img(800, 800, QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + PaintCommands pcmd(script, 800, 800); + pcmd.setPainter(&p); + pcmd.setFilePath(QFileInfo(filePath).absoluteFilePath()); // eh yuck + pcmd.runCommands(); + p.end(); + + return img; +} + + +QStringList tst_Lancelot::loadScriptFile(const QString &filePath) +{ + QFile file(filePath); + if (!file.open(QFile::ReadOnly)) { + errorMsg = QLatin1String("Failed to open script file ") + filePath; + return QStringList(); + } + //# use the new readscript function instead? + QTextStream stream(&file); + return stream.readAll().split(QLatin1Char('\n'), QString::SkipEmptyParts); +} + +QTEST_MAIN(tst_Lancelot) +#include "tst_lancelot.moc" diff --git a/tests/auto/other.pro b/tests/auto/other.pro index 3c8f856..d1a7a86 100644 --- a/tests/auto/other.pro +++ b/tests/auto/other.pro @@ -4,6 +4,7 @@ TEMPLATE=subdirs SUBDIRS=\ # exceptionsafety_objects \ shouldn't enable it + lancelot \ qaccessibility \ qalgorithms \ qcombobox \ -- cgit v0.12 From 619f8eec497538a3efb6cd36b12b16c6ce02cd88 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 25 Aug 2010 15:21:58 +0200 Subject: Use a remote test server during dev, plus some housekeeping --- tests/arthur/.gitignore | 2 ++ tests/arthur/baselineserver/.gitignore | 2 ++ tests/arthur/baselineserver/src/baselineserver.cpp | 24 +++++++++++++--------- tests/arthur/baselineserver/src/baselineserver.h | 1 + tests/arthur/common/baselineprotocol.cpp | 4 ++-- tests/auto/lancelot/.gitignore | 1 + 6 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 tests/arthur/.gitignore create mode 100644 tests/arthur/baselineserver/.gitignore create mode 100644 tests/auto/lancelot/.gitignore diff --git a/tests/arthur/.gitignore b/tests/arthur/.gitignore new file mode 100644 index 0000000..7f0c1fa --- /dev/null +++ b/tests/arthur/.gitignore @@ -0,0 +1,2 @@ +bin/shower +lance/lance diff --git a/tests/arthur/baselineserver/.gitignore b/tests/arthur/baselineserver/.gitignore new file mode 100644 index 0000000..cc513e0 --- /dev/null +++ b/tests/arthur/baselineserver/.gitignore @@ -0,0 +1,2 @@ +storage +bin/baselineserver diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index bba2cd8..f7293a2 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -79,24 +79,28 @@ BaselineHandler::BaselineHandler(int socketDescriptor) proto.socket.setSocketDescriptor(socketDescriptor); } +QString BaselineHandler::logtime() +{ + return QTime::currentTime().toString(QLatin1String("mm:ss.zzz")); +} void BaselineHandler::receiveRequest() { if (!connectionEstablished) { if (!proto.acceptConnection(&plat)) { - qWarning() << runId << "Accepting new connection failed. " << proto.errorMessage(); + qWarning() << runId << logtime() << "Accepting new connection failed. " << proto.errorMessage(); QThread::currentThread()->exit(1); return; } connectionEstablished = true; - qDebug() << runId << "Connection established with" << plat.hostname << "Qt version:" << plat.qtVersion << plat.buildKey; + qDebug() << runId << logtime() << "Connection established with" << plat.hostname << "Qt version:" << plat.qtVersion << plat.buildKey; return; } QByteArray block; BaselineProtocol::Command cmd; if (!proto.receiveBlock(&cmd, &block)) { - qWarning() << runId << "Command reception failed. "<< proto.errorMessage(); + qWarning() << runId << logtime() << "Command reception failed. "<< proto.errorMessage(); QThread::currentThread()->exit(1); return; } @@ -112,7 +116,7 @@ void BaselineHandler::receiveRequest() storeImage(block, false); break; default: - qWarning() << runId << "Unknown command received. " << proto.errorMessage(); + qWarning() << runId << logtime() << "Unknown command received. " << proto.errorMessage(); QThread::currentThread()->exit(1); } } @@ -120,11 +124,11 @@ void BaselineHandler::receiveRequest() void BaselineHandler::provideBaseline(const QByteArray &caseId) { - qDebug() << runId << "Received request for baseline" << caseId; + qDebug() << runId << logtime() << "Received request for baseline" << caseId; QFile file(pathForCaseId(caseId)); if (!file.open(QIODevice::ReadOnly)) { - qDebug() << runId << "baseline not found."; + qDebug() << runId << logtime() << "baseline not found."; proto.sendBlock(BaselineProtocol::BaselineNotPresent, caseId); return; } @@ -142,13 +146,13 @@ void BaselineHandler::storeImage(const QByteArray &imageBlock, bool isBaseline) ds >> caseId; //# For futuresafeness, should make caseId FS-safe - but revertable... QFile file(pathForCaseId(caseId, isBaseline)); - qDebug() << runId << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << caseId << "Storing in" << file.fileName(); + qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << caseId << "Storing in" << file.fileName(); QString path = file.fileName().section(QDir::separator(), 0, -2); QDir cwd; if (!cwd.exists(path)) cwd.mkpath(path); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - qWarning() << runId << "Failed to store" << file.fileName(); + qWarning() << runId << logtime() << "Failed to store" << file.fileName(); return; } file.write(imageBlock.constData()+buf.pos(), imageBlock.size()-buf.pos()); @@ -159,13 +163,13 @@ void BaselineHandler::storeImage(const QByteArray &imageBlock, bool isBaseline) + QHostInfo::localDomainName().toLatin1() + ':' + QFileInfo(file).absoluteFilePath().toLatin1(); proto.sendBlock(BaselineProtocol::Ack, msg); - qDebug() << runId << "Storing done."; + qDebug() << runId << logtime() << "Storing done."; } void BaselineHandler::receiveDisconnect() { - qDebug() << runId << "Client disconnected."; + qDebug() << runId << logtime() << "Client disconnected."; QThread::currentThread()->exit(0); } diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 8cd9f56..9d32e5d 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -64,6 +64,7 @@ private: void provideBaseline(const QByteArray &caseId); void storeImage(const QByteArray &imageBlock, bool isBaseline); QString pathForCaseId(const QByteArray &caseId, bool isBaseline = true); + QString logtime(); BaselineProtocol proto; PlatformInfo plat; diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index fb4f06d..83b7adc 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -37,8 +37,8 @@ BaselineProtocol::~BaselineProtocol() bool BaselineProtocol::connect() { errMsg.clear(); - //TBD: determine server address; for now localhost - QLatin1String serverName("localhost"); + //###TBD: determine server address; for now local devhost + QLatin1String serverName("chimera.europe.nokia.com"); socket.connectToHost(serverName, ServerPort); diff --git a/tests/auto/lancelot/.gitignore b/tests/auto/lancelot/.gitignore new file mode 100644 index 0000000..0a70416 --- /dev/null +++ b/tests/auto/lancelot/.gitignore @@ -0,0 +1 @@ +tst_lancelot -- cgit v0.12 From aabb19f90c93a12a1458c96d7e6baf6632a79098 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 27 Aug 2010 12:45:00 +0200 Subject: minor message fix --- tests/arthur/baselineserver/src/baselineserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index f7293a2..9f1665f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -157,7 +157,7 @@ void BaselineHandler::storeImage(const QByteArray &imageBlock, bool isBaseline) } file.write(imageBlock.constData()+buf.pos(), imageBlock.size()-buf.pos()); - QByteArray msg(isBaseline ? "Mismatching" : "Baseline"); + QByteArray msg(isBaseline ? "Baseline" : "Mismatching" ); msg += " image stored in " + QHostInfo::localHostName().toLatin1() + '.' + QHostInfo::localDomainName().toLatin1() + ':' -- cgit v0.12 From ab6a22fd0d414a8c7a9c3875cf1599516c0c6ff3 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 30 Aug 2010 09:46:10 +0200 Subject: Experiment with generating and storing the diff image also on failure --- tests/auto/lancelot/tst_lancelot.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 1b832c6..f1c6e5c 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -160,6 +160,19 @@ void tst_Lancelot::testRendering() if (rendered != baseline) { QByteArray failMsg; proto.submitMismatch(fileName, rendered, &failMsg); + +#if 1 + // Also generate & submit the diff image + QImage diff(rendered.size(), QImage::Format_RGB32); + diff.fill(0); + QPainter p(&diff); + p.drawImage(0, 0, rendered); + p.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + p.drawImage(0, 0, baseline); + p.end(); + proto.submitMismatch(fileName + QLatin1String("_diff"), diff, 0); +#endif + failMsg.prepend("Rendered image differs from baseline. "); QFAIL(failMsg.constData()); } -- cgit v0.12 From 4fe2b5d9b8dd43becf69cdf848ce7cdfca39b3bd Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 30 Aug 2010 14:46:47 +0200 Subject: Add reporting of difference score on mismatches --- tests/auto/lancelot/tst_lancelot.cpp | 72 ++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index f1c6e5c..5e346ff 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -67,6 +67,7 @@ private: QImage getBaseline(const QString &fileName, bool *created); QImage render(const QString &fileName); QStringList loadScriptFile(const QString &filePath); + QString computeMismatchScore(const QImage& baseline, const QImage& rendered); QString errorMsg; BaselineProtocol proto; @@ -158,27 +159,68 @@ void tst_Lancelot::testRendering() // The actual check: if (rendered != baseline) { - QByteArray failMsg; - proto.submitMismatch(fileName, rendered, &failMsg); - -#if 1 - // Also generate & submit the diff image - QImage diff(rendered.size(), QImage::Format_RGB32); - diff.fill(0); - QPainter p(&diff); - p.drawImage(0, 0, rendered); - p.setCompositionMode(QPainter::RasterOp_SourceXorDestination); - p.drawImage(0, 0, baseline); - p.end(); - proto.submitMismatch(fileName + QLatin1String("_diff"), diff, 0); -#endif + QString scoreMsg = computeMismatchScore(baseline, rendered); + QByteArray serverMsg; + proto.submitMismatch(fileName, rendered, &serverMsg); - failMsg.prepend("Rendered image differs from baseline. "); + QByteArray failMsg = QByteArray("Rendered image differs from baseline. ") + + scoreMsg.toLatin1() + '\n' + serverMsg; QFAIL(failMsg.constData()); } } +QString tst_Lancelot::computeMismatchScore(const QImage &baseline, const QImage &rendered) +{ + if (baseline.size() != rendered.size() || baseline.format() != rendered.format()) + return QLatin1String("[No score, incomparable images.]"); + if (baseline.depth() != 32) + return QLatin1String("[Score computation not implemented for format.]"); + + int w = baseline.width(); + int h = baseline.height(); + + uint ncd = 0; // number of differing color pixels + uint nad = 0; // number of differing alpha pixels + uint scd = 0; // sum of color pixel difference + uint sad = 0; // sum of alpha pixel difference + + for (int y=0; y Date: Tue, 31 Aug 2010 11:02:12 +0200 Subject: try a different image format --- tests/auto/lancelot/tst_lancelot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 5e346ff..5bbc575 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -211,11 +211,11 @@ QString tst_Lancelot::computeMismatchScore(const QImage &baseline, const QImage double pcd = 100.0 * ncd / (w*h); // percent of pixels that differ double acd = ncd ? double(scd) / (3*ncd) : 0; // avg. difference - QString res = QString(QLatin1String("Diffscore: %1% (Num:%2 Avg:%3.)")).arg(pcd, 0, 'g', 3).arg(ncd).arg(acd, 0, 'g', 3); + QString res = QString(QLatin1String("Diffscore: %1% (Num:%2 Avg:%3.)")).arg(pcd, 0, 'g', 2).arg(ncd).arg(acd, 0, 'g', 2); if (baseline.hasAlphaChannel()) { double pad = 100.0 * nad / (w*h); // percent of pixels that differ double aad = nad ? double(sad) / (3*nad) : 0; // avg. difference - res += QString(QLatin1String(" Alpha-diffscore: %1% (Num:%2 Avg:%3.)")).arg(pad, 0, 'g', 3).arg(nad).arg(aad, 0, 'g', 3); + res += QString(QLatin1String(" Alpha-diffscore: %1% (Num:%2 Avg:%3.)")).arg(pad, 0, 'g', 2).arg(nad).arg(aad, 0, 'g', 2); } return res; } @@ -265,7 +265,7 @@ QImage tst_Lancelot::render(const QString &fileName) if (script.isEmpty()) return QImage(); - QImage img(800, 800, QImage::Format_ARGB32_Premultiplied); + QImage img(800, 800, QImage::Format_ARGB32); QPainter p(&img); PaintCommands pcmd(script, 800, 800); pcmd.setPainter(&p); -- cgit v0.12 From 38f0e9dbf41ebc8707398279ccb7038d3927c2d8 Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 2 Sep 2010 14:48:04 +0200 Subject: Rewrite protocol (ImageItem/ImageItemList) Not finished, but core functionality is in working state. --- tests/arthur/baselineserver/src/baselineserver.cpp | 78 ++++++++---- tests/arthur/baselineserver/src/baselineserver.h | 5 +- tests/arthur/common/baselineprotocol.cpp | 78 ++++++++++-- tests/arthur/common/baselineprotocol.h | 63 ++++++++-- tests/auto/lancelot/tst_lancelot.cpp | 131 +++++++++++++-------- 5 files changed, 265 insertions(+), 90 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 9f1665f..3087357 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -5,6 +5,7 @@ #include #include #include +#include QString BaselineServer::storage; @@ -106,6 +107,9 @@ void BaselineHandler::receiveRequest() } switch(cmd) { + case BaselineProtocol::RequestBaselineChecksums: + provideBaselineChecksums(block); + break; case BaselineProtocol::RequestBaseline: provideBaseline(block); break; @@ -122,40 +126,73 @@ void BaselineHandler::receiveRequest() } +void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) +{ + ImageItemList itemList; + QDataStream ds(itemListBlock); + ds >> itemList; + qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items"; + + for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { + i->imageChecksum = 0; + QString prefix = pathForItem(*i, true); + QFile file(prefix + QLatin1String("metadata")); + if (file.open(QIODevice::ReadOnly)) { + QTextStream ts(&file); + ts >> i->imageChecksum; + file.close(); + i->status = ImageItem::Ok; + } + if (!i->imageChecksum) + i->status = ImageItem::BaselineNotFound; + } + + QByteArray block; + QDataStream ods(&block, QIODevice::WriteOnly); + ods << itemList; + proto.sendBlock(BaselineProtocol::Ack, block); +} + + void BaselineHandler::provideBaseline(const QByteArray &caseId) { qDebug() << runId << logtime() << "Received request for baseline" << caseId; + //### rewrite to use ImageItem + /* QFile file(pathForCaseId(caseId)); if (!file.open(QIODevice::ReadOnly)) { qDebug() << runId << logtime() << "baseline not found."; proto.sendBlock(BaselineProtocol::BaselineNotPresent, caseId); return; } + proto.sendBlock(BaselineProtocol::AcceptBaseline, file.readAll()); + */ } -void BaselineHandler::storeImage(const QByteArray &imageBlock, bool isBaseline) +void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) { - QBuffer buf; - buf.setData(imageBlock); - buf.open(QIODevice::ReadOnly); - QDataStream ds(&buf); - QByteArray caseId; - ds >> caseId; - //# For futuresafeness, should make caseId FS-safe - but revertable... - QFile file(pathForCaseId(caseId, isBaseline)); - qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << caseId << "Storing in" << file.fileName(); - QString path = file.fileName().section(QDir::separator(), 0, -2); + QDataStream ds(itemBlock); + ImageItem item; + ds >> item; + + QString prefix = pathForItem(item, isBaseline); + qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.scriptName << "Storing in" << prefix; + + QString dir = prefix.section(QDir::separator(), 0, -2); QDir cwd; - if (!cwd.exists(path)) - cwd.mkpath(path); - if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - qWarning() << runId << logtime() << "Failed to store" << file.fileName(); - return; - } - file.write(imageBlock.constData()+buf.pos(), imageBlock.size()-buf.pos()); + if (!cwd.exists(dir)) + cwd.mkpath(dir); + item.image.save(prefix + QLatin1String(FileFormat), FileFormat); + + //# Could use QSettings or XML or even DB, could use common file for whole dir or even whole storage - but for now, keep it simple + QFile file(prefix + QLatin1String("metadata")); + file.open(QIODevice::WriteOnly | QIODevice::Truncate); + QTextStream ts(&file); + ts << hex << showbase << item.imageChecksum << reset << endl; + file.close(); QByteArray msg(isBaseline ? "Baseline" : "Mismatching" ); msg += " image stored in " @@ -174,7 +211,7 @@ void BaselineHandler::receiveDisconnect() } -QString BaselineHandler::pathForCaseId(const QByteArray &caseId, bool isBaseline) +QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) { QString storePath = BaselineServer::storagePath(); storePath += plat.buildKey.section(QLatin1Char(' '), 1, 1) + QLatin1String("_Qt-") @@ -183,7 +220,8 @@ QString BaselineHandler::pathForCaseId(const QByteArray &caseId, bool isBaseline storePath += QLatin1String("baselines") + QDir::separator(); else storePath += runId + QDir::separator(); - return storePath + caseId + QLatin1Char('.') + QLatin1String(FileFormat); + //#? QString itemName = item.scriptName.replace(item.scriptName.lastIndexOf('.'), '_'); + return storePath + item.scriptName + QLatin1Char('.'); } diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 9d32e5d..4056ce0 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -11,7 +11,7 @@ #include // #seconds between update checks -#define HEARTBEAT 10 +#define HEARTBEAT 5 class BaselineServer : public QTcpServer { @@ -61,9 +61,10 @@ private slots: void receiveDisconnect(); private: + void provideBaselineChecksums(const QByteArray &itemListBlock); void provideBaseline(const QByteArray &caseId); void storeImage(const QByteArray &imageBlock, bool isBaseline); - QString pathForCaseId(const QByteArray &caseId, bool isBaseline = true); + QString pathForItem(const ImageItem &item, bool isBaseline = true); QString logtime(); BaselineProtocol proto; diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 83b7adc..e5545a9 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -26,6 +26,42 @@ QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo) return stream; } +ImageItem &ImageItem::operator=(const ImageItem &other) +{ + scriptName = other.scriptName; + scriptChecksum = other.scriptChecksum; + status = other.status; + renderFormat = other.renderFormat; + engine = other.engine; + image = other.image; + imageChecksum = other.imageChecksum; + return *this; +} + +quint64 ImageItem::computeChecksum(const QImage &image) +{ + //### Just fake it for now + return qChecksum((const char *)image.constScanLine(50), image.bytesPerLine()); +} + +QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) +{ + stream << ii.scriptName << ii.scriptChecksum << quint8(ii.status) << quint8(ii.renderFormat) + << quint8(ii.engine) << ii.image << ii.imageChecksum; + return stream; +} + +QDataStream & operator>> (QDataStream &stream, ImageItem &ii) +{ + quint8 encFormat, encStatus, encEngine; + stream >> ii.scriptName >> ii.scriptChecksum >> encStatus >> encFormat + >> encEngine >> ii.image >> ii.imageChecksum; + ii.renderFormat = QImage::Format(encFormat); + ii.status = ImageItem::ItemStatus(encStatus); + ii.engine = ImageItem::GraphicsEngine(encEngine); + return stream; +} + BaselineProtocol::~BaselineProtocol() { socket.close(); @@ -86,8 +122,28 @@ bool BaselineProtocol::acceptConnection(PlatformInfo *pi) } +bool BaselineProtocol::requestBaselineChecksums(ImageItemList *itemList) +{ + errMsg.clear(); + if (!itemList) + return false; + QByteArray block; + QDataStream ds(&block, QIODevice::ReadWrite); + ds << *itemList; + if (!sendBlock(RequestBaselineChecksums, block)) + return false; + Command cmd; + if (!receiveBlock(&cmd, &block)) + return false; + ds.device()->seek(0); + ds >> *itemList; + return true; +} + + bool BaselineProtocol::requestBaseline(const QString &caseId, Command *response, QImage *baseline) { + //### TBD: rewrite to use ImageItem errMsg.clear(); if (!sendBlock(RequestBaseline, caseId.toLatin1())) return false; @@ -115,29 +171,31 @@ bool BaselineProtocol::requestBaseline(const QString &caseId, Command *response, } -bool BaselineProtocol::submitNewBaseline(const QString &caseId, const QImage &baseline) +bool BaselineProtocol::submitNewBaseline(const ImageItem &item) +{ + return sendItem(AcceptNewBaseline, item); +} + + +bool BaselineProtocol::sendItem(Command cmd, const ImageItem &item) { errMsg.clear(); QBuffer buf; buf.open(QIODevice::WriteOnly); QDataStream ds(&buf); - ds << caseId.toLatin1(); - if (!baseline.save(&buf, FileFormat)) { - errMsg = QLatin1String("Failed to convert new baseline image to ") + QLatin1String(FileFormat); - return false; - } - if (!sendBlock(AcceptNewBaseline, buf.data())) { - errMsg.prepend(QLatin1String("Failed to submit new baseline to server. ")); + ds << item; + if (!sendBlock(cmd, buf.data())) { + errMsg.prepend(QLatin1String("Failed to submit image to server. ")); return false; } - Command cmd; - receiveBlock(&cmd, 0); // Just wait for the pong; ignore reply contents + receiveBlock(&cmd, 0); // For now, Just wait for the pong; ignore reply contents return true; } bool BaselineProtocol::submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg) { + //### TBD: rewrite to use ImageItem errMsg.clear(); QBuffer buf; buf.open(QIODevice::WriteOnly); diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 8740413..b16a55b 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -3,19 +3,61 @@ #include #include +#include +#include #define FileFormat "png" struct PlatformInfo { -public: PlatformInfo(bool useLocal = false); QString buildKey; QString qtVersion; QString hostname; }; +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pinfo); +QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo); +struct ImageItem +{ +public: + ImageItem() + : status(Ok), renderFormat(QImage::Format_Invalid), engine(Raster), imageChecksum(0), scriptChecksum(0) + {} + ImageItem(const ImageItem &other) + { *this = other; } + ~ImageItem() + {} + ImageItem &operator=(const ImageItem &other); + static quint64 computeChecksum(const QImage& image); + + enum ItemStatus { + Ok = 0, + BaselineNotFound = 1, + IgnoreItem = 2 + }; + + enum GraphicsEngine { + Raster = 0, + OpenGL = 1 + }; + + QString scriptName; + ItemStatus status; + QImage::Format renderFormat; + GraphicsEngine engine; + QImage image; + quint64 imageChecksum; + // tbd: add diffscore + quint16 scriptChecksum; +}; +QDataStream & operator<< (QDataStream &stream, const ImageItem &ii); +QDataStream & operator>> (QDataStream& stream, ImageItem& ii); + +Q_DECLARE_METATYPE(ImageItem); + +typedef QVector ImageItemList; class BaselineProtocol @@ -30,18 +72,21 @@ public: enum Constant { ProtocolVersion = 1, ServerPort = 54129, - Timeout = 100000 + Timeout = 10000 }; enum Command { UnknownError = 0, // Queries AcceptPlatformInfo = 1, - RequestBaseline = 2, - AcceptNewBaseline = 3, - AcceptMismatch = 4, + RequestBaselineChecksums = 2, + RequestBaseline = 3, + AcceptNewBaseline = 4, + AcceptMismatch = 5, // Responses Ack = 128, + + //#### remove these: AcceptBaseline = 129, BaselineNotPresent = 130, IgnoreCase = 131 @@ -49,8 +94,9 @@ public: // For client: bool connect(); + bool requestBaselineChecksums(ImageItemList *itemList); bool requestBaseline(const QString &caseId, Command *response, QImage *baseline); - bool submitNewBaseline(const QString &caseId, const QImage &baseline); + bool submitNewBaseline(const ImageItem &item); bool submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg); // For server: @@ -59,6 +105,8 @@ public: QString errorMessage(); private: + bool sendItem(Command cmd, const ImageItem &item); + bool sendBlock(Command cmd, const QByteArray &block); bool receiveBlock(Command *cmd, QByteArray *block); QString errMsg; @@ -69,8 +117,7 @@ private: }; -QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pinfo); -QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo); + #endif // BASELINEPROTOCOL_H diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 5bbc575..a6bb68f 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -65,19 +65,21 @@ public: private: QImage getBaseline(const QString &fileName, bool *created); - QImage render(const QString &fileName); + QImage render(const QString &fileName, QImage::Format format); QStringList loadScriptFile(const QString &filePath); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); + void runTestSuite(); QString errorMsg; BaselineProtocol proto; + ImageItemList baseList; private slots: void initTestCase(); void cleanupTestCase() {} - void testRendering_data(); - void testRendering(); + void testRasterARGB32PM_data(); + void testRasterARGB32PM(); }; tst_Lancelot::tst_Lancelot() @@ -86,85 +88,111 @@ tst_Lancelot::tst_Lancelot() void tst_Lancelot::initTestCase() { + // Check and setup the environment. We treat failures because of test environment + // (e.g. script files not found) as just warnings, and not QFAILs, to avoid false negatives + // caused by environment or server instability + #if !defined(Q_OS_LINUX) QSKIP("For the moment, this test is only supported on Linux.", SkipAll); #endif - - // Check the environment here, so that we can just skip on trouble! if (!proto.connect()) { QWARN(qPrintable(proto.errorMessage())); QSKIP("Communication with baseline image server failed.", SkipAll); } - // TBD: preload scripts, to confirm reading and generate checksums + QDir qpsDir(scriptsDir); + QStringList files = qpsDir.entryList(QStringList() << QLatin1String("*.qps"), QDir::Files | QDir::Readable); + if (files.isEmpty()) { + QWARN("No qps script files found in " + qpsDir.path().toLatin1()); + QSKIP("Aborted due to errors.", SkipAll); + } + + baseList.resize(files.count()); + int i = 0; + foreach(const QString& file, files) { + baseList[i].scriptName = file; + // tbd: also load, split and generate checksums for scripts + i++; + } } -void tst_Lancelot::testRendering_data() + +void tst_Lancelot::testRasterARGB32PM_data() { - // search the data directory for qps files and make a row for each. - // filter out those marked as blacklisted (in the file itself?) - // Rather do the above in initTestCase. Can load & split them all also. - // And baselines too? + QTest::addColumn("item"); - QTest::addColumn("fileName"); + ImageItemList itemList(baseList); - // ### no, don't do it like this, we want opt-in, not opt-out, for stability - QDir qpsDir(scriptsDir); - QStringList files = qpsDir.entryList(QStringList() << QLatin1String("*.qps"), QDir::Files | QDir::Readable); - files.removeOne(QLatin1String("porter_duff.qps")); - files.removeOne(QLatin1String("porter_duff2.qps")); - files.removeOne(QLatin1String("images.qps")); - files.removeOne(QLatin1String("sizes.qps")); + for(int i = 0; i < itemList.size(); i++) { + itemList[i].engine = ImageItem::Raster; + itemList[i].renderFormat = QImage::Format_ARGB32_Premultiplied; + } - if (files.isEmpty()) { - QWARN("No qps files found in " + qpsDir.path().toLatin1()); - QSKIP("Aborted due to errors.", SkipAll); + if (!proto.requestBaselineChecksums(&itemList)) { + QWARN(qPrintable(proto.errorMessage())); + QSKIP("Communication with baseline image server failed.", SkipAll); } - foreach(QString fileName, files) { - QString baseName = fileName.section('.', 0, -2); - QTest::newRow(baseName.toLatin1()) << fileName; + qDebug() << "items:" << itemList.count(); + foreach(const ImageItem& item, itemList) { + if (item.scriptName != QLatin1String("sizes.qps")) // Hardcoded blacklisting for this enigine/format + QTest::newRow(item.scriptName.toLatin1()) << item; } } -// We treat failures because of test environment -// (e.g. script files not found) as just warnings, and not -// QFAILs, to avoid false negatives caused by environment -// or server instability +void tst_Lancelot::testRasterARGB32PM() +{ + runTestSuite(); +} -void tst_Lancelot::testRendering() + +void tst_Lancelot::runTestSuite() { errorMsg.clear(); - QFETCH(QString, fileName); + QFETCH(ImageItem, item); + + if (item.status == ImageItem::IgnoreItem) + QSKIP("Blacklisted by baseline server.", SkipSingle); + + QImage rendered = render(item.scriptName, item.renderFormat); + if (!errorMsg.isNull() || rendered.isNull()) { // Assume an error in the test environment, not Qt + QWARN("Error: Failed to render image. " + errorMsg.toLatin1()); + QSKIP("Aborted due to errors.", SkipSingle); + } - bool newBaselineCreated = false; - QImage baseline = getBaseline(fileName, &newBaselineCreated); - if (newBaselineCreated) + quint64 checksum = ImageItem::computeChecksum(rendered); + + if (item.status == ImageItem::BaselineNotFound) { + item.image = rendered; + item.imageChecksum = checksum; + proto.submitNewBaseline(item); QSKIP("Baseline not found; new baseline created.", SkipSingle); + } + + qDebug() << "rendered" << QString::number(checksum, 16).prepend("0x") << "baseline" << QString::number(item.imageChecksum, 16).prepend("0x"); + if (checksum != item.imageChecksum) { + /* TBD + - Get baseline image + - compute diffscore + - submit mismatching + + getBaseline(...) if (!errorMsg.isNull() || baseline.isNull()) { QWARN("Error: Failed to get baseline image. " + errorMsg.toLatin1()); QSKIP("Aborted due to errors.", SkipSingle); } - QImage rendered = render(fileName); - if (!errorMsg.isNull() || rendered.isNull()) { - // Indicates that it's an error in the test environment, not Qt - QWARN("Error: Failed to render image. " + errorMsg.toLatin1()); - QSKIP("Aborted due to errors.", SkipSingle); - } if (rendered.format() != baseline.format()) - baseline = baseline.convertToFormat(rendered.format()); + rendered = rendered.convertToFormat(baseline.format()); //### depending on format - // The actual check: - if (rendered != baseline) { QString scoreMsg = computeMismatchScore(baseline, rendered); QByteArray serverMsg; proto.submitMismatch(fileName, rendered, &serverMsg); - - QByteArray failMsg = QByteArray("Rendered image differs from baseline. ") - + scoreMsg.toLatin1() + '\n' + serverMsg; + */ + QByteArray failMsg = QByteArray("Rendered image differs from baseline. "); + //+ scoreMsg.toLatin1() + '\n' + serverMsg; QFAIL(failMsg.constData()); } } @@ -211,11 +239,11 @@ QString tst_Lancelot::computeMismatchScore(const QImage &baseline, const QImage double pcd = 100.0 * ncd / (w*h); // percent of pixels that differ double acd = ncd ? double(scd) / (3*ncd) : 0; // avg. difference - QString res = QString(QLatin1String("Diffscore: %1% (Num:%2 Avg:%3.)")).arg(pcd, 0, 'g', 2).arg(ncd).arg(acd, 0, 'g', 2); + QString res = QString(QLatin1String("Diffscore: %1% (Num:%2 Avg:%3)")).arg(pcd, 0, 'g', 2).arg(ncd).arg(acd, 0, 'g', 2); if (baseline.hasAlphaChannel()) { double pad = 100.0 * nad / (w*h); // percent of pixels that differ double aad = nad ? double(sad) / (3*nad) : 0; // avg. difference - res += QString(QLatin1String(" Alpha-diffscore: %1% (Num:%2 Avg:%3.)")).arg(pad, 0, 'g', 2).arg(nad).arg(aad, 0, 'g', 2); + res += QString(QLatin1String(" Alpha-diffscore: %1% (Num:%2 Avg:%3)")).arg(pad, 0, 'g', 2).arg(nad).arg(aad, 0, 'g', 2); } return res; } @@ -224,6 +252,8 @@ QString tst_Lancelot::computeMismatchScore(const QImage &baseline, const QImage QImage tst_Lancelot::getBaseline(const QString &fileName, bool *created) { QImage baseline; + //### TBD: rewrite to use ImageItem + /* BaselineProtocol::Command response; if (!proto.requestBaseline(fileName, &response, &baseline)) { errorMsg = QLatin1String("Error downloading baseline from server. ") + proto.errorMessage(); @@ -254,18 +284,19 @@ QImage tst_Lancelot::getBaseline(const QString &fileName, bool *created) errorMsg = QLatin1String("Unknown response from baseline server. "); return QImage(); } + */ return baseline; } -QImage tst_Lancelot::render(const QString &fileName) +QImage tst_Lancelot::render(const QString &fileName, QImage::Format format) { QString filePath = scriptsDir + fileName; QStringList script = loadScriptFile(filePath); if (script.isEmpty()) return QImage(); - QImage img(800, 800, QImage::Format_ARGB32); + QImage img(800, 800, format); QPainter p(&img); PaintCommands pcmd(script, 800, 800); pcmd.setPainter(&p); -- cgit v0.12 From 0d18809a78021709f024e85c5251815a5864a7e3 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 3 Sep 2010 10:29:10 +0200 Subject: Protocol rewrite done; design cleaned up. Client no longer fetches baseline images, not even on mismatch. Bitwise comparison, mismatch score etc. will be done on server, if wanted. --- tests/arthur/baselineserver/src/baselineserver.cpp | 74 +++++--- tests/arthur/baselineserver/src/baselineserver.h | 4 +- tests/arthur/common/baselineprotocol.cpp | 58 +------ tests/arthur/common/baselineprotocol.h | 11 +- tests/auto/lancelot/tst_lancelot.cpp | 190 ++++----------------- 5 files changed, 95 insertions(+), 242 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 3087357..0f95474 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -110,9 +110,6 @@ void BaselineHandler::receiveRequest() case BaselineProtocol::RequestBaselineChecksums: provideBaselineChecksums(block); break; - case BaselineProtocol::RequestBaseline: - provideBaseline(block); - break; case BaselineProtocol::AcceptNewBaseline: storeImage(block, true); break; @@ -154,24 +151,6 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) } -void BaselineHandler::provideBaseline(const QByteArray &caseId) -{ - qDebug() << runId << logtime() << "Received request for baseline" << caseId; - - //### rewrite to use ImageItem - /* - QFile file(pathForCaseId(caseId)); - if (!file.open(QIODevice::ReadOnly)) { - qDebug() << runId << logtime() << "baseline not found."; - proto.sendBlock(BaselineProtocol::BaselineNotPresent, caseId); - return; - } - - proto.sendBlock(BaselineProtocol::AcceptBaseline, file.readAll()); - */ -} - - void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) { QDataStream ds(itemBlock); @@ -200,7 +179,6 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) + QHostInfo::localDomainName().toLatin1() + ':' + QFileInfo(file).absoluteFilePath().toLatin1(); proto.sendBlock(BaselineProtocol::Ack, msg); - qDebug() << runId << logtime() << "Storing done."; } @@ -225,6 +203,52 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) } -// - transferring and comparing checksums instead of images -// - then we could now if multiple error/imgs are really the same (and just store it once) -// - e.g. using db +QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QImage &rendered) +{ + if (baseline.size() != rendered.size() || baseline.format() != rendered.format()) + return QLatin1String("[No score, incomparable images.]"); + if (baseline.depth() != 32) + return QLatin1String("[Score computation not implemented for format.]"); + + int w = baseline.width(); + int h = baseline.height(); + + uint ncd = 0; // number of differing color pixels + uint nad = 0; // number of differing alpha pixels + uint scd = 0; // sum of color pixel difference + uint sad = 0; // sum of alpha pixel difference + + for (int y=0; yisNull()) { - errMsg.prepend(QLatin1String("Invalid baseline image data received. ")); - return false; - } - } - return true; - } - errMsg.prepend(QLatin1String("Unexpected reply from server on baseline request. ")); - return false; + return (sendItem(AcceptNewBaseline, item) && receiveBlock(&cmd, serverMsg) && cmd == Ack); } -bool BaselineProtocol::submitNewBaseline(const ImageItem &item) +bool BaselineProtocol::submitMismatch(const ImageItem &item, QByteArray *serverMsg) { - return sendItem(AcceptNewBaseline, item); + Command cmd; + return (sendItem(AcceptMismatch, item) && receiveBlock(&cmd, serverMsg) && cmd == Ack); } @@ -188,32 +166,6 @@ bool BaselineProtocol::sendItem(Command cmd, const ImageItem &item) errMsg.prepend(QLatin1String("Failed to submit image to server. ")); return false; } - receiveBlock(&cmd, 0); // For now, Just wait for the pong; ignore reply contents - return true; -} - - -bool BaselineProtocol::submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg) -{ - //### TBD: rewrite to use ImageItem - errMsg.clear(); - QBuffer buf; - buf.open(QIODevice::WriteOnly); - QDataStream ds(&buf); - ds << caseId.toLatin1(); - if (!mismatch.save(&buf, FileFormat)) { - errMsg = QLatin1String("Failed to convert mismatched image to ") + QLatin1String(FileFormat); - return false; - } - if (!sendBlock(AcceptMismatch, buf.data())) { - errMsg.prepend(QLatin1String("Failed to submit mismatched image to server. ")); - return false; - } - Command cmd; - if (!receiveBlock(&cmd, failMsg)) { - errMsg.prepend(QLatin1String("Failed to receive response on mismatched image from server. ")); - return false; - } return true; } diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index b16a55b..749b623 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -80,24 +80,17 @@ public: // Queries AcceptPlatformInfo = 1, RequestBaselineChecksums = 2, - RequestBaseline = 3, AcceptNewBaseline = 4, AcceptMismatch = 5, // Responses Ack = 128, - - //#### remove these: - AcceptBaseline = 129, - BaselineNotPresent = 130, - IgnoreCase = 131 }; // For client: bool connect(); bool requestBaselineChecksums(ImageItemList *itemList); - bool requestBaseline(const QString &caseId, Command *response, QImage *baseline); - bool submitNewBaseline(const ImageItem &item); - bool submitMismatch(const QString &caseId, const QImage &mismatch, QByteArray *failMsg); + bool submitNewBaseline(const ImageItem &item, QByteArray *serverMsg); + bool submitMismatch(const ImageItem &item, QByteArray *serverMsg); // For server: bool acceptConnection(PlatformInfo *pi); diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index a6bb68f..4485880 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -64,13 +64,10 @@ public: tst_Lancelot(); private: - QImage getBaseline(const QString &fileName, bool *created); - QImage render(const QString &fileName, QImage::Format format); + ImageItem render(const ImageItem &item); QStringList loadScriptFile(const QString &filePath); - QString computeMismatchScore(const QImage& baseline, const QImage& rendered); void runTestSuite(); - QString errorMsg; BaselineProtocol proto; ImageItemList baseList; @@ -108,24 +105,24 @@ void tst_Lancelot::initTestCase() } baseList.resize(files.count()); - int i = 0; + ImageItemList::iterator it = baseList.begin(); foreach(const QString& file, files) { - baseList[i].scriptName = file; + it->scriptName = file; // tbd: also load, split and generate checksums for scripts - i++; + it++; } } void tst_Lancelot::testRasterARGB32PM_data() { - QTest::addColumn("item"); + QTest::addColumn("baseline"); ImageItemList itemList(baseList); - for(int i = 0; i < itemList.size(); i++) { - itemList[i].engine = ImageItem::Raster; - itemList[i].renderFormat = QImage::Format_ARGB32_Premultiplied; + for(ImageItemList::iterator it = itemList.begin(); it != itemList.end(); it++) { + it->engine = ImageItem::Raster; + it->renderFormat = QImage::Format_ARGB32_Premultiplied; } if (!proto.requestBaselineChecksums(&itemList)) { @@ -133,9 +130,8 @@ void tst_Lancelot::testRasterARGB32PM_data() QSKIP("Communication with baseline image server failed.", SkipAll); } - qDebug() << "items:" << itemList.count(); foreach(const ImageItem& item, itemList) { - if (item.scriptName != QLatin1String("sizes.qps")) // Hardcoded blacklisting for this enigine/format + if (item.scriptName != QLatin1String("sizes.qps")) // Example of hardcoded blacklisting for this enigine/format QTest::newRow(item.scriptName.toLatin1()) << item; } } @@ -149,170 +145,58 @@ void tst_Lancelot::testRasterARGB32PM() void tst_Lancelot::runTestSuite() { - errorMsg.clear(); - QFETCH(ImageItem, item); + QFETCH(ImageItem, baseline); - if (item.status == ImageItem::IgnoreItem) + if (baseline.status == ImageItem::IgnoreItem) QSKIP("Blacklisted by baseline server.", SkipSingle); - QImage rendered = render(item.scriptName, item.renderFormat); - if (!errorMsg.isNull() || rendered.isNull()) { // Assume an error in the test environment, not Qt - QWARN("Error: Failed to render image. " + errorMsg.toLatin1()); + ImageItem rendered = render(baseline); + if (rendered.image.isNull()) { // Assume an error in the test environment, not Qt + QWARN("Error: Failed to render image."); QSKIP("Aborted due to errors.", SkipSingle); } - quint64 checksum = ImageItem::computeChecksum(rendered); - - if (item.status == ImageItem::BaselineNotFound) { - item.image = rendered; - item.imageChecksum = checksum; - proto.submitNewBaseline(item); + if (baseline.status == ImageItem::BaselineNotFound) { + proto.submitNewBaseline(rendered, 0); QSKIP("Baseline not found; new baseline created.", SkipSingle); } - qDebug() << "rendered" << QString::number(checksum, 16).prepend("0x") << "baseline" << QString::number(item.imageChecksum, 16).prepend("0x"); - if (checksum != item.imageChecksum) { - /* TBD - - Get baseline image - - compute diffscore - - submit mismatching - - getBaseline(...) - if (!errorMsg.isNull() || baseline.isNull()) { - QWARN("Error: Failed to get baseline image. " + errorMsg.toLatin1()); - QSKIP("Aborted due to errors.", SkipSingle); - } - - - if (rendered.format() != baseline.format()) - rendered = rendered.convertToFormat(baseline.format()); //### depending on format - - QString scoreMsg = computeMismatchScore(baseline, rendered); + if (rendered.imageChecksum != baseline.imageChecksum) { QByteArray serverMsg; - proto.submitMismatch(fileName, rendered, &serverMsg); - */ - QByteArray failMsg = QByteArray("Rendered image differs from baseline. "); - //+ scoreMsg.toLatin1() + '\n' + serverMsg; - QFAIL(failMsg.constData()); + if (!proto.submitMismatch(rendered, &serverMsg)) + serverMsg = "Failed to submit mismatching image to server."; + QFAIL("Rendered image differs from baseline.\n" + serverMsg); } } -QString tst_Lancelot::computeMismatchScore(const QImage &baseline, const QImage &rendered) +ImageItem tst_Lancelot::render(const ImageItem &item) { - if (baseline.size() != rendered.size() || baseline.format() != rendered.format()) - return QLatin1String("[No score, incomparable images.]"); - if (baseline.depth() != 32) - return QLatin1String("[Score computation not implemented for format.]"); - - int w = baseline.width(); - int h = baseline.height(); - - uint ncd = 0; // number of differing color pixels - uint nad = 0; // number of differing alpha pixels - uint scd = 0; // sum of color pixel difference - uint sad = 0; // sum of alpha pixel difference - - for (int y=0; y Date: Fri, 3 Sep 2010 12:33:03 +0200 Subject: Add basic OpenGL testing support. --- tests/arthur/baselineserver/src/baselineserver.cpp | 22 ++++++- tests/arthur/baselineserver/src/baselineserver.h | 1 + tests/auto/lancelot/tst_lancelot.cpp | 70 +++++++++++++++++++--- 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 0f95474..430d4af 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -194,14 +194,30 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) QString storePath = BaselineServer::storagePath(); storePath += plat.buildKey.section(QLatin1Char(' '), 1, 1) + QLatin1String("_Qt-") + plat.qtVersion + QDir::separator(); - if (isBaseline) - storePath += QLatin1String("baselines") + QDir::separator(); - else + if (isBaseline) { + storePath += QLatin1String("baselines") + QDir::separator() + + engineForItem(item) + QDir::separator(); + } else { storePath += runId + QDir::separator(); + } //#? QString itemName = item.scriptName.replace(item.scriptName.lastIndexOf('.'), '_'); return storePath + item.scriptName + QLatin1Char('.'); } +QString BaselineHandler::engineForItem(const ImageItem &item) +{ + switch (item.engine) { + case ImageItem::Raster: + return QLatin1String("Raster"); + break; + case ImageItem::OpenGL: + return QLatin1String("OpenGL"); + break; + default: + break; + } + return QLatin1String("Unknown"); +} QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QImage &rendered) { diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 337b38c..2963fd1 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -66,6 +66,7 @@ private: QString pathForItem(const ImageItem &item, bool isBaseline = true); QString logtime(); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); + QString engineForItem(const ImageItem &item); BaselineProtocol proto; PlatformInfo plat; diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 4485880..93b9346 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -50,6 +50,8 @@ #include #include +#include + #ifndef SRCDIR #define SRCDIR "." #endif @@ -65,6 +67,7 @@ public: private: ImageItem render(const ImageItem &item); + void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); QStringList loadScriptFile(const QString &filePath); void runTestSuite(); @@ -77,6 +80,9 @@ private slots: void testRasterARGB32PM_data(); void testRasterARGB32PM(); + + void testOpenGL_data(); + void testOpenGL(); }; tst_Lancelot::tst_Lancelot() @@ -143,6 +149,36 @@ void tst_Lancelot::testRasterARGB32PM() } +void tst_Lancelot::testOpenGL_data() +{ + QTest::addColumn("item"); + + ImageItemList itemList(baseList); + + for(int i = 0; i < itemList.size(); i++) { + itemList[i].engine = ImageItem::OpenGL; + itemList[i].renderFormat = QImage::Format_RGB32; + } + + if (!proto.requestBaselineChecksums(&itemList)) { + QWARN(qPrintable(proto.errorMessage())); + QSKIP("Communication with baseline image server failed.", SkipAll); + } + + qDebug() << "items:" << itemList.count(); + foreach(const ImageItem& item, itemList) { + if (item.scriptName != QLatin1String("sizes.qps")) // Hardcoded blacklisting for this enigine/format + QTest::newRow(item.scriptName.toLatin1()) << item; + } +} + + +void tst_Lancelot::testOpenGL() +{ + runTestSuite(); +} + + void tst_Lancelot::runTestSuite() { QFETCH(ImageItem, baseline); @@ -178,20 +214,40 @@ ImageItem tst_Lancelot::render(const ImageItem &item) if (script.isEmpty()) { res.image = QImage(); res.imageChecksum = 0; - } else { + } else if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); - QPainter p(&img); - PaintCommands pcmd(script, 800, 800); - pcmd.setPainter(&p); - pcmd.setFilePath(QFileInfo(filePath).absoluteFilePath()); // eh yuck - pcmd.runCommands(); - p.end(); + paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) res.image = img; res.imageChecksum = ImageItem::computeChecksum(img); + } else if (item.engine == ImageItem::OpenGL) { + QGLWidget glWidget; + if (!glWidget.isValid()) { + res.image = QImage(); + res.imageChecksum = 0; + return res; + } + glWidget.resize(800, 800); + glWidget.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&glWidget); +#endif + paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) + res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat); + res.imageChecksum = ImageItem::computeChecksum(res.image); } + return res; } +void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const QString &filePath) +{ + QPainter p(device); + PaintCommands pcmd(script, 800, 800); + pcmd.setPainter(&p); + pcmd.setFilePath(filePath); + pcmd.runCommands(); + p.end(); +} QStringList tst_Lancelot::loadScriptFile(const QString &filePath) { -- cgit v0.12 From bfd35cefd0a56f0faf624185330d5b9e0c9701d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 3 Sep 2010 12:50:52 +0200 Subject: Data column names have apparently changed :) --- tests/auto/lancelot/tst_lancelot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 93b9346..7381c1d 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -151,7 +151,7 @@ void tst_Lancelot::testRasterARGB32PM() void tst_Lancelot::testOpenGL_data() { - QTest::addColumn("item"); + QTest::addColumn("baseline"); ImageItemList itemList(baseList); -- cgit v0.12 From fe97cdb508697140ebbba8d73097fdd9e5b44bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 3 Sep 2010 13:30:12 +0200 Subject: Move the engine->string function into ImageItem. --- tests/arthur/baselineserver/src/baselineserver.cpp | 17 +---------------- tests/arthur/common/baselineprotocol.cpp | 15 +++++++++++++++ tests/arthur/common/baselineprotocol.h | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 430d4af..ec5793f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -196,7 +196,7 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) + plat.qtVersion + QDir::separator(); if (isBaseline) { storePath += QLatin1String("baselines") + QDir::separator() - + engineForItem(item) + QDir::separator(); + + item.engineAsString() + QDir::separator(); } else { storePath += runId + QDir::separator(); } @@ -204,21 +204,6 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) return storePath + item.scriptName + QLatin1Char('.'); } -QString BaselineHandler::engineForItem(const ImageItem &item) -{ - switch (item.engine) { - case ImageItem::Raster: - return QLatin1String("Raster"); - break; - case ImageItem::OpenGL: - return QLatin1String("OpenGL"); - break; - default: - break; - } - return QLatin1String("Unknown"); -} - QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QImage &rendered) { if (baseline.size() != rendered.size() || baseline.format() != rendered.format()) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index a6306b9..881c9cc 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -44,6 +44,21 @@ quint64 ImageItem::computeChecksum(const QImage &image) return qChecksum((const char *)image.constScanLine(50), image.bytesPerLine()); } +QString ImageItem::engineAsString() +{ + switch (engine) { + case Raster: + return QLatin1String("Raster"); + break; + case OpenGL: + return QLatin1String("OpenGL"); + break; + default: + break; + } + return QLatin1String("Unknown"); +} + QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { stream << ii.scriptName << ii.scriptChecksum << quint8(ii.status) << quint8(ii.renderFormat) diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 749b623..70cb227 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -31,6 +31,7 @@ public: {} ImageItem &operator=(const ImageItem &other); static quint64 computeChecksum(const QImage& image); + QString engineAsString(); enum ItemStatus { Ok = 0, -- cgit v0.12 From 22293fb1c19e7ff7c8f3bec8c97729fb2816c96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 3 Sep 2010 13:35:58 +0200 Subject: engineAsString() should've been const. --- tests/arthur/common/baselineprotocol.cpp | 2 +- tests/arthur/common/baselineprotocol.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 881c9cc..790b749 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -44,7 +44,7 @@ quint64 ImageItem::computeChecksum(const QImage &image) return qChecksum((const char *)image.constScanLine(50), image.bytesPerLine()); } -QString ImageItem::engineAsString() +QString ImageItem::engineAsString() const { switch (engine) { case Raster: diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 70cb227..9ec1ef4 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -31,7 +31,7 @@ public: {} ImageItem &operator=(const ImageItem &other); static quint64 computeChecksum(const QImage& image); - QString engineAsString(); + QString engineAsString() const; enum ItemStatus { Ok = 0, -- cgit v0.12 From 5322e029863f0085c5cd58f8241d34be22231d27 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 3 Sep 2010 14:58:30 +0200 Subject: Proper checksum function implemented --- tests/arthur/common/baselineprotocol.cpp | 32 +- tests/arthur/common/baselineprotocol.pri | 3 +- tests/arthur/common/lookup3.cpp | 745 +++++++++++++++++++++++++++++++ 3 files changed, 777 insertions(+), 3 deletions(-) create mode 100644 tests/arthur/common/lookup3.cpp diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index a6306b9..f2b719f 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -38,10 +38,38 @@ ImageItem &ImageItem::operator=(const ImageItem &other) return *this; } +// Defined in lookup3.c: +void hashword2 ( +const quint32 *k, /* the key, an array of quint32 values */ +size_t length, /* the length of the key, in quint32s */ +quint32 *pc, /* IN: seed OUT: primary hash value */ +quint32 *pb); /* IN: more seed OUT: secondary hash value */ + quint64 ImageItem::computeChecksum(const QImage &image) { - //### Just fake it for now - return qChecksum((const char *)image.constScanLine(50), image.bytesPerLine()); + quint32 h1 = 0xfeedbacc; + quint32 h2 = 0x21604894; + + QImage img(image); + const int bpl = img.bytesPerLine(); + const int padBytes = bpl - (img.width() * img.depth() / 8); + if (padBytes) { + uchar *p = img.bits() + bpl - padBytes; + const int h = img.height(); + for (int y = 0; y < h; ++y) { + qMemSet(p, 0, padBytes); + p += bpl; + } + } + if (img.format() == QImage::Format_RGB32) { // Thank you, Haavard + quint32 *p = (quint32 *)img.bits(); + const quint32 *end = p + (img.byteCount()/4); + while (p + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +# define HASH_LITTLE_ENDIAN 0 +# define HASH_BIG_ENDIAN 1 +#else +# define HASH_LITTLE_ENDIAN 1 +# define HASH_BIG_ENDIAN 0 +#endif + +#define hashsize(n) ((quint32)1<<(n)) +#define hashmask(n) (hashsize(n)-1) +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) + +/* +------------------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. + +This is reversible, so any information in (a,b,c) before mix() is +still in (a,b,c) after mix(). + +If four pairs of (a,b,c) inputs are run through mix(), or through +mix() in reverse, there are at least 32 bits of the output that +are sometimes the same for one pair and different for another pair. +This was tested for: +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that +satisfy this are + 4 6 8 16 19 4 + 9 15 3 18 27 15 + 14 9 3 7 17 3 +Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing +for "differ" defined as + with a one-bit base and a two-bit delta. I +used http://burtleburtle.net/bob/hash/avalanche.html to choose +the operations, constants, and arrangements of the variables. + +This does not achieve avalanche. There are input bits of (a,b,c) +that fail to affect some output bits of (a,b,c), especially of a. The +most thoroughly mixed value is c, but it doesn't really even achieve +avalanche in c. + +This allows some parallelism. Read-after-writes are good at doubling +the number of bits affected, so the goal of mixing pulls in the opposite +direction as the goal of parallelism. I did what I could. Rotates +seem to cost as much as shifts on every machine I could lay my hands +on, and rotates are much kinder to the top and bottom bits, so I used +rotates. +------------------------------------------------------------------------------- +*/ +#define mix(a,b,c) \ +{ \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c,16); c += b; \ + b -= a; b ^= rot(a,19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} + +/* +------------------------------------------------------------------------------- +final -- final mixing of 3 32-bit values (a,b,c) into c + +Pairs of (a,b,c) values differing in only a few bits will usually +produce values of c that look totally different. This was tested for +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +These constants passed: + 14 11 25 16 4 14 24 + 12 14 25 16 4 14 24 +and these came close: + 4 8 15 26 3 22 24 + 10 8 15 26 3 22 24 + 11 8 15 26 3 22 24 +------------------------------------------------------------------------------- +*/ +#define final(a,b,c) \ +{ \ + c ^= b; c -= rot(b,14); \ + a ^= c; a -= rot(c,11); \ + b ^= a; b -= rot(a,25); \ + c ^= b; c -= rot(b,16); \ + a ^= c; a -= rot(c,4); \ + b ^= a; b -= rot(a,14); \ + c ^= b; c -= rot(b,24); \ +} + +/* +-------------------------------------------------------------------- + This works on all machines. To be useful, it requires + -- that the key be an array of quint32's, and + -- that the length be the number of quint32's in the key + + The function hashword() is identical to hashlittle() on little-endian + machines, and identical to hashbig() on big-endian machines, + except that the length has to be measured in quint32s rather than in + bytes. hashlittle() is more complicated than hashword() only because + hashlittle() has to dance around fitting the key bytes into registers. +-------------------------------------------------------------------- +*/ +quint32 hashword( +const quint32 *k, /* the key, an array of quint32 values */ +size_t length, /* the length of the key, in quint32s */ +quint32 initval) /* the previous hash, or an arbitrary value */ +{ + quint32 a,b,c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + (((quint32)length)<<2) + initval; + + /*------------------------------------------------- handle most of the key */ + while (length > 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 3; + k += 3; + } + + /*------------------------------------------- handle the last 3 quint32's */ + switch(length) /* all the case statements fall through */ + { + case 3 : c+=k[2]; + case 2 : b+=k[1]; + case 1 : a+=k[0]; + final(a,b,c); + case 0: /* case 0: nothing left to add */ + break; + } + /*------------------------------------------------------ report the result */ + return c; +} + + +/* +-------------------------------------------------------------------- +hashword2() -- same as hashword(), but take two seeds and return two +32-bit values. pc and pb must both be nonnull, and *pc and *pb must +both be initialized with seeds. If you pass in (*pb)==0, the output +(*pc) will be the same as the return value from hashword(). +-------------------------------------------------------------------- +*/ +void hashword2 ( +const quint32 *k, /* the key, an array of quint32 values */ +size_t length, /* the length of the key, in quint32s */ +quint32 *pc, /* IN: seed OUT: primary hash value */ +quint32 *pb) /* IN: more seed OUT: secondary hash value */ +{ + quint32 a,b,c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + ((quint32)(length<<2)) + *pc; + c += *pb; + + /*------------------------------------------------- handle most of the key */ + while (length > 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 3; + k += 3; + } + + /*------------------------------------------- handle the last 3 quint32's */ + switch(length) /* all the case statements fall through */ + { + case 3 : c+=k[2]; + case 2 : b+=k[1]; + case 1 : a+=k[0]; + final(a,b,c); + case 0: /* case 0: nothing left to add */ + break; + } + /*------------------------------------------------------ report the result */ + *pc=c; *pb=b; +} + + +/* +------------------------------------------------------------------------------- +hashlittle() -- hash a variable-length key into a 32-bit value + k : the key (the unaligned variable-length array of bytes) + length : the length of the key, counting by bytes + initval : can be any 4-byte value +Returns a 32-bit value. Every bit of the key affects every bit of +the return value. Two keys differing by one or two bits will have +totally different hash values. + +The best hash table sizes are powers of 2. There is no need to do +mod a prime (mod is sooo slow!). If you need less than 32 bits, +use a bitmask. For example, if you need only 10 bits, do + h = (h & hashmask(10)); +In which case, the hash table should have hashsize(10) elements. + +If you are hashing n strings (quint8 **)k, do it like this: + for (i=0, h=0; i 12) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 12; + k += 3; + } + + /*----------------------------- handle the last (probably partial) block */ + /* + * "k[2]&0xffffff" actually reads beyond the end of the string, but + * then masks off the part it's not allowed to read. Because the + * string is aligned, the masked-off tail is in the same word as the + * rest of the string. Every machine with memory protection I've seen + * does it on word boundaries, so is OK with this. But VALGRIND will + * still catch it and complain. The masking trick does make the hash + * noticably faster for short strings (like English words). + */ +#ifndef VALGRIND + + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; + case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; + case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=k[1]&0xffffff; a+=k[0]; break; + case 6 : b+=k[1]&0xffff; a+=k[0]; break; + case 5 : b+=k[1]&0xff; a+=k[0]; break; + case 4 : a+=k[0]; break; + case 3 : a+=k[0]&0xffffff; break; + case 2 : a+=k[0]&0xffff; break; + case 1 : a+=k[0]&0xff; break; + case 0 : return c; /* zero length strings require no mixing */ + } + +#else /* make valgrind happy */ + + const quint8 *k8 = (const quint8 *)k; + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=((quint32)k8[10])<<16; /* fall through */ + case 10: c+=((quint32)k8[9])<<8; /* fall through */ + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=((quint32)k8[6])<<16; /* fall through */ + case 6 : b+=((quint32)k8[5])<<8; /* fall through */ + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]; break; + case 3 : a+=((quint32)k8[2])<<16; /* fall through */ + case 2 : a+=((quint32)k8[1])<<8; /* fall through */ + case 1 : a+=k8[0]; break; + case 0 : return c; + } + +#endif /* !valgrind */ + + } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { + const quint16 *k = (const quint16 *)key; /* read 16-bit chunks */ + const quint8 *k8; + + /*--------------- all but last block: aligned reads and different mixing */ + while (length > 12) + { + a += k[0] + (((quint32)k[1])<<16); + b += k[2] + (((quint32)k[3])<<16); + c += k[4] + (((quint32)k[5])<<16); + mix(a,b,c); + length -= 12; + k += 6; + } + + /*----------------------------- handle the last (probably partial) block */ + k8 = (const quint8 *)k; + switch(length) + { + case 12: c+=k[4]+(((quint32)k[5])<<16); + b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 11: c+=((quint32)k8[10])<<16; /* fall through */ + case 10: c+=k[4]; + b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 7 : b+=((quint32)k8[6])<<16; /* fall through */ + case 6 : b+=k[2]; + a+=k[0]+(((quint32)k[1])<<16); + break; + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]+(((quint32)k[1])<<16); + break; + case 3 : a+=((quint32)k8[2])<<16; /* fall through */ + case 2 : a+=k[0]; + break; + case 1 : a+=k8[0]; + break; + case 0 : return c; /* zero length requires no mixing */ + } + + } else { /* need to read the key one byte at a time */ + const quint8 *k = (const quint8 *)key; + + /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ + while (length > 12) + { + a += k[0]; + a += ((quint32)k[1])<<8; + a += ((quint32)k[2])<<16; + a += ((quint32)k[3])<<24; + b += k[4]; + b += ((quint32)k[5])<<8; + b += ((quint32)k[6])<<16; + b += ((quint32)k[7])<<24; + c += k[8]; + c += ((quint32)k[9])<<8; + c += ((quint32)k[10])<<16; + c += ((quint32)k[11])<<24; + mix(a,b,c); + length -= 12; + k += 12; + } + + /*-------------------------------- last block: affect all 32 bits of (c) */ + switch(length) /* all the case statements fall through */ + { + case 12: c+=((quint32)k[11])<<24; + case 11: c+=((quint32)k[10])<<16; + case 10: c+=((quint32)k[9])<<8; + case 9 : c+=k[8]; + case 8 : b+=((quint32)k[7])<<24; + case 7 : b+=((quint32)k[6])<<16; + case 6 : b+=((quint32)k[5])<<8; + case 5 : b+=k[4]; + case 4 : a+=((quint32)k[3])<<24; + case 3 : a+=((quint32)k[2])<<16; + case 2 : a+=((quint32)k[1])<<8; + case 1 : a+=k[0]; + break; + case 0 : return c; + } + } + + final(a,b,c); + return c; +} + + +/* + * hashlittle2: return 2 32-bit hash values + * + * This is identical to hashlittle(), except it returns two 32-bit hash + * values instead of just one. This is good enough for hash table + * lookup with 2^^64 buckets, or if you want a second hash if you're not + * happy with the first, or if you want a probably-unique 64-bit ID for + * the key. *pc is better mixed than *pb, so use *pc first. If you want + * a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)". + */ +void hashlittle2( + const void *key, /* the key to hash */ + size_t length, /* length of the key */ + quint32 *pc, /* IN: primary initval, OUT: primary hash */ + quint32 *pb) /* IN: secondary initval, OUT: secondary hash */ +{ + quint32 a,b,c; /* internal state */ + union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + ((quint32)length) + *pc; + c += *pb; + + u.ptr = key; + if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { + const quint32 *k = (const quint32 *)key; /* read 32-bit chunks */ + + /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ + while (length > 12) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 12; + k += 3; + } + + /*----------------------------- handle the last (probably partial) block */ + /* + * "k[2]&0xffffff" actually reads beyond the end of the string, but + * then masks off the part it's not allowed to read. Because the + * string is aligned, the masked-off tail is in the same word as the + * rest of the string. Every machine with memory protection I've seen + * does it on word boundaries, so is OK with this. But VALGRIND will + * still catch it and complain. The masking trick does make the hash + * noticably faster for short strings (like English words). + */ +#ifndef VALGRIND + + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; + case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; + case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=k[1]&0xffffff; a+=k[0]; break; + case 6 : b+=k[1]&0xffff; a+=k[0]; break; + case 5 : b+=k[1]&0xff; a+=k[0]; break; + case 4 : a+=k[0]; break; + case 3 : a+=k[0]&0xffffff; break; + case 2 : a+=k[0]&0xffff; break; + case 1 : a+=k[0]&0xff; break; + case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ + } + +#else /* make valgrind happy */ + + const quint8 *k8 = (const quint8 *)k; + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=((quint32)k8[10])<<16; /* fall through */ + case 10: c+=((quint32)k8[9])<<8; /* fall through */ + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=((quint32)k8[6])<<16; /* fall through */ + case 6 : b+=((quint32)k8[5])<<8; /* fall through */ + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]; break; + case 3 : a+=((quint32)k8[2])<<16; /* fall through */ + case 2 : a+=((quint32)k8[1])<<8; /* fall through */ + case 1 : a+=k8[0]; break; + case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ + } + +#endif /* !valgrind */ + + } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { + const quint16 *k = (const quint16 *)key; /* read 16-bit chunks */ + const quint8 *k8; + + /*--------------- all but last block: aligned reads and different mixing */ + while (length > 12) + { + a += k[0] + (((quint32)k[1])<<16); + b += k[2] + (((quint32)k[3])<<16); + c += k[4] + (((quint32)k[5])<<16); + mix(a,b,c); + length -= 12; + k += 6; + } + + /*----------------------------- handle the last (probably partial) block */ + k8 = (const quint8 *)k; + switch(length) + { + case 12: c+=k[4]+(((quint32)k[5])<<16); + b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 11: c+=((quint32)k8[10])<<16; /* fall through */ + case 10: c+=k[4]; + b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[2]+(((quint32)k[3])<<16); + a+=k[0]+(((quint32)k[1])<<16); + break; + case 7 : b+=((quint32)k8[6])<<16; /* fall through */ + case 6 : b+=k[2]; + a+=k[0]+(((quint32)k[1])<<16); + break; + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]+(((quint32)k[1])<<16); + break; + case 3 : a+=((quint32)k8[2])<<16; /* fall through */ + case 2 : a+=k[0]; + break; + case 1 : a+=k8[0]; + break; + case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ + } + + } else { /* need to read the key one byte at a time */ + const quint8 *k = (const quint8 *)key; + + /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ + while (length > 12) + { + a += k[0]; + a += ((quint32)k[1])<<8; + a += ((quint32)k[2])<<16; + a += ((quint32)k[3])<<24; + b += k[4]; + b += ((quint32)k[5])<<8; + b += ((quint32)k[6])<<16; + b += ((quint32)k[7])<<24; + c += k[8]; + c += ((quint32)k[9])<<8; + c += ((quint32)k[10])<<16; + c += ((quint32)k[11])<<24; + mix(a,b,c); + length -= 12; + k += 12; + } + + /*-------------------------------- last block: affect all 32 bits of (c) */ + switch(length) /* all the case statements fall through */ + { + case 12: c+=((quint32)k[11])<<24; + case 11: c+=((quint32)k[10])<<16; + case 10: c+=((quint32)k[9])<<8; + case 9 : c+=k[8]; + case 8 : b+=((quint32)k[7])<<24; + case 7 : b+=((quint32)k[6])<<16; + case 6 : b+=((quint32)k[5])<<8; + case 5 : b+=k[4]; + case 4 : a+=((quint32)k[3])<<24; + case 3 : a+=((quint32)k[2])<<16; + case 2 : a+=((quint32)k[1])<<8; + case 1 : a+=k[0]; + break; + case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ + } + } + + final(a,b,c); + *pc=c; *pb=b; +} + + + +/* + * hashbig(): + * This is the same as hashword() on big-endian machines. It is different + * from hashlittle() on all machines. hashbig() takes advantage of + * big-endian byte ordering. + */ +quint32 hashbig( const void *key, size_t length, quint32 initval) +{ + quint32 a,b,c; + union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */ + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + ((quint32)length) + initval; + + u.ptr = key; + if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) { + const quint32 *k = (const quint32 *)key; /* read 32-bit chunks */ + + /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ + while (length > 12) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 12; + k += 3; + } + + /*----------------------------- handle the last (probably partial) block */ + /* + * "k[2]<<8" actually reads beyond the end of the string, but + * then shifts out the part it's not allowed to read. Because the + * string is aligned, the illegal read is in the same word as the + * rest of the string. Every machine with memory protection I've seen + * does it on word boundaries, so is OK with this. But VALGRIND will + * still catch it and complain. The masking trick does make the hash + * noticably faster for short strings (like English words). + */ +#ifndef VALGRIND + + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=k[2]&0xffffff00; b+=k[1]; a+=k[0]; break; + case 10: c+=k[2]&0xffff0000; b+=k[1]; a+=k[0]; break; + case 9 : c+=k[2]&0xff000000; b+=k[1]; a+=k[0]; break; + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=k[1]&0xffffff00; a+=k[0]; break; + case 6 : b+=k[1]&0xffff0000; a+=k[0]; break; + case 5 : b+=k[1]&0xff000000; a+=k[0]; break; + case 4 : a+=k[0]; break; + case 3 : a+=k[0]&0xffffff00; break; + case 2 : a+=k[0]&0xffff0000; break; + case 1 : a+=k[0]&0xff000000; break; + case 0 : return c; /* zero length strings require no mixing */ + } + +#else /* make valgrind happy */ + + const quint8 *k8 = (const quint8 *)k; + switch(length) /* all the case statements fall through */ + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=((quint32)k8[10])<<8; /* fall through */ + case 10: c+=((quint32)k8[9])<<16; /* fall through */ + case 9 : c+=((quint32)k8[8])<<24; /* fall through */ + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=((quint32)k8[6])<<8; /* fall through */ + case 6 : b+=((quint32)k8[5])<<16; /* fall through */ + case 5 : b+=((quint32)k8[4])<<24; /* fall through */ + case 4 : a+=k[0]; break; + case 3 : a+=((quint32)k8[2])<<8; /* fall through */ + case 2 : a+=((quint32)k8[1])<<16; /* fall through */ + case 1 : a+=((quint32)k8[0])<<24; break; + case 0 : return c; + } + +#endif /* !VALGRIND */ + + } else { /* need to read the key one byte at a time */ + const quint8 *k = (const quint8 *)key; + + /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ + while (length > 12) + { + a += ((quint32)k[0])<<24; + a += ((quint32)k[1])<<16; + a += ((quint32)k[2])<<8; + a += ((quint32)k[3]); + b += ((quint32)k[4])<<24; + b += ((quint32)k[5])<<16; + b += ((quint32)k[6])<<8; + b += ((quint32)k[7]); + c += ((quint32)k[8])<<24; + c += ((quint32)k[9])<<16; + c += ((quint32)k[10])<<8; + c += ((quint32)k[11]); + mix(a,b,c); + length -= 12; + k += 12; + } + + /*-------------------------------- last block: affect all 32 bits of (c) */ + switch(length) /* all the case statements fall through */ + { + case 12: c+=k[11]; + case 11: c+=((quint32)k[10])<<8; + case 10: c+=((quint32)k[9])<<16; + case 9 : c+=((quint32)k[8])<<24; + case 8 : b+=k[7]; + case 7 : b+=((quint32)k[6])<<8; + case 6 : b+=((quint32)k[5])<<16; + case 5 : b+=((quint32)k[4])<<24; + case 4 : a+=k[3]; + case 3 : a+=((quint32)k[2])<<8; + case 2 : a+=((quint32)k[1])<<16; + case 1 : a+=((quint32)k[0])<<24; + break; + case 0 : return c; + } + } + + final(a,b,c); + return c; +} -- cgit v0.12 From e800ada8fea5b3f5858574696b373959a8e15b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 6 Sep 2010 14:14:59 +0200 Subject: We only want to test hw accelerated GL 2.0 implementations. --- tests/auto/lancelot/tst_lancelot.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 7381c1d..23a5c94 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -175,7 +175,14 @@ void tst_Lancelot::testOpenGL_data() void tst_Lancelot::testOpenGL() { - runTestSuite(); + QGLWidget glWidget; + if (glWidget.isValid() && glWidget.format().directRendering() + && (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) + { + runTestSuite(); + } else { + QSKIP("System under test does not meet preconditions for GL testing. Skipping.", SkipAll); + } } -- cgit v0.12 From c142da9f1573738bb0c9e4c728bab4b3c2c8f438 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 7 Sep 2010 10:22:12 +0200 Subject: Minor style improvements --- tests/arthur/common/baselineprotocol.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 7a423d2..24b5b8c 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -1,4 +1,3 @@ - #include "baselineprotocol.h" #include #include @@ -40,16 +39,13 @@ ImageItem &ImageItem::operator=(const ImageItem &other) // Defined in lookup3.c: void hashword2 ( -const quint32 *k, /* the key, an array of quint32 values */ -size_t length, /* the length of the key, in quint32s */ -quint32 *pc, /* IN: seed OUT: primary hash value */ -quint32 *pb); /* IN: more seed OUT: secondary hash value */ +const quint32 *k, /* the key, an array of quint32 values */ +size_t length, /* the length of the key, in quint32s */ +quint32 *pc, /* IN: seed OUT: primary hash value */ +quint32 *pb); /* IN: more seed OUT: secondary hash value */ quint64 ImageItem::computeChecksum(const QImage &image) { - quint32 h1 = 0xfeedbacc; - quint32 h2 = 0x21604894; - QImage img(image); const int bpl = img.bytesPerLine(); const int padBytes = bpl - (img.width() * img.depth() / 8); @@ -68,6 +64,8 @@ quint64 ImageItem::computeChecksum(const QImage &image) *p++ &= RGB_MASK; } + quint32 h1 = 0xfeedbacc; + quint32 h2 = 0x21604894; hashword2((const quint32 *)img.constBits(), img.byteCount()/4, &h1, &h2); return (quint64(h1) << 32) | h2; } -- cgit v0.12 From b146492b9319c80bde174f1a188ece89963eae3a Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 7 Sep 2010 11:50:03 +0200 Subject: Avoid testing on Mesa --- tests/auto/lancelot/tst_lancelot.cpp | 82 +++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 23a5c94..c968473 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -70,6 +70,7 @@ private: void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); QStringList loadScriptFile(const QString &filePath); void runTestSuite(); + bool setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist); BaselineProtocol proto; ImageItemList baseList; @@ -80,6 +81,8 @@ private slots: void testRasterARGB32PM_data(); void testRasterARGB32PM(); + void testRasterRGB32_data(); + void testRasterRGB32(); void testOpenGL_data(); void testOpenGL(); @@ -122,28 +125,27 @@ void tst_Lancelot::initTestCase() void tst_Lancelot::testRasterARGB32PM_data() { - QTest::addColumn("baseline"); + QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + if (!setupTestSuite(ImageItem::Raster, QImage::Format_ARGB32_Premultiplied, localBlacklist)) + QSKIP("Communication with baseline image server failed.", SkipAll); +} - ImageItemList itemList(baseList); - for(ImageItemList::iterator it = itemList.begin(); it != itemList.end(); it++) { - it->engine = ImageItem::Raster; - it->renderFormat = QImage::Format_ARGB32_Premultiplied; - } +void tst_Lancelot::testRasterARGB32PM() +{ + runTestSuite(); +} - if (!proto.requestBaselineChecksums(&itemList)) { - QWARN(qPrintable(proto.errorMessage())); - QSKIP("Communication with baseline image server failed.", SkipAll); - } - foreach(const ImageItem& item, itemList) { - if (item.scriptName != QLatin1String("sizes.qps")) // Example of hardcoded blacklisting for this enigine/format - QTest::newRow(item.scriptName.toLatin1()) << item; - } +void tst_Lancelot::testRasterRGB32_data() +{ + QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB32, localBlacklist)) + QSKIP("Communication with baseline image server failed.", SkipAll); } -void tst_Lancelot::testRasterARGB32PM() +void tst_Lancelot::testRasterRGB32() { runTestSuite(); } @@ -151,38 +153,50 @@ void tst_Lancelot::testRasterARGB32PM() void tst_Lancelot::testOpenGL_data() { + QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + if (!setupTestSuite(ImageItem::OpenGL, QImage::Format_RGB32, localBlacklist)) + QSKIP("Communication with baseline image server failed.", SkipAll); +} + + +void tst_Lancelot::testOpenGL() +{ + bool ok = false; + QGLWidget glWidget; + if (glWidget.isValid() && glWidget.format().directRendering() + && (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) { + glWidget.makeCurrent(); + if (!QByteArray((const char *)glGetString(GL_RENDERER)).contains("Mesa")) + ok = true; + } + if (ok) + runTestSuite(); + else + QSKIP("System under test does not meet preconditions for GL testing. Skipping.", SkipAll); +} + + +bool tst_Lancelot::setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist) +{ QTest::addColumn("baseline"); ImageItemList itemList(baseList); - for(int i = 0; i < itemList.size(); i++) { - itemList[i].engine = ImageItem::OpenGL; - itemList[i].renderFormat = QImage::Format_RGB32; + for(ImageItemList::iterator it = itemList.begin(); it != itemList.end(); it++) { + it->engine = engine; + it->renderFormat = format; } if (!proto.requestBaselineChecksums(&itemList)) { QWARN(qPrintable(proto.errorMessage())); - QSKIP("Communication with baseline image server failed.", SkipAll); + return false; } - qDebug() << "items:" << itemList.count(); foreach(const ImageItem& item, itemList) { - if (item.scriptName != QLatin1String("sizes.qps")) // Hardcoded blacklisting for this enigine/format + if (!blacklist.contains(item.scriptName)) QTest::newRow(item.scriptName.toLatin1()) << item; } -} - - -void tst_Lancelot::testOpenGL() -{ - QGLWidget glWidget; - if (glWidget.isValid() && glWidget.format().directRendering() - && (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) - { - runTestSuite(); - } else { - QSKIP("System under test does not meet preconditions for GL testing. Skipping.", SkipAll); - } + return true; } -- cgit v0.12 From bf12d2047b00eb88d96f2767b07c47bbb8df6b89 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 7 Sep 2010 12:57:38 +0200 Subject: Improve servers storage directory structure - support different pixel formats for same engine - separate baselines per hostname --- tests/arthur/baselineserver/src/baselineserver.cpp | 21 ++++++++--------- tests/arthur/common/baselineprotocol.cpp | 26 ++++++++++++++++++++++ tests/arthur/common/baselineprotocol.h | 1 + 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index ec5793f..685fcae 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -118,7 +118,7 @@ void BaselineHandler::receiveRequest() break; default: qWarning() << runId << logtime() << "Unknown command received. " << proto.errorMessage(); - QThread::currentThread()->exit(1); + proto.sendBlock(BaselineProtocol::UnknownError, QByteArray()); } } @@ -191,15 +191,16 @@ void BaselineHandler::receiveDisconnect() QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) { - QString storePath = BaselineServer::storagePath(); - storePath += plat.buildKey.section(QLatin1Char(' '), 1, 1) + QLatin1String("_Qt-") - + plat.qtVersion + QDir::separator(); - if (isBaseline) { - storePath += QLatin1String("baselines") + QDir::separator() - + item.engineAsString() + QDir::separator(); - } else { - storePath += runId + QDir::separator(); - } + QString host = plat.hostname; + //# tbd: if "localhost", replace with smth meaningful + host.replace(QRegExp(QLatin1String("^(bq|oslo)-(.*)-\\d\\d$")), QLatin1String("vm-\\2")); + QString pathForRun = BaselineServer::storagePath() + host + QLatin1Char('/'); + + QString storePath = pathForRun; + if (isBaseline) + storePath += QString(QLatin1String("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); + else + storePath += runId + QLatin1Char('/'); //#? QString itemName = item.scriptName.replace(item.scriptName.lastIndexOf('.'), '_'); return storePath + item.scriptName + QLatin1Char('.'); } diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 24b5b8c..417474d 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -85,6 +85,32 @@ QString ImageItem::engineAsString() const return QLatin1String("Unknown"); } +QString ImageItem::formatAsString() const +{ + static const int numFormats = 16; + static const char *formatNames[numFormats] = { + "Invalid", + "Mono", + "MonoLSB", + "Indexed8", + "RGB32", + "ARGB32", + "ARGB32-Premult", + "RGB16", + "ARGB8565-Premult", + "RGB666", + "ARGB6666-Premult", + "RGB555", + "ARGB8555-Premult", + "RGB888", + "RGB444", + "ARGB4444-Premult" + }; + if (renderFormat < 0 || renderFormat >= numFormats) + return QLatin1String("UnknownFormat"); + return QLatin1String(formatNames[renderFormat]); +} + QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { stream << ii.scriptName << ii.scriptChecksum << quint8(ii.status) << quint8(ii.renderFormat) diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 9ec1ef4..b3e853d 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -32,6 +32,7 @@ public: ImageItem &operator=(const ImageItem &other); static quint64 computeChecksum(const QImage& image); QString engineAsString() const; + QString formatAsString() const; enum ItemStatus { Ok = 0, -- cgit v0.12 From f1c5c0c1580e68d28eae0373e5df2b92be437af3 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 7 Sep 2010 14:02:30 +0200 Subject: More server storage path fixing --- tests/arthur/baselineserver/src/baselineserver.cpp | 22 +++++++++++++++------- tests/arthur/baselineserver/src/baselineserver.h | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 685fcae..e7a994f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -94,7 +94,7 @@ void BaselineHandler::receiveRequest() return; } connectionEstablished = true; - qDebug() << runId << logtime() << "Connection established with" << plat.hostname << "Qt version:" << plat.qtVersion << plat.buildKey; + qDebug() << runId << logtime() << "Connection established with" << plat.hostname << proto.socket.peerAddress().toString() << "Qt version:" << plat.qtVersion << plat.buildKey; return; } @@ -191,18 +191,26 @@ void BaselineHandler::receiveDisconnect() QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) { - QString host = plat.hostname; - //# tbd: if "localhost", replace with smth meaningful - host.replace(QRegExp(QLatin1String("^(bq|oslo)-(.*)-\\d\\d$")), QLatin1String("vm-\\2")); - QString pathForRun = BaselineServer::storagePath() + host + QLatin1Char('/'); + if (pathForRun.isNull()) { + QString host = plat.hostname; + if (host == QLatin1String("localhost")) + host = proto.socket.peerAddress().toString(); + else + host.replace(QRegExp(QLatin1String("^(bq|oslo)-(.*)-\\d\\d$")), QLatin1String("vm-\\2")); + pathForRun = BaselineServer::storagePath() + host + QLatin1Char('/'); + } QString storePath = pathForRun; if (isBaseline) storePath += QString(QLatin1String("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); else storePath += runId + QLatin1Char('/'); - //#? QString itemName = item.scriptName.replace(item.scriptName.lastIndexOf('.'), '_'); - return storePath + item.scriptName + QLatin1Char('.'); + + QString itemName = item.scriptName; + if (itemName.contains(QLatin1Char('.'))) + itemName.replace(itemName.lastIndexOf(QLatin1Char('.')), 1, QLatin1Char('_')); + + return storePath + itemName + QLatin1Char('.'); } QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QImage &rendered) diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 2963fd1..683d2fd 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -72,6 +72,7 @@ private: PlatformInfo plat; bool connectionEstablished; QString runId; + QString pathForRun; }; #endif // BASELINESERVER_H -- cgit v0.12 From 5e3d55cc6fc3216e0079bb9d0c835338c9ac2ef8 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 7 Sep 2010 15:01:32 +0200 Subject: Add another format, and blacklist some more --- tests/arthur/baselineserver/src/baselineserver.cpp | 5 +++++ tests/auto/lancelot/tst_lancelot.cpp | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index e7a994f..5328f59 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -131,6 +131,11 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items"; for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { + if (i->scriptName.startsWith(QLatin1String("porter_duff"))) { + // Example of blacklisting on server. + i->status = ImageItem::IgnoreItem; + continue; + } i->imageChecksum = 0; QString prefix = pathForItem(*i, true); QFile file(prefix + QLatin1String("metadata")); diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index c968473..0f57c1e 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -83,6 +83,8 @@ private slots: void testRasterARGB32PM(); void testRasterRGB32_data(); void testRasterRGB32(); + void testRasterRGB16_data(); + void testRasterRGB16(); void testOpenGL_data(); void testOpenGL(); @@ -151,9 +153,23 @@ void tst_Lancelot::testRasterRGB32() } -void tst_Lancelot::testOpenGL_data() +void tst_Lancelot::testRasterRGB16_data() { QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB16, localBlacklist)) + QSKIP("Communication with baseline image server failed.", SkipAll); +} + + +void tst_Lancelot::testRasterRGB16() +{ + runTestSuite(); +} + + +void tst_Lancelot::testOpenGL_data() +{ + QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps") << QLatin1String("rasterops.qps"); if (!setupTestSuite(ImageItem::OpenGL, QImage::Format_RGB32, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } -- cgit v0.12 From a59566262ebd226a901172fc06c7bcb9023d5a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 7 Sep 2010 15:55:27 +0200 Subject: Make it possible to have several checksums associated with one ImageItem. Also changed the meta file from being a text file to a binary file. Nothing uses the extra checksums yet, but that should be added soon. --- tests/arthur/baselineserver/src/baselineserver.cpp | 12 +++++----- tests/arthur/common/baselineprotocol.cpp | 26 +++++++++++++++++++--- tests/arthur/common/baselineprotocol.h | 8 +++++-- tests/auto/lancelot/tst_lancelot.cpp | 18 +++++++-------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 5328f59..5a96b90 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -136,16 +136,16 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) i->status = ImageItem::IgnoreItem; continue; } - i->imageChecksum = 0; + i->imageChecksums.clear(); QString prefix = pathForItem(*i, true); QFile file(prefix + QLatin1String("metadata")); if (file.open(QIODevice::ReadOnly)) { - QTextStream ts(&file); - ts >> i->imageChecksum; + QDataStream checkSums(&file); + checkSums >> i->imageChecksums; file.close(); i->status = ImageItem::Ok; } - if (!i->imageChecksum) + if (!i->imageChecksums.count()) i->status = ImageItem::BaselineNotFound; } @@ -174,8 +174,8 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) //# Could use QSettings or XML or even DB, could use common file for whole dir or even whole storage - but for now, keep it simple QFile file(prefix + QLatin1String("metadata")); file.open(QIODevice::WriteOnly | QIODevice::Truncate); - QTextStream ts(&file); - ts << hex << showbase << item.imageChecksum << reset << endl; + QDataStream checkSums(&file); + checkSums << item.imageChecksums; file.close(); QByteArray msg(isBaseline ? "Baseline" : "Mismatching" ); diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 417474d..cbead24 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -33,7 +33,7 @@ ImageItem &ImageItem::operator=(const ImageItem &other) renderFormat = other.renderFormat; engine = other.engine; image = other.image; - imageChecksum = other.imageChecksum; + imageChecksums = other.imageChecksums; return *this; } @@ -114,7 +114,7 @@ QString ImageItem::formatAsString() const QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { stream << ii.scriptName << ii.scriptChecksum << quint8(ii.status) << quint8(ii.renderFormat) - << quint8(ii.engine) << ii.image << ii.imageChecksum; + << quint8(ii.engine) << ii.image << ii.imageChecksums; return stream; } @@ -122,13 +122,33 @@ QDataStream & operator>> (QDataStream &stream, ImageItem &ii) { quint8 encFormat, encStatus, encEngine; stream >> ii.scriptName >> ii.scriptChecksum >> encStatus >> encFormat - >> encEngine >> ii.image >> ii.imageChecksum; + >> encEngine >> ii.image >> ii.imageChecksums; ii.renderFormat = QImage::Format(encFormat); ii.status = ImageItem::ItemStatus(encStatus); ii.engine = ImageItem::GraphicsEngine(encEngine); return stream; } +QDataStream & operator<< (QDataStream &stream, const QList &checkSumList) +{ + stream << quint32(checkSumList.count()); + foreach(quint64 checksum, checkSumList) + stream << checksum; + return stream; +} + +QDataStream & operator>> (QDataStream &stream, QList &checkSumList) +{ + quint32 numChecksums; + stream >> numChecksums; + quint64 checkSum; + for (int i=0; i<(int)numChecksums; ++i) { + stream >> checkSum; + checkSumList.append(checkSum); + } + return stream; +} + BaselineProtocol::~BaselineProtocol() { socket.close(); diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index b3e853d..1cd8bb6 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -23,7 +23,7 @@ struct ImageItem { public: ImageItem() - : status(Ok), renderFormat(QImage::Format_Invalid), engine(Raster), imageChecksum(0), scriptChecksum(0) + : status(Ok), renderFormat(QImage::Format_Invalid), engine(Raster), scriptChecksum(0) {} ImageItem(const ImageItem &other) { *this = other; } @@ -50,15 +50,19 @@ public: QImage::Format renderFormat; GraphicsEngine engine; QImage image; - quint64 imageChecksum; + QList imageChecksums; // tbd: add diffscore quint16 scriptChecksum; }; QDataStream & operator<< (QDataStream &stream, const ImageItem &ii); QDataStream & operator>> (QDataStream& stream, ImageItem& ii); + Q_DECLARE_METATYPE(ImageItem); +QDataStream & operator<< (QDataStream &stream, const QList &checkSumList); +QDataStream & operator>> (QDataStream &stream, QList &checkSumList); + typedef QVector ImageItemList; diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 0f57c1e..0226cc6 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -234,11 +234,11 @@ void tst_Lancelot::runTestSuite() QSKIP("Baseline not found; new baseline created.", SkipSingle); } - if (rendered.imageChecksum != baseline.imageChecksum) { - QByteArray serverMsg; - if (!proto.submitMismatch(rendered, &serverMsg)) - serverMsg = "Failed to submit mismatching image to server."; - QFAIL("Rendered image differs from baseline.\n" + serverMsg); + if (!baseline.imageChecksums.contains(rendered.imageChecksums.at(0))) { + QByteArray serverMsg; + if (!proto.submitMismatch(rendered, &serverMsg)) + serverMsg = "Failed to submit mismatching image to server."; + QFAIL("Rendered image differs from baseline.\n" + serverMsg); } } @@ -250,17 +250,17 @@ ImageItem tst_Lancelot::render(const ImageItem &item) QStringList script = loadScriptFile(filePath); if (script.isEmpty()) { res.image = QImage(); - res.imageChecksum = 0; + res.imageChecksums.append(0); } else if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) res.image = img; - res.imageChecksum = ImageItem::computeChecksum(img); + res.imageChecksums.append(ImageItem::computeChecksum(img)); } else if (item.engine == ImageItem::OpenGL) { QGLWidget glWidget; if (!glWidget.isValid()) { res.image = QImage(); - res.imageChecksum = 0; + res.imageChecksums.append(0); return res; } glWidget.resize(800, 800); @@ -270,7 +270,7 @@ ImageItem tst_Lancelot::render(const ImageItem &item) #endif paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat); - res.imageChecksum = ImageItem::computeChecksum(res.image); + res.imageChecksums.append(ImageItem::computeChecksum(res.image)); } return res; -- cgit v0.12 From 296e37e29bb0b364340e1813e18c460354b74acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 7 Sep 2010 16:13:10 +0200 Subject: It's the GL_VERSION string that usually contains the Mesa substring. This of course differs, depending on the different backends used, but so far it seems most of the Mesa implementations have Mesa mentioned in the version string. --- tests/auto/lancelot/tst_lancelot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 0226cc6..b2d5a7b 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -182,7 +182,7 @@ void tst_Lancelot::testOpenGL() if (glWidget.isValid() && glWidget.format().directRendering() && (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) { glWidget.makeCurrent(); - if (!QByteArray((const char *)glGetString(GL_RENDERER)).contains("Mesa")) + if (!QByteArray((const char *)glGetString(GL_VERSION)).contains("Mesa")) ok = true; } if (ok) -- cgit v0.12 From 1743a8bea43066c52cf07f6c8a859c3d9ddb65da Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 8 Sep 2010 09:09:35 +0200 Subject: Fix: remove baseline checksums before adding rendered .. otherwise, the comparison will always yield true... Also a simplification: QList provides default datastreaming ops --- tests/arthur/common/baselineprotocol.cpp | 20 -------------------- tests/arthur/common/baselineprotocol.h | 5 ----- tests/auto/lancelot/tst_lancelot.cpp | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index cbead24..7996fff 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -129,26 +129,6 @@ QDataStream & operator>> (QDataStream &stream, ImageItem &ii) return stream; } -QDataStream & operator<< (QDataStream &stream, const QList &checkSumList) -{ - stream << quint32(checkSumList.count()); - foreach(quint64 checksum, checkSumList) - stream << checksum; - return stream; -} - -QDataStream & operator>> (QDataStream &stream, QList &checkSumList) -{ - quint32 numChecksums; - stream >> numChecksums; - quint64 checkSum; - for (int i=0; i<(int)numChecksums; ++i) { - stream >> checkSum; - checkSumList.append(checkSum); - } - return stream; -} - BaselineProtocol::~BaselineProtocol() { socket.close(); diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 1cd8bb6..5427023 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -57,15 +57,10 @@ public: QDataStream & operator<< (QDataStream &stream, const ImageItem &ii); QDataStream & operator>> (QDataStream& stream, ImageItem& ii); - Q_DECLARE_METATYPE(ImageItem); -QDataStream & operator<< (QDataStream &stream, const QList &checkSumList); -QDataStream & operator>> (QDataStream &stream, QList &checkSumList); - typedef QVector ImageItemList; - class BaselineProtocol { public: diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index b2d5a7b..aba544f 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -246,11 +246,11 @@ void tst_Lancelot::runTestSuite() ImageItem tst_Lancelot::render(const ImageItem &item) { ImageItem res = item; + res.imageChecksums.clear(); QString filePath = scriptsDir + item.scriptName; QStringList script = loadScriptFile(filePath); if (script.isEmpty()) { res.image = QImage(); - res.imageChecksums.append(0); } else if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) -- cgit v0.12 From 45d5811cb2b47e41d7bb0be4cd44e5aef739f804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 8 Sep 2010 11:57:22 +0200 Subject: Check the QT_LANCELOT_SERVER env var for the servername. --- tests/arthur/common/baselineprotocol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 7996fff..34d1a04 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -141,7 +141,9 @@ bool BaselineProtocol::connect() { errMsg.clear(); //###TBD: determine server address; for now local devhost - QLatin1String serverName("chimera.europe.nokia.com"); + QByteArray serverName(qgetenv("QT_LANCELOT_SERVER")); + if (serverName.isNull()) + serverName = "chimera.europe.nokia.com"; socket.connectToHost(serverName, ServerPort); -- cgit v0.12 From 6d4003b0fd742ee2be2e536091d5b65d72d01ce0 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 8 Sep 2010 13:29:43 +0200 Subject: Shave 25% off test time by smarter qps script parsing --- tests/arthur/common/paintcommands.cpp | 27 ++++++++++++++++++++++++--- tests/arthur/common/paintcommands.h | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index 70d419e..1d7b810 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -185,6 +185,7 @@ int PaintCommands::translateEnum(const char *table[], const QString &pattern, in QList PaintCommands::s_commandInfoTable = QList(); QList > PaintCommands::s_enumsTable = QList >(); +QMultiHash PaintCommands::s_commandHash; #define DECL_PAINTCOMMAND(identifier, method, regexp, syntax, sample) \ s_commandInfoTable << PaintCommandInfos(QLatin1String(identifier), &PaintCommands::method, QRegExp(regexp), \ @@ -627,6 +628,15 @@ void PaintCommands::staticInit() "\n - where vertices 1 to 4 defines the source quad and 5 to 8 the destination quad", "mapQuadToQuad 0.0 0.0 1.0 1.0 0.0 0.0 -1.0 -1.0"); + // populate the command lookup hash + for (int i=0; i= 0) { + if (scriptLine.isEmpty()) { + command_noop(QRegExp()); + return; + } + if (scriptLine.startsWith('#')) { + command_comment(QRegExp()); + return; + } + QString firstWord = scriptLine.section(QRegExp("\\s"), 0, 0); + QList indices = s_commandHash.values(firstWord); + foreach(int idx, indices) { + const PaintCommandInfos &command = s_commandInfoTable.at(idx); + if (command.regExp.indexIn(scriptLine) >= 0) { (this->*(command.paintMethod))(command.regExp); return; } + } qWarning("ERROR: unknown command or argument syntax error in \"%s\"", qPrintable(scriptLine)); } diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index aed4840..4d966b8 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -48,6 +48,7 @@ #include #include #include +#include QT_FORWARD_DECLARE_CLASS(QPainter) QT_FORWARD_DECLARE_CLASS(QRegExp) @@ -329,6 +330,7 @@ public: static QList s_commandInfoTable; static QList > s_enumsTable; + static QMultiHash s_commandHash; }; #endif // PAINTCOMMANDS_H -- cgit v0.12 From 4d89a1dc2ea1f1dfbb6109d940496e924185fe13 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 8 Sep 2010 15:20:08 +0200 Subject: Opened for running on Mac too --- tests/auto/lancelot/tst_lancelot.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index aba544f..4792aa5 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -100,8 +100,8 @@ void tst_Lancelot::initTestCase() // (e.g. script files not found) as just warnings, and not QFAILs, to avoid false negatives // caused by environment or server instability -#if !defined(Q_OS_LINUX) - QSKIP("For the moment, this test is only supported on Linux.", SkipAll); +#if !defined(Q_OS_LINUX) && !defined(Q_OS_MAC) + QSKIP("For the moment, this test is only supported on Linux & Mac.", SkipAll); #endif if (!proto.connect()) { QWARN(qPrintable(proto.errorMessage())); @@ -169,6 +169,9 @@ void tst_Lancelot::testRasterRGB16() void tst_Lancelot::testOpenGL_data() { +#if defined(Q_OS_MAC) + QSKIP("OpenGL testing not supported on this platform.", SkipAll); +#endif QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps") << QLatin1String("rasterops.qps"); if (!setupTestSuite(ImageItem::OpenGL, QImage::Format_RGB32, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); -- cgit v0.12 From 3c29f241cebf18f4927579e054e2906915328cac Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 9 Sep 2010 10:46:34 +0200 Subject: Improved server logging and more robust client connection attempt Also misc minor improvements all around --- tests/arthur/baselineserver/bin/runserver | 11 +++++++-- tests/arthur/baselineserver/src/baselineserver.cpp | 7 +++--- tests/arthur/common/baselineprotocol.cpp | 17 ++++++++++---- tests/arthur/common/baselineprotocol.h | 3 --- tests/auto/lancelot/tst_lancelot.cpp | 27 +++++++++++----------- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/tests/arthur/baselineserver/bin/runserver b/tests/arthur/baselineserver/bin/runserver index 52feb86..48c5c1d 100755 --- a/tests/arthur/baselineserver/bin/runserver +++ b/tests/arthur/baselineserver/bin/runserver @@ -1,6 +1,13 @@ #!/bin/bash +logfile=baselineserver.log + while true; do - ./baselineserver - sleep 5 + echo >> $logfile + echo -n "***RESTARTING*** " >> $logfile + date >> $logfile + + ./baselineserver 2>&1 | tee -a $logfile + + sleep 2 done diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 5a96b90..2eee408 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -128,7 +128,8 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) ImageItemList itemList; QDataStream ds(itemListBlock); ds >> itemList; - qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items"; + qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items, engine" + << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { if (i->scriptName.startsWith(QLatin1String("porter_duff"))) { @@ -182,7 +183,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) msg += " image stored in " + QHostInfo::localHostName().toLatin1() + '.' + QHostInfo::localDomainName().toLatin1() + ':' - + QFileInfo(file).absoluteFilePath().toLatin1(); + + prefix.toLatin1() + FileFormat; proto.sendBlock(BaselineProtocol::Ack, msg); } @@ -209,7 +210,7 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) if (isBaseline) storePath += QString(QLatin1String("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); else - storePath += runId + QLatin1Char('/'); + storePath += QString(QLatin1String("mismatches_%1_%2/")).arg(item.engineAsString(), item.formatAsString()) + runId + QLatin1Char('/'); QString itemName = item.scriptName; if (itemName.contains(QLatin1Char('.'))) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 34d1a04..01ae67a 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -3,6 +3,7 @@ #include #include #include +#include PlatformInfo::PlatformInfo(bool useLocal) { @@ -145,11 +146,17 @@ bool BaselineProtocol::connect() if (serverName.isNull()) serverName = "chimera.europe.nokia.com"; - socket.connectToHost(serverName, ServerPort); - - if (!socket.waitForConnected(Timeout)) { - errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); - return false; + for (int i = 0; i < 2; i++) { + socket.connectToHost(serverName, ServerPort); + if (!socket.waitForConnected(Timeout)) { + if (!i && socket.error() == QAbstractSocket::ConnectionRefusedError) { + QTest::qSleep(3000); // In case the server is just restarting, we try again + continue; + } + errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); + return false; + } + break; } PlatformInfo pi(true); diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 5427023..062a99c 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -111,7 +111,4 @@ private: }; - - - #endif // BASELINEPROTOCOL_H diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 4792aa5..13a20e9 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -250,30 +250,29 @@ ImageItem tst_Lancelot::render(const ImageItem &item) { ImageItem res = item; res.imageChecksums.clear(); + res.image = QImage(); QString filePath = scriptsDir + item.scriptName; QStringList script = loadScriptFile(filePath); - if (script.isEmpty()) { - res.image = QImage(); - } else if (item.engine == ImageItem::Raster) { + if (script.isEmpty()) + return res; + + if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) res.image = img; res.imageChecksums.append(ImageItem::computeChecksum(img)); } else if (item.engine == ImageItem::OpenGL) { QGLWidget glWidget; - if (!glWidget.isValid()) { - res.image = QImage(); - res.imageChecksums.append(0); - return res; - } - glWidget.resize(800, 800); - glWidget.show(); + if (glWidget.isValid()) { + glWidget.resize(800, 800); + glWidget.show(); #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&glWidget); + qt_x11_wait_for_window_manager(&glWidget); #endif - paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) - res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat); - res.imageChecksums.append(ImageItem::computeChecksum(res.image)); + paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) + res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat); + res.imageChecksums.append(ImageItem::computeChecksum(res.image)); + } } return res; -- cgit v0.12 From 437ae33b11c703ef33ebdede379b32463f22a2ee Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 9 Sep 2010 10:55:03 +0200 Subject: Open up for all platforms --- tests/auto/lancelot/tst_lancelot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 13a20e9..40fe7f2 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -100,8 +100,8 @@ void tst_Lancelot::initTestCase() // (e.g. script files not found) as just warnings, and not QFAILs, to avoid false negatives // caused by environment or server instability -#if !defined(Q_OS_LINUX) && !defined(Q_OS_MAC) - QSKIP("For the moment, this test is only supported on Linux & Mac.", SkipAll); +#if defined(Q_OS_SOMEPLATFORM) + QSKIP("This test is not supported on this platform.", SkipAll); #endif if (!proto.connect()) { QWARN(qPrintable(proto.errorMessage())); -- cgit v0.12 From 738b93fd6676a24880e1ae1c603f9457b43de831 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 10 Sep 2010 15:07:57 +0200 Subject: Improved path mapping, added test mode for it. Misc improvements. --- tests/arthur/baselineserver/src/baselineserver.cpp | 85 ++++++++++++++++------ tests/arthur/baselineserver/src/baselineserver.h | 3 +- tests/arthur/baselineserver/src/main.cpp | 7 ++ tests/arthur/common/baselineprotocol.cpp | 16 +--- tests/auto/lancelot/tst_lancelot.cpp | 7 +- 5 files changed, 82 insertions(+), 36 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 2eee408..63b79ca 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -7,6 +7,9 @@ #include #include +#define QLS QLatin1String +#define QLC QLatin1Char + QString BaselineServer::storage; BaselineServer::BaselineServer(QObject *parent) @@ -24,7 +27,7 @@ QString BaselineServer::storagePath() if (storage.isEmpty()) { QDir dir(QCoreApplication::applicationDirPath()); dir.cdUp(); - storage = dir.path() + QLatin1String("/storage/"); + storage = dir.path() + QLS("/storage/"); } return storage; } @@ -73,7 +76,10 @@ void BaselineThread::run() BaselineHandler::BaselineHandler(int socketDescriptor) : QObject(), connectionEstablished(false) { - runId = QDateTime::currentDateTime().toString(QLatin1String("MMMdd-hhmmss")); + runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); + + if (socketDescriptor == -1) + return; connect(&proto.socket, SIGNAL(readyRead()), this, SLOT(receiveRequest())); connect(&proto.socket, SIGNAL(disconnected()), this, SLOT(receiveDisconnect())); @@ -82,7 +88,7 @@ BaselineHandler::BaselineHandler(int socketDescriptor) QString BaselineHandler::logtime() { - return QTime::currentTime().toString(QLatin1String("mm:ss.zzz")); + return QTime::currentTime().toString(QLS("mm:ss.zzz")); } void BaselineHandler::receiveRequest() @@ -132,14 +138,14 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { - if (i->scriptName.startsWith(QLatin1String("porter_duff"))) { + if (i->scriptName.startsWith(QLS("porter_duff"))) { // Example of blacklisting on server. i->status = ImageItem::IgnoreItem; continue; } i->imageChecksums.clear(); QString prefix = pathForItem(*i, true); - QFile file(prefix + QLatin1String("metadata")); + QFile file(prefix + QLS("metadata")); if (file.open(QIODevice::ReadOnly)) { QDataStream checkSums(&file); checkSums >> i->imageChecksums; @@ -170,10 +176,10 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) QDir cwd; if (!cwd.exists(dir)) cwd.mkpath(dir); - item.image.save(prefix + QLatin1String(FileFormat), FileFormat); + item.image.save(prefix + QLS(FileFormat), FileFormat); //# Could use QSettings or XML or even DB, could use common file for whole dir or even whole storage - but for now, keep it simple - QFile file(prefix + QLatin1String("metadata")); + QFile file(prefix + QLS("metadata")); file.open(QIODevice::WriteOnly | QIODevice::Truncate); QDataStream checkSums(&file); checkSums << item.imageChecksums; @@ -198,33 +204,70 @@ void BaselineHandler::receiveDisconnect() QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) { if (pathForRun.isNull()) { - QString host = plat.hostname; - if (host == QLatin1String("localhost")) + QString host = plat.hostname.section(QLC('.'), 0, 0); // Filter away domain, if any + if (host.isEmpty() || host == QLS("localhost")) { host = proto.socket.peerAddress().toString(); - else - host.replace(QRegExp(QLatin1String("^(bq|oslo)-(.*)-\\d\\d$")), QLatin1String("vm-\\2")); - pathForRun = BaselineServer::storagePath() + host + QLatin1Char('/'); + if (host.isEmpty()) + host = QLS("Unknown"); + } else { + host.replace(QRegExp(QLS("^(bq|oslo?)-(.*)$")), QLS("\\2")); + host.replace(QRegExp(QLS("^(.*)-\\d+$")), QLS("vm-\\1")); + } + pathForRun = BaselineServer::storagePath() + host + QLC('/'); } QString storePath = pathForRun; if (isBaseline) - storePath += QString(QLatin1String("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); + storePath += QString(QLS("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); else - storePath += QString(QLatin1String("mismatches_%1_%2/")).arg(item.engineAsString(), item.formatAsString()) + runId + QLatin1Char('/'); + storePath += QString(QLS("mismatches_%1_%2/")).arg(item.engineAsString(), item.formatAsString()) + runId + QLC('/'); QString itemName = item.scriptName; - if (itemName.contains(QLatin1Char('.'))) - itemName.replace(itemName.lastIndexOf(QLatin1Char('.')), 1, QLatin1Char('_')); + if (itemName.contains(QLC('.'))) + itemName.replace(itemName.lastIndexOf(QLC('.')), 1, QLC('_')); + + return storePath + itemName + QLC('.'); +} - return storePath + itemName + QLatin1Char('.'); + +void BaselineHandler::testPathMapping() +{ + qDebug() << "Storeage prefix:" << BaselineServer::storagePath(); + + QStringList hosts; + hosts << QLS("bq-ubuntu910-x86-01") + << QLS("bq-ubuntu910-x86-15") + << QLS("osl-mac-master-5.test.qt.nokia.com") + << QLS("osl-mac-master-6.test.qt.nokia.com") + << QLS("sv-xp-vs-010") + << QLS("sv-xp-vs-011") + << QLS("chimera") + << QLS("localhost"); + + ImageItem item; + item.scriptName = QLS("arcs.qps"); + item.engine = ImageItem::Raster; + item.renderFormat = QImage::Format_ARGB32_Premultiplied; + item.imageChecksums << 0x0123456789abcdefULL; + item.scriptChecksum = 0x0123; + + plat.qtVersion = QLS("4.8.0"); + plat.buildKey = QLS("(nobuildkey)"); + foreach(const QString& host, hosts) { + pathForRun = QString(); + plat.hostname = host; + qDebug() << "Baseline from" << host << "->" << pathForItem(item, true).remove(BaselineServer::storagePath()); + qDebug() << "Mismatch from" << host << "->" << pathForItem(item, false).remove(BaselineServer::storagePath()); + } } + QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QImage &rendered) { if (baseline.size() != rendered.size() || baseline.format() != rendered.format()) - return QLatin1String("[No score, incomparable images.]"); + return QLS("[No score, incomparable images.]"); if (baseline.depth() != 32) - return QLatin1String("[Score computation not implemented for format.]"); + return QLS("[Score computation not implemented for format.]"); int w = baseline.width(); int h = baseline.height(); @@ -260,11 +303,11 @@ QString BaselineHandler::computeMismatchScore(const QImage &baseline, const QIma double pcd = 100.0 * ncd / (w*h); // percent of pixels that differ double acd = ncd ? double(scd) / (3*ncd) : 0; // avg. difference - QString res = QString(QLatin1String("Diffscore: %1% (Num:%2 Avg:%3)")).arg(pcd, 0, 'g', 2).arg(ncd).arg(acd, 0, 'g', 2); + QString res = QString(QLS("Diffscore: %1% (Num:%2 Avg:%3)")).arg(pcd, 0, 'g', 2).arg(ncd).arg(acd, 0, 'g', 2); if (baseline.hasAlphaChannel()) { double pad = 100.0 * nad / (w*h); // percent of pixels that differ double aad = nad ? double(sad) / (3*nad) : 0; // avg. difference - res += QString(QLatin1String(" Alpha-diffscore: %1% (Num:%2 Avg:%3)")).arg(pad, 0, 'g', 2).arg(nad).arg(aad, 0, 'g', 2); + res += QString(QLS(" Alpha-diffscore: %1% (Num:%2 Avg:%3)")).arg(pad, 0, 'g', 2).arg(nad).arg(aad, 0, 'g', 2); } return res; } diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 683d2fd..a4b46f6 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -54,7 +54,8 @@ class BaselineHandler : public QObject Q_OBJECT public: - BaselineHandler(int socketDescriptor); + BaselineHandler(int socketDescriptor = -1); + void testPathMapping(); private slots: void receiveRequest(); diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp index 46048db..a69a5a2 100644 --- a/tests/arthur/baselineserver/src/main.cpp +++ b/tests/arthur/baselineserver/src/main.cpp @@ -1,10 +1,17 @@ #include #include "baselineserver.h" + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); + if (a.arguments().contains(QLatin1String("-testmapping"))) { + BaselineHandler h; + h.testPathMapping(); + return 0; + } + BaselineServer server; if (!server.listen(QHostAddress::Any, BaselineProtocol::ServerPort)) { qWarning("Failed to listen!"); diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 01ae67a..697ce58 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -3,7 +3,6 @@ #include #include #include -#include PlatformInfo::PlatformInfo(bool useLocal) { @@ -146,17 +145,10 @@ bool BaselineProtocol::connect() if (serverName.isNull()) serverName = "chimera.europe.nokia.com"; - for (int i = 0; i < 2; i++) { - socket.connectToHost(serverName, ServerPort); - if (!socket.waitForConnected(Timeout)) { - if (!i && socket.error() == QAbstractSocket::ConnectionRefusedError) { - QTest::qSleep(3000); // In case the server is just restarting, we try again - continue; - } - errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); - return false; - } - break; + socket.connectToHost(serverName, ServerPort); + if (!socket.waitForConnected(Timeout)) { + errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); + return false; } PlatformInfo pi(true); diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 40fe7f2..2b1329f 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -104,8 +104,11 @@ void tst_Lancelot::initTestCase() QSKIP("This test is not supported on this platform.", SkipAll); #endif if (!proto.connect()) { - QWARN(qPrintable(proto.errorMessage())); - QSKIP("Communication with baseline image server failed.", SkipAll); + QTest::qSleep(3000); // Wait a bit and try again, the server might just be restarting + if (!proto.connect()) { + QWARN(qPrintable(proto.errorMessage())); + QSKIP("Communication with baseline image server failed.", SkipAll); + } } QDir qpsDir(scriptsDir); -- cgit v0.12 From 1ac37675969d31fb508d9f46f2e39b0e2b68dc20 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 13 Sep 2010 14:05:31 +0200 Subject: Checksumming of the script files added. If the scripts themselves are modfied, it will not cause mismatch. --- tests/arthur/baselineserver/src/baselineserver.cpp | 4 +++- tests/auto/lancelot/tst_lancelot.cpp | 28 ++++++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 63b79ca..d58313f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -225,6 +225,8 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) QString itemName = item.scriptName; if (itemName.contains(QLC('.'))) itemName.replace(itemName.lastIndexOf(QLC('.')), 1, QLC('_')); + itemName.append(QLC('_')); + itemName.append(QString::number(item.scriptChecksum, 16).rightJustified(4, QLC('0'))); return storePath + itemName + QLC('.'); } @@ -232,7 +234,7 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) void BaselineHandler::testPathMapping() { - qDebug() << "Storeage prefix:" << BaselineServer::storagePath(); + qDebug() << "Storage prefix:" << BaselineServer::storagePath(); QStringList hosts; hosts << QLS("bq-ubuntu910-x86-01") diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 2b1329f..5ec1667 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -68,12 +69,12 @@ public: private: ImageItem render(const ImageItem &item); void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); - QStringList loadScriptFile(const QString &filePath); void runTestSuite(); bool setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist); BaselineProtocol proto; ImageItemList baseList; + QHash scripts; private slots: void initTestCase(); @@ -120,9 +121,13 @@ void tst_Lancelot::initTestCase() baseList.resize(files.count()); ImageItemList::iterator it = baseList.begin(); - foreach(const QString& file, files) { - it->scriptName = file; - // tbd: also load, split and generate checksums for scripts + foreach(const QString& fileName, files) { + QFile file(scriptsDir + fileName); + file.open(QFile::ReadOnly); + QByteArray cont = file.readAll(); + scripts.insert(fileName, QString::fromLatin1(cont).split(QLatin1Char('\n'), QString::SkipEmptyParts)); + it->scriptName = fileName; + it->scriptChecksum = qChecksum(cont.constData(), cont.size()); it++; } } @@ -255,9 +260,7 @@ ImageItem tst_Lancelot::render(const ImageItem &item) res.imageChecksums.clear(); res.image = QImage(); QString filePath = scriptsDir + item.scriptName; - QStringList script = loadScriptFile(filePath); - if (script.isEmpty()) - return res; + QStringList script = scripts.value(item.scriptName); if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); @@ -291,16 +294,5 @@ void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const p.end(); } -QStringList tst_Lancelot::loadScriptFile(const QString &filePath) -{ - QFile file(filePath); - if (!file.open(QFile::ReadOnly)) { - return QStringList(); - } - //# use the new readscript function instead? - QTextStream stream(&file); - return stream.readAll().split(QLatin1Char('\n'), QString::SkipEmptyParts); -} - QTEST_MAIN(tst_Lancelot) #include "tst_lancelot.moc" -- cgit v0.12 From 43a3763e392f05e758085c6b06a5001d9b51aafb Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 16 Sep 2010 15:33:57 +0200 Subject: Server generation of HTML mismatch reports added --- tests/arthur/baselineserver/src/baselineserver.cpp | 33 ++++--- tests/arthur/baselineserver/src/baselineserver.h | 7 +- tests/arthur/baselineserver/src/baselineserver.pro | 6 +- tests/arthur/baselineserver/src/htmlpage.cpp | 110 +++++++++++++++++++++ tests/arthur/baselineserver/src/htmlpage.h | 34 +++++++ tests/arthur/common/baselineprotocol.h | 3 + 6 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 tests/arthur/baselineserver/src/htmlpage.cpp create mode 100644 tests/arthur/baselineserver/src/htmlpage.h diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index d58313f..c25bfc4 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -7,9 +7,6 @@ #include #include -#define QLS QLatin1String -#define QLC QLatin1Char - QString BaselineServer::storage; BaselineServer::BaselineServer(QObject *parent) @@ -160,6 +157,7 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) QDataStream ods(&block, QIODevice::WriteOnly); ods << itemList; proto.sendBlock(BaselineProtocol::Ack, block); + report.start(BaselineServer::storagePath(), runId, plat); } @@ -172,7 +170,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) QString prefix = pathForItem(item, isBaseline); qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.scriptName << "Storing in" << prefix; - QString dir = prefix.section(QDir::separator(), 0, -2); + QString dir = prefix.section(QLC('/'), 0, -2); QDir cwd; if (!cwd.exists(dir)) cwd.mkpath(dir); @@ -185,11 +183,21 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) checkSums << item.imageChecksums; file.close(); - QByteArray msg(isBaseline ? "Baseline" : "Mismatching" ); - msg += " image stored in " - + QHostInfo::localHostName().toLatin1() + '.' - + QHostInfo::localDomainName().toLatin1() + ':' - + prefix.toLatin1() + FileFormat; + if (!isBaseline) + report.addItem(pathForItem(item, true, false) + QLS(FileFormat), + pathForItem(item, false, false) + QLS(FileFormat), + item); + + QByteArray msg(isBaseline ? "New baseline image stored: " : + "Mismatch report: " ); + msg += "http://" + + QHostInfo::localHostName().toLatin1() + '.' + + QHostInfo::localDomainName().toLatin1() + '/'; + if (isBaseline) + msg += pathForItem(item, true, false).toLatin1() + FileFormat; + else + msg += report.filePath(); + proto.sendBlock(BaselineProtocol::Ack, msg); } @@ -197,11 +205,12 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) void BaselineHandler::receiveDisconnect() { qDebug() << runId << logtime() << "Client disconnected."; + report.end(); QThread::currentThread()->exit(0); } -QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) +QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) { if (pathForRun.isNull()) { QString host = plat.hostname.section(QLC('.'), 0, 0); // Filter away domain, if any @@ -213,7 +222,7 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) host.replace(QRegExp(QLS("^(bq|oslo?)-(.*)$")), QLS("\\2")); host.replace(QRegExp(QLS("^(.*)-\\d+$")), QLS("vm-\\1")); } - pathForRun = BaselineServer::storagePath() + host + QLC('/'); + pathForRun = host + QLC('/'); } QString storePath = pathForRun; @@ -228,6 +237,8 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) itemName.append(QLC('_')); itemName.append(QString::number(item.scriptChecksum, 16).rightJustified(4, QLC('0'))); + if (absolute) + storePath.prepend(BaselineServer::storagePath()); return storePath + itemName + QLC('.'); } diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index a4b46f6..8d791e0 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -5,11 +5,13 @@ #include #include #include -#include "baselineprotocol.h" #include #include #include +#include "baselineprotocol.h" +#include "htmlpage.h" + // #seconds between update checks #define HEARTBEAT 5 @@ -64,7 +66,7 @@ private slots: private: void provideBaselineChecksums(const QByteArray &itemListBlock); void storeImage(const QByteArray &itemBlock, bool isBaseline); - QString pathForItem(const ImageItem &item, bool isBaseline = true); + QString pathForItem(const ImageItem &item, bool isBaseline = true, bool absolute = true); QString logtime(); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); QString engineForItem(const ImageItem &item); @@ -74,6 +76,7 @@ private: bool connectionEstablished; QString runId; QString pathForRun; + HTMLPage report; }; #endif // BASELINESERVER_H diff --git a/tests/arthur/baselineserver/src/baselineserver.pro b/tests/arthur/baselineserver/src/baselineserver.pro index 2065d4a..a7be03d 100644 --- a/tests/arthur/baselineserver/src/baselineserver.pro +++ b/tests/arthur/baselineserver/src/baselineserver.pro @@ -19,7 +19,9 @@ TEMPLATE = app include(../../common/baselineprotocol.pri) SOURCES += main.cpp \ - baselineserver.cpp + baselineserver.cpp \ + htmlpage.cpp HEADERS += \ - baselineserver.h + baselineserver.h \ + htmlpage.h diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp new file mode 100644 index 0000000..3ff138f --- /dev/null +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -0,0 +1,110 @@ +#include "htmlpage.h" +#include "baselineprotocol.h" +#include +#include + +HTMLPage::HTMLPage() + : headerWritten(false) +{ +} + +HTMLPage::~HTMLPage() +{ + end(); +} + +QString HTMLPage::filePath() +{ + return path; +} + +void HTMLPage::start(const QString &storagepath, const QString &runId, const PlatformInfo pinfo) +{ + end(); + + id = runId; + plat = pinfo; + root = storagepath; + QString dir = root + QLS("reports/"); + QDir cwd; + if (!cwd.exists(dir)) + cwd.mkpath(dir); +} + + +void HTMLPage::writeHeader(const ImageItem &item) +{ + path = QLS("reports/") + id + QLC('_') + item.engineAsString() + + QLC('_') + item.formatAsString() + QLS(".html"); + file.setFileName(root + path); + if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) + qWarning() << "Failed to open report file" << file.fileName(); + out.setDevice(&file); + + out << "

Lancelot results from run " << id << "

\n\n"; + out << "

Host: " << plat.hostname << "

\n"; + out << "

Qt version: " << plat.qtVersion << "

\n"; + out << "

Build key: " << plat.buildKey << "

\n"; + out << "

Engine: " << item.engineAsString() << "

\n"; + out << "

Format: " << item.formatAsString() << "

\n\n"; + out << "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n\n"; +} + + +void HTMLPage::writeFooter() +{ + out << "
ScriptBaselineRenderedComparisonFuzzy ComparisonScore
\n\n"; +} + + +void HTMLPage::addItem(const QString &baseline, const QString &rendered, const ImageItem &item) +{ + if (!headerWritten) { + writeHeader(item); + headerWritten = true; + } + QString compared = generateCompared(baseline, rendered); + QString fuzzy = generateCompared(baseline, rendered, true); + + out << "\n"; + out << "" << item.scriptName << "\n"; + QStringList images = QStringList() << baseline << rendered << compared << fuzzy; + foreach(const QString& img, images) + out << "\n"; + out << "\n\n"; +} + + +void HTMLPage::end() +{ + if (file.isOpen()) { + writeFooter(); + out.flush(); + file.close(); + path.clear(); + headerWritten = false; + } +} + + +QString HTMLPage::generateCompared(const QString &baseline, const QString &rendered, bool fuzzy) +{ + QString res = rendered; + QFileInfo fi(res); + res.chop(fi.suffix().length() + 1); + res += QLS(fuzzy ? "_fuzzycompared.png" : "_compared.png"); + QStringList args; + if (fuzzy) + args << QLS("-fuzz") << QLS("5%"); + args << root+baseline << root+rendered << root+res; + QProcess::execute(QLS("compare"), args); + return res; +} diff --git a/tests/arthur/baselineserver/src/htmlpage.h b/tests/arthur/baselineserver/src/htmlpage.h new file mode 100644 index 0000000..af0e364 --- /dev/null +++ b/tests/arthur/baselineserver/src/htmlpage.h @@ -0,0 +1,34 @@ +#ifndef HTMLPAGE_H +#define HTMLPAGE_H + +#include "baselineprotocol.h" +#include +#include + +class HTMLPage +{ +public: + HTMLPage(); + ~HTMLPage(); + + void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo); + void addItem(const QString &baseline, const QString &rendered, const ImageItem &item); + void end(); + + QString filePath(); + +private: + void writeHeader(const ImageItem &item); + void writeFooter(); + QString generateCompared(const QString &baseline, const QString &rendered, bool fuzzy = false); + + QString root; + QString path; + QFile file; + QTextStream out; + QString id; + PlatformInfo plat; + bool headerWritten; +}; + +#endif // HTMLPAGE_H diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 062a99c..6af4f22 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -6,6 +6,9 @@ #include #include +#define QLS QLatin1String +#define QLC QLatin1Char + #define FileFormat "png" struct PlatformInfo -- cgit v0.12 From a4b69e877850dc4b934f690e3451e586daffb049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 16 Sep 2010 16:30:07 +0200 Subject: Added support for turning off text drawing. Text drawing is the one thing that will always differ between different platforms. If we're going to do any x-platform testing of the raster engine we'll have to turn text drawing off.. --- tests/arthur/common/paintcommands.cpp | 2 ++ tests/arthur/common/paintcommands.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index 1d7b810..a86b30a 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -1378,6 +1378,8 @@ void PaintCommands::command_qt3_drawArc(QRegExp re) /***************************************************************************************************/ void PaintCommands::command_drawText(QRegExp re) { + if (!m_shouldDrawText) + return; QStringList caps = re.capturedTexts(); int x = convertToInt(caps.at(1)); int y = convertToInt(caps.at(2)); diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index 4d966b8..ebd882b 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -90,6 +90,7 @@ public: , m_verboseMode(false) , m_type(WidgetType) , m_checkers_background(true) + , m_shouldDrawText(true) { staticInit(); } public: @@ -115,6 +116,7 @@ public: void setControlPoints(const QVector &points) { staticInit(); m_controlPoints = points; } void setVerboseMode(bool v) { staticInit(); m_verboseMode = v; } void insertAt(int commandIndex, const QStringList &newCommands); + void setShouldDrawText(bool drawText) { m_shouldDrawText = drawText; } // run void runCommands(); @@ -280,6 +282,7 @@ private: bool m_verboseMode; DeviceType m_type; bool m_checkers_background; + bool m_shouldDrawText; QVector m_controlPoints; -- cgit v0.12 From e1bdeb521fa1c53a8039fec77fad80994b394413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 20 Sep 2010 10:52:39 +0200 Subject: This should run on GL ES 2.0 as well. --- tests/auto/lancelot/tst_lancelot.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 5ec1667..d7a675d 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -191,7 +191,9 @@ void tst_Lancelot::testOpenGL() bool ok = false; QGLWidget glWidget; if (glWidget.isValid() && glWidget.format().directRendering() - && (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) { + && ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) + || (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) + { glWidget.makeCurrent(); if (!QByteArray((const char *)glGetString(GL_VERSION)).contains("Mesa")) ok = true; -- cgit v0.12 From 72b1a614748add429f301ea156760fafc01a5128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 30 Sep 2010 17:11:09 +0200 Subject: Added support for updating the baselines via the generated HTML reports. The baselineserver can now run as a CGI binary if it detects that the QUERY_STRING variable is set. Currently it only handles commands for updating the baselines for failed tests. For this to work properly the baselineserver binary needs to have the setuid bit set, so that when it's run as a CGI binary, it will have the proper rights to move files around. The server currently assumes the CGI binary is a link to the baselineserver executable named 'server.cgi' in the configured 'cgi-bin' directory. --- tests/arthur/baselineserver/src/baselineserver.cpp | 70 +++++++++++++++++++++- tests/arthur/baselineserver/src/baselineserver.h | 5 ++ tests/arthur/baselineserver/src/htmlpage.cpp | 36 +++++++++++ tests/arthur/baselineserver/src/htmlpage.h | 3 +- tests/arthur/baselineserver/src/main.cpp | 8 ++- 5 files changed, 117 insertions(+), 5 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index c25bfc4..41e48eb 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -6,6 +6,7 @@ #include #include #include +#include QString BaselineServer::storage; @@ -29,6 +30,13 @@ QString BaselineServer::storagePath() return storage; } +QString BaselineServer::baseUrl() +{ + return QLS("http://") + + QHostInfo::localHostName().toLatin1() + '.' + + QHostInfo::localDomainName().toLatin1() + '/'; +} + void BaselineServer::incomingConnection(int socketDescriptor) { qDebug() << "Server: New connection!"; @@ -190,9 +198,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) QByteArray msg(isBaseline ? "New baseline image stored: " : "Mismatch report: " ); - msg += "http://" - + QHostInfo::localHostName().toLatin1() + '.' - + QHostInfo::localDomainName().toLatin1() + '/'; + msg += BaselineServer::baseUrl(); if (isBaseline) msg += pathForItem(item, true, false).toLatin1() + FileFormat; else @@ -243,6 +249,64 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, boo } +QString BaselineHandler::updateAllBaselines(const QString &host, const QString &id, + const QString &engine, const QString &format) +{ + QString basePath(BaselineServer::storagePath()); + QString srcDir(basePath + host + QLC('/') + + QString(QLS("mismatches_%1_%2/")).arg(engine, format) + + id); + QString dstDir(basePath + host + QLC('/') + + QString(QLS("baselines_%1_%2/")).arg(engine, format)); + + QDir dir(srcDir); + QStringList nameFilter; + nameFilter << "*.metadata" << "*.png"; + QStringList fileList = dir.entryList(nameFilter, QDir::Files | QDir::NoDotAndDotDot); + + // remove the generated _fuzzycompared.png and _compared.png files from the list + QMutableStringListIterator it(fileList); + while (it.hasNext()) { + it.next(); + if (it.value().endsWith(QLS("compared.png"))) + it.remove(); + } + + QString res; + QProcess proc; + proc.setWorkingDirectory(srcDir); + proc.setProcessChannelMode(QProcess::MergedChannels); + proc.start(QLS("cp"), QStringList() << QLS("-f") << fileList << dstDir); + proc.waitForFinished(); + if (proc.exitCode() == 0) + res = QLS("Successfully updated baseline for all failed tests."); + else + res = QString("Error updating baseline: %1
" + "Command output:
%2
").arg(proc.errorString(), proc.readAll().constData()); + + return res; +} + +QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline) +{ + QString res; + QString basePath(BaselineServer::storagePath()); + QString srcBase(basePath + newBaseline.left(newBaseline.length() - 3)); + QString dstDir(basePath + oldBaseline.left(oldBaseline.lastIndexOf(QLC('/')))); + + QProcess proc; + proc.setProcessChannelMode(QProcess::MergedChannels); + proc.start(QLS("cp"), QStringList() << QLS("-f") << srcBase + QLS("png") << srcBase + QLS("metadata") << dstDir); + proc.waitForFinished(); + if (proc.exitCode() == 0) + res = QString("Successfully updated '%1'").arg(oldBaseline + QLS("/metadata")); + else + res = QString("Error updating baseline: %1
" + "Command output:
%2
").arg(proc.errorString(), proc.readAll().constData()); + + return res; +} + void BaselineHandler::testPathMapping() { qDebug() << "Storage prefix:" << BaselineServer::storagePath(); diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 8d791e0..b77bc09 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -23,6 +23,7 @@ public: BaselineServer(QObject *parent = 0); static QString storagePath(); + static QString baseUrl(); protected: void incomingConnection(int socketDescriptor); @@ -59,6 +60,10 @@ public: BaselineHandler(int socketDescriptor = -1); void testPathMapping(); + static QString updateAllBaselines(const QString &host, const QString &id, + const QString &engine, const QString &format); + static QString updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline); + private slots: void receiveRequest(); void receiveDisconnect(); diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 3ff138f..4f53c67 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -1,7 +1,9 @@ #include "htmlpage.h" #include "baselineprotocol.h" +#include "baselineserver.h" #include #include +#include HTMLPage::HTMLPage() : headerWritten(false) @@ -36,6 +38,9 @@ void HTMLPage::writeHeader(const ImageItem &item) { path = QLS("reports/") + id + QLC('_') + item.engineAsString() + QLC('_') + item.formatAsString() + QLS(".html"); + + QString pageUrl = BaselineServer::baseUrl() + path; + file.setFileName(root + path); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) qWarning() << "Failed to open report file" << file.fileName(); @@ -47,6 +52,10 @@ void HTMLPage::writeHeader(const ImageItem &item) out << "

Build key: " << plat.buildKey << "

\n"; out << "

Engine: " << item.engineAsString() << "

\n"; out << "

Format: " << item.formatAsString() << "

\n\n"; + out << "

Update all baselines

\n\n"; out << "\n" "\n" "\n" @@ -55,6 +64,7 @@ void HTMLPage::writeHeader(const ImageItem &item) "\n" "\n" "\n" + "\n" "\n\n"; } @@ -73,12 +83,15 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I } QString compared = generateCompared(baseline, rendered); QString fuzzy = generateCompared(baseline, rendered, true); + QString pageUrl = BaselineServer::baseUrl() + path; out << "\n"; out << "\n"; QStringList images = QStringList() << baseline << rendered << compared << fuzzy; foreach(const QString& img, images) out << "\n"; + out << "\n"; out << "\n\n"; } @@ -108,3 +121,26 @@ QString HTMLPage::generateCompared(const QString &baseline, const QString &rende QProcess::execute(QLS("compare"), args); return res; } + + +void HTMLPage::handleCGIQuery(const QString &query) +{ + QUrl cgiUrl(QLS("http://dummy/cgi-bin/dummy.cgi?") + query); + QTextStream s(stdout); + s << "Content-Type: text/html\r\n\r\n" + << ""; +// << "Contents of QUERY_STRING:
" +// << "Full string = " << query << "
"; + + if (cgiUrl.queryItemValue(QLS("update")) == QLS("single")) { + s << BaselineHandler::updateSingleBaseline(cgiUrl.queryItemValue(QLS("oldBaseline")), + cgiUrl.queryItemValue(QLS("newBaseline"))); + } else { + s << BaselineHandler::updateAllBaselines(cgiUrl.queryItemValue(QLS("host")), + cgiUrl.queryItemValue(QLS("id")), + cgiUrl.queryItemValue(QLS("engine")), + cgiUrl.queryItemValue(QLS("format"))); + } + s << "

Back to report"; + s << ""; +} diff --git a/tests/arthur/baselineserver/src/htmlpage.h b/tests/arthur/baselineserver/src/htmlpage.h index af0e364..29b4ff5 100644 --- a/tests/arthur/baselineserver/src/htmlpage.h +++ b/tests/arthur/baselineserver/src/htmlpage.h @@ -14,9 +14,10 @@ public: void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo); void addItem(const QString &baseline, const QString &rendered, const ImageItem &item); void end(); - QString filePath(); + static void handleCGIQuery(const QString &query); + private: void writeHeader(const ImageItem &item); void writeFooter(); diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp index a69a5a2..0e15a60 100644 --- a/tests/arthur/baselineserver/src/main.cpp +++ b/tests/arthur/baselineserver/src/main.cpp @@ -1,11 +1,17 @@ #include #include "baselineserver.h" - int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); + QString queryString(qgetenv("QUERY_STRING")); + if (!queryString.isEmpty()) { + // run as CGI script + HTMLPage::handleCGIQuery(queryString); + return 0; + } + if (a.arguments().contains(QLatin1String("-testmapping"))) { BaselineHandler h; h.testPathMapping(); -- cgit v0.12 From 52111401594472503ce21096fc720807a9253b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 6 Oct 2010 15:04:31 +0200 Subject: Add support for blacklisting/whitelisting tests on the report page. Also changed how the GL tests are run: they now render into a multisampled FBO, which seems to be more stable than to a plain GL widget. --- tests/arthur/baselineserver/src/baselineserver.cpp | 92 +++++++++++++++++++--- tests/arthur/baselineserver/src/baselineserver.h | 6 ++ tests/arthur/baselineserver/src/htmlpage.cpp | 71 ++++++++++++++--- tests/arthur/baselineserver/src/htmlpage.h | 3 +- tests/auto/lancelot/tst_lancelot.cpp | 20 ++--- 5 files changed, 156 insertions(+), 36 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 41e48eb..072e216 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -143,11 +143,6 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { - if (i->scriptName.startsWith(QLS("porter_duff"))) { - // Example of blacklisting on server. - i->status = ImageItem::IgnoreItem; - continue; - } i->imageChecksums.clear(); QString prefix = pathForItem(*i, true); QFile file(prefix + QLS("metadata")); @@ -161,11 +156,29 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) i->status = ImageItem::BaselineNotFound; } + // Find and mark blacklisted items + if (itemList.count() > 0) { + QString prefix = pathForItem(itemList.at(0), true).section(QLC('/'), 0, -2); + QFile file(prefix + QLS("/.blacklist")); + if (file.open(QIODevice::ReadOnly)) { + QTextStream in(&file); + do { + QString scriptName = in.readLine(); + if (!scriptName.isNull()) { + for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { + if (i->scriptName == scriptName) + i->status = ImageItem::IgnoreItem; + } + } + } while (!in.atEnd()); + } + } + QByteArray block; QDataStream ods(&block, QIODevice::WriteOnly); ods << itemList; proto.sendBlock(BaselineProtocol::Ack, block); - report.start(BaselineServer::storagePath(), runId, plat); + report.start(BaselineServer::storagePath(), runId, plat, itemList); } @@ -216,6 +229,14 @@ void BaselineHandler::receiveDisconnect() } +QString BaselineHandler::itemSubPath(const QString &engine, const QString &format, bool isBaseline) +{ + if (isBaseline) + return QString(QLS("baselines_%1_%2/")).arg(engine, format); + else + return QString(QLS("mismatches_%1_%2/")).arg(engine, format); +} + QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) { if (pathForRun.isNull()) { @@ -233,9 +254,9 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, boo QString storePath = pathForRun; if (isBaseline) - storePath += QString(QLS("baselines_%1_%2/")).arg(item.engineAsString(), item.formatAsString()); + storePath += itemSubPath(item.engineAsString(), item.formatAsString(), isBaseline); else - storePath += QString(QLS("mismatches_%1_%2/")).arg(item.engineAsString(), item.formatAsString()) + runId + QLC('/'); + storePath += itemSubPath(item.engineAsString(), item.formatAsString(), isBaseline) + runId + QLC('/'); QString itemName = item.scriptName; if (itemName.contains(QLC('.'))) @@ -253,11 +274,8 @@ QString BaselineHandler::updateAllBaselines(const QString &host, const QString & const QString &engine, const QString &format) { QString basePath(BaselineServer::storagePath()); - QString srcDir(basePath + host + QLC('/') - + QString(QLS("mismatches_%1_%2/")).arg(engine, format) - + id); - QString dstDir(basePath + host + QLC('/') - + QString(QLS("baselines_%1_%2/")).arg(engine, format)); + QString srcDir(basePath + host + QLC('/') + itemSubPath(engine, format, false) + id); + QString dstDir(basePath + host + QLC('/') + itemSubPath(engine, format)); QDir dir(srcDir); QStringList nameFilter; @@ -307,6 +325,54 @@ QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const return res; } +QString BaselineHandler::blacklistTest(const QString &scriptName, const QString &host, const QString &engine, + const QString &format) +{ + QString configFile(BaselineServer::storagePath() + host + QLC('/') + + itemSubPath(engine, format) + QLS(".blacklist")); + QFile file(configFile); + if (file.open(QIODevice::Append)) { + QTextStream out(&file); + out << scriptName << endl; + return QLS("Blacklisted ") + scriptName; + } else { + return QLS("Unable to update blacklisted tests."); + } +} + +QString BaselineHandler::whitelistTest(const QString &scriptName, const QString &host, const QString &engine, + const QString &format) +{ + QString configFile(BaselineServer::storagePath() + host + QLC('/') + + itemSubPath(engine, format) + QLS(".blacklist")); + QFile file(configFile); + QStringList tests; + if (file.open(QIODevice::ReadOnly)) { + QTextStream in(&file); + do { + tests << in.readLine(); + } while (!in.atEnd()); + if (tests.count() != 0) { + QMutableStringListIterator it(tests); + while (it.hasNext()) { + it.next(); + if (it.value() == scriptName) + it.remove(); + } + } + file.close(); + if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + QTextStream out(&file); + for (int i=0; iBuild key: " << plat.buildKey << "\n"; out << "

Engine: " << item.engineAsString() << "

\n"; out << "

Format: " << item.formatAsString() << "

\n\n"; - out << "

Update all baselines

\n\n"; + << "\">Update all baselines
"; out << "
ScriptComparisonFuzzy ComparisonScoreUpdate
" << item.scriptName << "Update baseline
\n" "\n" "\n" "\n" "\n" "\n" - "\n" - "\n" - "\n" - "\n\n"; + "\n" + "
"; } @@ -82,23 +81,53 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I headerWritten = true; } QString compared = generateCompared(baseline, rendered); - QString fuzzy = generateCompared(baseline, rendered, true); QString pageUrl = BaselineServer::baseUrl() + path; out << "\n"; out << "\n"; - QStringList images = QStringList() << baseline << rendered << compared << fuzzy; + QStringList images = QStringList() << baseline << rendered << compared; foreach(const QString& img, images) out << "\n"; - out << "\n"; + out << "\n"; out << "\n\n"; + + QMutableVectorIterator it(imageItems); + while (it.hasNext()) { + it.next(); + if (it.value().scriptName == item.scriptName) { + it.remove(); + break; + } + } } void HTMLPage::end() { if (file.isOpen()) { + // Add the names of the scripts that passed the test, or were blacklisted + QString pageUrl = BaselineServer::baseUrl() + path; + for (int i=0; i"; + } + writeFooter(); out.flush(); file.close(); @@ -132,14 +161,30 @@ void HTMLPage::handleCGIQuery(const QString &query) // << "Contents of QUERY_STRING:
" // << "Full string = " << query << "
"; - if (cgiUrl.queryItemValue(QLS("update")) == QLS("single")) { + QString command(cgiUrl.queryItemValue("cmd")); + + if (command == QLS("updateSingleBaseline")) { s << BaselineHandler::updateSingleBaseline(cgiUrl.queryItemValue(QLS("oldBaseline")), cgiUrl.queryItemValue(QLS("newBaseline"))); - } else { + } else if (command == QLS("updateAllBaselines")) { s << BaselineHandler::updateAllBaselines(cgiUrl.queryItemValue(QLS("host")), cgiUrl.queryItemValue(QLS("id")), cgiUrl.queryItemValue(QLS("engine")), cgiUrl.queryItemValue(QLS("format"))); + } else if (command == QLS("blacklist")) { + // blacklist a test + s << BaselineHandler::blacklistTest(cgiUrl.queryItemValue(QLS("scriptName")), + cgiUrl.queryItemValue(QLS("host")), + cgiUrl.queryItemValue(QLS("engine")), + cgiUrl.queryItemValue(QLS("format"))); + } else if (command == QLS("whitelist")) { + // whitelist a test + s << BaselineHandler::whitelistTest(cgiUrl.queryItemValue(QLS("scriptName")), + cgiUrl.queryItemValue(QLS("host")), + cgiUrl.queryItemValue(QLS("engine")), + cgiUrl.queryItemValue(QLS("format"))); + } else { + s << "Unknown query:
" << query << "
"; } s << "

Back to report"; s << ""; diff --git a/tests/arthur/baselineserver/src/htmlpage.h b/tests/arthur/baselineserver/src/htmlpage.h index 29b4ff5..a937052 100644 --- a/tests/arthur/baselineserver/src/htmlpage.h +++ b/tests/arthur/baselineserver/src/htmlpage.h @@ -11,7 +11,7 @@ public: HTMLPage(); ~HTMLPage(); - void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo); + void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo, const ImageItemList &itemList); void addItem(const QString &baseline, const QString &rendered, const ImageItem &item); void end(); QString filePath(); @@ -29,6 +29,7 @@ private: QTextStream out; QString id; PlatformInfo plat; + ImageItemList imageItems; bool headerWritten; }; diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index d7a675d..21044d4 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -189,10 +189,11 @@ void tst_Lancelot::testOpenGL_data() void tst_Lancelot::testOpenGL() { bool ok = false; - QGLWidget glWidget; + QGLWidget glWidget; if (glWidget.isValid() && glWidget.format().directRendering() && ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - || (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) + || (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) + && QGLFramebufferObject::hasOpenGLFramebufferObjects()) { glWidget.makeCurrent(); if (!QByteArray((const char *)glGetString(GL_VERSION)).contains("Mesa")) @@ -272,13 +273,13 @@ ImageItem tst_Lancelot::render(const ImageItem &item) } else if (item.engine == ImageItem::OpenGL) { QGLWidget glWidget; if (glWidget.isValid()) { - glWidget.resize(800, 800); - glWidget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&glWidget); -#endif - paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) - res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat); + glWidget.makeCurrent(); + QGLFramebufferObjectFormat fboFormat; + fboFormat.setSamples(16); + fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QGLFramebufferObject fbo(800, 800, fboFormat); + paint(&fbo, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) + res.image = fbo.toImage().convertToFormat(item.renderFormat); res.imageChecksums.append(ImageItem::computeChecksum(res.image)); } } @@ -290,6 +291,7 @@ void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const { QPainter p(device); PaintCommands pcmd(script, 800, 800); + pcmd.setType(ImageType); pcmd.setPainter(&p); pcmd.setFilePath(filePath); pcmd.runCommands(); -- cgit v0.12 From 76e1b6a93a36080e39c3d1e7cb1e754aa0131999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 8 Oct 2010 11:58:16 +0200 Subject: Don't include the arthur/common.pri file. Including the arthur/common.pri file pulls in many files we don't actually need. --- tests/auto/lancelot/lancelot.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/lancelot/lancelot.pro b/tests/auto/lancelot/lancelot.pro index d0138bd..3859a55 100644 --- a/tests/auto/lancelot/lancelot.pro +++ b/tests/auto/lancelot/lancelot.pro @@ -2,9 +2,11 @@ load(qttest_p4) QT += xml svg contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl -SOURCES += tst_lancelot.cpp +SOURCES += tst_lancelot.cpp \ + $$QT_SOURCE_TREE/tests/arthur/common/paintcommands.cpp +HEADERS += $$QT_SOURCE_TREE/tests/arthur/common/paintcommands.h +RESOURCES += $$QT_SOURCE_TREE/tests/arthur/common/images.qrc -include($$QT_SOURCE_TREE/tests/arthur/common/common.pri) include($$QT_SOURCE_TREE/tests/arthur/common/baselineprotocol.pri) !symbian:!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\" -- cgit v0.12 From 5c92ff774eadca40e6f33b5e096df01ecc5da717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 12 Oct 2010 12:54:15 +0200 Subject: Revert "Don't define highp/mediump/lowp if desktop GL has them" This reverts commit 6155050f68cc86c445552da61a5f240c16f5e2cd. The GL_ARB_ES2_compatibility extension does not mention the lowp, mediump or highp keywords. Task-number: QTBUG-14384 Reviewed-by: Samuel Reviewed-by: Prasanth --- dist/changes-4.6.4 | 4 +--- src/opengl/qgl.cpp | 3 --- src/opengl/qgl_p.h | 3 +-- src/opengl/qglshaderprogram.cpp | 10 ++-------- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dist/changes-4.6.4 b/dist/changes-4.6.4 index 389aa3a..3949b9a 100644 --- a/dist/changes-4.6.4 +++ b/dist/changes-4.6.4 @@ -66,8 +66,6 @@ QtOpenGL - QGLShaderProgram * [QTBUG-12478] Don't resolve GLSL extensions if no shaders. * [QTBUG-12591] setUniformValue(QSize) was setting (w,w) not (w,h). - * [QTBUG-12862] Don't #define highp/mediump/lowp if the desktop OpenGL - implementation has the GL_ARB_ES2_compatibility extension. * [QTBUG-12554] Wrong OpenGLVersionFlags on OpenGL 4.0 systems. QtScript @@ -109,7 +107,7 @@ Third party components Qt for Unix (X11 and Mac OS X) ------------------------------ - - + - Qt for Linux/X11 ---------------- diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index cb31491..c4d2bd5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5325,8 +5325,6 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= FragmentShader; if (extensions.match("GL_ARB_shader_objects")) glExtensions |= FragmentShader; - if (extensions.match("GL_ARB_ES2_compatibility")) - glExtensions |= ES2Compatibility; if (extensions.match("GL_ARB_texture_mirrored_repeat")) glExtensions |= MirroredRepeat; if (extensions.match("GL_EXT_framebuffer_object")) @@ -5347,7 +5345,6 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= FramebufferObject; glExtensions |= GenerateMipmap; glExtensions |= FragmentShader; - glExtensions |= ES2Compatibility; #endif #if defined(QT_OPENGL_ES_1) if (extensions.match("GL_OES_framebuffer_object")) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 78f888a..f86a848 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -282,8 +282,7 @@ public: DDSTextureCompression = 0x00008000, ETC1TextureCompression = 0x00010000, PVRTCTextureCompression = 0x00020000, - FragmentShader = 0x00040000, - ES2Compatibility = 0x00080000 + FragmentShader = 0x00040000 }; Q_DECLARE_FLAGS(Extensions, Extension) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index bc1c009..74382b0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -97,10 +97,6 @@ QT_BEGIN_NAMESPACE to just features that are present in GLSL/ES, and avoid standard variable names that only work on the desktop. - If the \c{GL_ARB_ES2_compatibility} extension is present, - then the above prefix is not added because the desktop OpenGL - implementation supports precision qualifiers. - \section1 Simple shader example \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1 @@ -398,10 +394,8 @@ bool QGLShader::compileSourceCode(const char *source) srclen.append(GLint(headerLen)); } #ifdef QGL_DEFINE_QUALIFIERS - if (!(QGLExtensions::glExtensions() & QGLExtensions::ES2Compatibility)) { - src.append(qualifierDefines); - srclen.append(GLint(sizeof(qualifierDefines) - 1)); - } + src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP if (d->shaderType == Fragment) { -- cgit v0.12 From e7f0288bd9a57c25a7e482f4b058769d7147270a Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 18 Oct 2010 15:37:59 +0200 Subject: Add OS and git data to PlatformInfo --- tests/arthur/baselineserver/src/baselineserver.cpp | 26 ++++++++------- tests/arthur/baselineserver/src/htmlpage.cpp | 8 ++--- tests/arthur/common/baselineprotocol.cpp | 38 +++++++++++++++++++--- tests/arthur/common/baselineprotocol.h | 11 ++++--- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 072e216..86554fd 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -105,8 +105,10 @@ void BaselineHandler::receiveRequest() return; } connectionEstablished = true; - qDebug() << runId << logtime() << "Connection established with" << plat.hostname << proto.socket.peerAddress().toString() << "Qt version:" << plat.qtVersion << plat.buildKey; - return; + qDebug() << runId << logtime() << "Connection established with" << plat.hostName << "[" << proto.socket.peerAddress().toString() << "]" + << "OS:" << plat.osName << "[" << plat.osVersion << "]" << "Qt version:" << plat.qtVersion << "[" << plat.buildKey << "]" + << "git commit:" << plat.gitCommit; + return; } QByteArray block; @@ -140,7 +142,7 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) QDataStream ds(itemListBlock); ds >> itemList; qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items, engine" - << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); + << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { i->imageChecksums.clear(); @@ -240,7 +242,7 @@ QString BaselineHandler::itemSubPath(const QString &engine, const QString &forma QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) { if (pathForRun.isNull()) { - QString host = plat.hostname.section(QLC('.'), 0, 0); // Filter away domain, if any + QString host = plat.hostName.section(QLC('.'), 0, 0); // Filter away domain, if any if (host.isEmpty() || host == QLS("localhost")) { host = proto.socket.peerAddress().toString(); if (host.isEmpty()) @@ -379,13 +381,13 @@ void BaselineHandler::testPathMapping() QStringList hosts; hosts << QLS("bq-ubuntu910-x86-01") - << QLS("bq-ubuntu910-x86-15") - << QLS("osl-mac-master-5.test.qt.nokia.com") - << QLS("osl-mac-master-6.test.qt.nokia.com") - << QLS("sv-xp-vs-010") - << QLS("sv-xp-vs-011") - << QLS("chimera") - << QLS("localhost"); + << QLS("bq-ubuntu910-x86-15") + << QLS("osl-mac-master-5.test.qt.nokia.com") + << QLS("osl-mac-master-6.test.qt.nokia.com") + << QLS("sv-xp-vs-010") + << QLS("sv-xp-vs-011") + << QLS("chimera") + << QLS("localhost"); ImageItem item; item.scriptName = QLS("arcs.qps"); @@ -398,7 +400,7 @@ void BaselineHandler::testPathMapping() plat.buildKey = QLS("(nobuildkey)"); foreach(const QString& host, hosts) { pathForRun = QString(); - plat.hostname = host; + plat.hostName = host; qDebug() << "Baseline from" << host << "->" << pathForItem(item, true).remove(BaselineServer::storagePath()); qDebug() << "Mismatch from" << host << "->" << pathForItem(item, false).remove(BaselineServer::storagePath()); } diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 7759c8e..14bcb0c 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -48,12 +48,12 @@ void HTMLPage::writeHeader(const ImageItem &item) out.setDevice(&file); out << "

Lancelot results from run " << id << "

\n\n"; - out << "

Host: " << plat.hostname << "

\n"; + out << "

Host: " << plat.hostName << "

\n"; out << "

Qt version: " << plat.qtVersion << "

\n"; out << "

Build key: " << plat.buildKey << "

\n"; out << "

Engine: " << item.engineAsString() << "

\n"; out << "

Format: " << item.formatAsString() << "

\n\n"; - out << "

Update all baselines
"; @@ -91,7 +91,7 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I out << "

\n"; out << "\n\n"; @@ -117,7 +117,7 @@ void HTMLPage::end() if (imageItems.at(i).status == ImageItem::IgnoreItem) { out << "Blacklisted
" "> (QDataStream& stream, PlatformInfo& pinfo) +QDataStream & operator>> (QDataStream& stream, PlatformInfo& p) { - stream >> pinfo.buildKey >> pinfo.qtVersion >> pinfo.hostname; + stream >> p.hostName >> p.osName >> p.osVersion >> p.qtVersion >> p.buildKey >> p.gitCommit; return stream; } diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 6af4f22..42f9729 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -15,12 +15,15 @@ struct PlatformInfo { PlatformInfo(bool useLocal = false); - QString buildKey; + QString hostName; + QString osName; + int osVersion; QString qtVersion; - QString hostname; + QString buildKey; + QString gitCommit; }; -QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pinfo); -QDataStream & operator>> (QDataStream& stream, PlatformInfo& pinfo); +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &p); +QDataStream & operator>> (QDataStream& stream, PlatformInfo& p); struct ImageItem { -- cgit v0.12 From 3f0ff810e448253e6da0c4716e6ed1819786349f Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 25 Oct 2010 13:04:44 +0200 Subject: Preparations for running on actual server --- tests/arthur/baselineserver/src/baselineserver.cpp | 11 ++++++++--- tests/arthur/common/baselineprotocol.cpp | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 86554fd..bef6e41 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -23,9 +23,14 @@ BaselineServer::BaselineServer(QObject *parent) QString BaselineServer::storagePath() { if (storage.isEmpty()) { - QDir dir(QCoreApplication::applicationDirPath()); - dir.cdUp(); - storage = dir.path() + QLS("/storage/"); + QByteArray envDir = qgetenv("QT_LANCELOT_DIR"); + if (!envDir.isEmpty()) { + storage = QLS(envDir.append('/')); + } else { + QDir dir(QCoreApplication::applicationDirPath()); + dir.cdUp(); + storage = dir.path() + QLS("/storage/"); + } } return storage; } diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 78c80f1..a7fb5be 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -168,10 +168,9 @@ BaselineProtocol::~BaselineProtocol() bool BaselineProtocol::connect() { errMsg.clear(); - //###TBD: determine server address; for now local devhost QByteArray serverName(qgetenv("QT_LANCELOT_SERVER")); if (serverName.isNull()) - serverName = "chimera.europe.nokia.com"; + serverName = "lancelot.test.qt.nokia.com"; socket.connectToHost(serverName, ServerPort); if (!socket.waitForConnected(Timeout)) { -- cgit v0.12 From 8188942adf7745923d058cdad025af2054b8e5c8 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 25 Oct 2010 15:51:33 +0200 Subject: Another change for running on actual server --- tests/arthur/baselineserver/src/baselineserver.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index bef6e41..1e241c1 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -24,13 +24,10 @@ QString BaselineServer::storagePath() { if (storage.isEmpty()) { QByteArray envDir = qgetenv("QT_LANCELOT_DIR"); - if (!envDir.isEmpty()) { + if (!envDir.isEmpty()) storage = QLS(envDir.append('/')); - } else { - QDir dir(QCoreApplication::applicationDirPath()); - dir.cdUp(); - storage = dir.path() + QLS("/storage/"); - } + else + storage = QLS("/var/www/"); } return storage; } -- cgit v0.12 From 0a2309a401184dfd4adb3e941d390fe7a625806c Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 25 Oct 2010 16:20:12 +0200 Subject: Testing auto-rebuild on server --- tests/arthur/baselineserver/src/baselineserver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index ba71ce5..95f40de 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -13,7 +13,7 @@ #include "htmlpage.h" // #seconds between update checks -#define HEARTBEAT 5 +#define HEARTBEAT 10 class BaselineServer : public QTcpServer { -- cgit v0.12 From 499b864a4bebb3176ba44141714e18687e9000bd Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 26 Oct 2010 12:38:56 +0200 Subject: Remove historic remains of qt3 testing --- tests/auto/lancelot/scripts/sizes.qps | 122 +++++++++++++++++----------------- tests/auto/lancelot/tst_lancelot.cpp | 11 ++- 2 files changed, 65 insertions(+), 68 deletions(-) diff --git a/tests/auto/lancelot/scripts/sizes.qps b/tests/auto/lancelot/scripts/sizes.qps index b923881..268808e 100644 --- a/tests/auto/lancelot/scripts/sizes.qps +++ b/tests/auto/lancelot/scripts/sizes.qps @@ -17,16 +17,16 @@ drawRect 120 0 16 16 drawRect 140 0 17 17 drawRect 160 0 18 18 drawRect 180 0 19 19 -qt3_drawRect 200 0 10 10 -qt3_drawRect 220 0 11 11 -qt3_drawRect 240 0 12 12 -qt3_drawRect 260 0 13 13 -qt3_drawRect 280 0 14 14 -qt3_drawRect 300 0 15 15 -qt3_drawRect 320 0 16 16 -qt3_drawRect 340 0 17 17 -qt3_drawRect 360 0 18 18 -qt3_drawRect 380 0 19 19 +# qt3_drawRect 200 0 10 10 +# qt3_drawRect 220 0 11 11 +# qt3_drawRect 240 0 12 12 +# qt3_drawRect 260 0 13 13 +# qt3_drawRect 280 0 14 14 +# qt3_drawRect 300 0 15 15 +# qt3_drawRect 320 0 16 16 +# qt3_drawRect 340 0 17 17 +# qt3_drawRect 360 0 18 18 +# qt3_drawRect 380 0 19 19 drawEllipse 0 20 10 10 drawEllipse 20 20 11 11 @@ -38,16 +38,16 @@ drawEllipse 120 20 16 16 drawEllipse 140 20 17 17 drawEllipse 160 20 18 18 drawEllipse 180 20 19 19 -qt3_drawEllipse 200 20 10 10 -qt3_drawEllipse 220 20 11 11 -qt3_drawEllipse 240 20 12 12 -qt3_drawEllipse 260 20 13 13 -qt3_drawEllipse 280 20 14 14 -qt3_drawEllipse 300 20 15 15 -qt3_drawEllipse 320 20 16 16 -qt3_drawEllipse 340 20 17 17 -qt3_drawEllipse 360 20 18 18 -qt3_drawEllipse 380 20 19 19 +# qt3_drawEllipse 200 20 10 10 +# qt3_drawEllipse 220 20 11 11 +# qt3_drawEllipse 240 20 12 12 +# qt3_drawEllipse 260 20 13 13 +# qt3_drawEllipse 280 20 14 14 +# qt3_drawEllipse 300 20 15 15 +# qt3_drawEllipse 320 20 16 16 +# qt3_drawEllipse 340 20 17 17 +# qt3_drawEllipse 360 20 18 18 +# qt3_drawEllipse 380 20 19 19 drawRoundRect 0 40 10 10 drawRoundRect 20 40 11 11 @@ -59,16 +59,16 @@ drawRoundRect 120 40 16 16 drawRoundRect 140 40 17 17 drawRoundRect 160 40 18 18 drawRoundRect 180 40 19 19 -qt3_drawRoundRect 200 40 10 10 -qt3_drawRoundRect 220 40 11 11 -qt3_drawRoundRect 240 40 12 12 -qt3_drawRoundRect 260 40 13 13 -qt3_drawRoundRect 280 40 14 14 -qt3_drawRoundRect 300 40 15 15 -qt3_drawRoundRect 320 40 16 16 -qt3_drawRoundRect 340 40 17 17 -qt3_drawRoundRect 360 40 18 18 -qt3_drawRoundRect 380 40 19 19 +# qt3_drawRoundRect 200 40 10 10 +# qt3_drawRoundRect 220 40 11 11 +# qt3_drawRoundRect 240 40 12 12 +# qt3_drawRoundRect 260 40 13 13 +# qt3_drawRoundRect 280 40 14 14 +# qt3_drawRoundRect 300 40 15 15 +# qt3_drawRoundRect 320 40 16 16 +# qt3_drawRoundRect 340 40 17 17 +# qt3_drawRoundRect 360 40 18 18 +# qt3_drawRoundRect 380 40 19 19 drawPie 0 60 10 10 0 4320 drawPie 20 60 11 11 0 4320 @@ -80,16 +80,16 @@ drawPie 120 60 16 16 0 4320 drawPie 140 60 17 17 0 4320 drawPie 160 60 18 18 0 4320 drawPie 180 60 19 19 0 4320 -qt3_drawPie 200 60 10 10 0 4320 -qt3_drawPie 220 60 11 11 0 4320 -qt3_drawPie 240 60 12 12 0 4320 -qt3_drawPie 260 60 13 13 0 4320 -qt3_drawPie 280 60 14 14 0 4320 -qt3_drawPie 300 60 15 15 0 4320 -qt3_drawPie 320 60 16 16 0 4320 -qt3_drawPie 340 60 17 17 0 4320 -qt3_drawPie 360 60 18 18 0 4320 -qt3_drawPie 380 60 19 19 0 4320 +# qt3_drawPie 200 60 10 10 0 4320 +# qt3_drawPie 220 60 11 11 0 4320 +# qt3_drawPie 240 60 12 12 0 4320 +# qt3_drawPie 260 60 13 13 0 4320 +# qt3_drawPie 280 60 14 14 0 4320 +# qt3_drawPie 300 60 15 15 0 4320 +# qt3_drawPie 320 60 16 16 0 4320 +# qt3_drawPie 340 60 17 17 0 4320 +# qt3_drawPie 360 60 18 18 0 4320 +# qt3_drawPie 380 60 19 19 0 4320 drawArc 0 80 10 10 0 4320 drawArc 20 80 11 11 0 4320 @@ -101,16 +101,16 @@ drawArc 120 80 16 16 0 4320 drawArc 140 80 17 17 0 4320 drawArc 160 80 18 18 0 4320 drawArc 180 80 19 19 0 4320 -qt3_drawArc 200 80 10 10 0 4320 -qt3_drawArc 220 80 11 11 0 4320 -qt3_drawArc 240 80 12 12 0 4320 -qt3_drawArc 260 80 13 13 0 4320 -qt3_drawArc 280 80 14 14 0 4320 -qt3_drawArc 300 80 15 15 0 4320 -qt3_drawArc 320 80 16 16 0 4320 -qt3_drawArc 340 80 17 17 0 4320 -qt3_drawArc 360 80 18 18 0 4320 -qt3_drawArc 380 80 19 19 0 4320 +# qt3_drawArc 200 80 10 10 0 4320 +# qt3_drawArc 220 80 11 11 0 4320 +# qt3_drawArc 240 80 12 12 0 4320 +# qt3_drawArc 260 80 13 13 0 4320 +# qt3_drawArc 280 80 14 14 0 4320 +# qt3_drawArc 300 80 15 15 0 4320 +# qt3_drawArc 320 80 16 16 0 4320 +# qt3_drawArc 340 80 17 17 0 4320 +# qt3_drawArc 360 80 18 18 0 4320 +# qt3_drawArc 380 80 19 19 0 4320 drawChord 0 100 10 10 0 4320 drawChord 20 100 11 11 0 4320 @@ -122,16 +122,16 @@ drawChord 120 100 16 16 0 4320 drawChord 140 100 17 17 0 4320 drawChord 160 100 18 18 0 4320 drawChord 180 100 19 19 0 4320 -qt3_drawChord 200 100 10 10 0 4320 -qt3_drawChord 220 100 11 11 0 4320 -qt3_drawChord 240 100 12 12 0 4320 -qt3_drawChord 260 100 13 13 0 4320 -qt3_drawChord 280 100 14 14 0 4320 -qt3_drawChord 300 100 15 15 0 4320 -qt3_drawChord 320 100 16 16 0 4320 -qt3_drawChord 340 100 17 17 0 4320 -qt3_drawChord 360 100 18 18 0 4320 -qt3_drawChord 380 100 19 19 0 4320 +# qt3_drawChord 200 100 10 10 0 4320 +# qt3_drawChord 220 100 11 11 0 4320 +# qt3_drawChord 240 100 12 12 0 4320 +# qt3_drawChord 260 100 13 13 0 4320 +# qt3_drawChord 280 100 14 14 0 4320 +# qt3_drawChord 300 100 15 15 0 4320 +# qt3_drawChord 320 100 16 16 0 4320 +# qt3_drawChord 340 100 17 17 0 4320 +# qt3_drawChord 360 100 18 18 0 4320 +# qt3_drawChord 380 100 19 19 0 4320 end_block @@ -147,4 +147,4 @@ repeat_block testblock setPen red translate 0 150 -repeat_block testblock \ No newline at end of file +repeat_block testblock diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 21044d4..799aba7 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -135,7 +135,7 @@ void tst_Lancelot::initTestCase() void tst_Lancelot::testRasterARGB32PM_data() { - QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + QStringList localBlacklist; if (!setupTestSuite(ImageItem::Raster, QImage::Format_ARGB32_Premultiplied, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } @@ -149,7 +149,7 @@ void tst_Lancelot::testRasterARGB32PM() void tst_Lancelot::testRasterRGB32_data() { - QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + QStringList localBlacklist; if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB32, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } @@ -163,7 +163,7 @@ void tst_Lancelot::testRasterRGB32() void tst_Lancelot::testRasterRGB16_data() { - QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps"); + QStringList localBlacklist; if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB16, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } @@ -177,10 +177,7 @@ void tst_Lancelot::testRasterRGB16() void tst_Lancelot::testOpenGL_data() { -#if defined(Q_OS_MAC) - QSKIP("OpenGL testing not supported on this platform.", SkipAll); -#endif - QStringList localBlacklist = QStringList() << QLatin1String("sizes.qps") << QLatin1String("rasterops.qps"); + QStringList localBlacklist = QStringList() << QLatin1String("rasterops.qps"); if (!setupTestSuite(ImageItem::OpenGL, QImage::Format_RGB32, localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } -- cgit v0.12 From 789ae99928f96a7fc66ff9dacf6bbf5826d24cac Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 26 Oct 2010 12:39:47 +0200 Subject: Fix getting git info on Win --- tests/arthur/common/baselineprotocol.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index a7fb5be..6a35115 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -32,7 +32,16 @@ PlatformInfo::PlatformInfo(bool useLocal) #endif QProcess git; - git.start(QLS("git"), QStringList() << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H")); + QString cmd; + QStringList args; +#if defined(Q_OS_WIN) + cmd = QLS("cmd.exe"); + args << QLS("/c") << QLS("git"); +#else + cmd = QLS("git"); +#endif + args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H"); + git.start(cmd, args); git.waitForFinished(3000); if (!git.exitCode()) gitCommit = QString::fromLocal8Bit(git.readAllStandardOutput().constData()).trimmed(); -- cgit v0.12 From 9a9b891db491953c5b2d922aacb25aba0dce6771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 27 Oct 2010 11:19:20 +0200 Subject: Fixes unstability caused by a dangling pointer in GL text rendering Reviewed-by: eskil --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 3 ++- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 12 ++++++------ src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 025731d..fba3b20 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1477,9 +1477,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp void *cacheKey = const_cast(QGLContextPrivate::contextGroup(ctx)->context()); QGLTextureGlyphCache *cache = (QGLTextureGlyphCache *) staticTextItem->fontEngine->glyphCache(cacheKey, glyphType, QTransform()); - if (!cache || cache->cacheType() != glyphType) { + if (!cache || cache->cacheType() != glyphType || cache->context() == 0) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); staticTextItem->fontEngine->setGlyphCache(cacheKey, cache); + cache->insert(ctx, cache); } bool recreateVertexArrays = false; diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index b8576cb..f185f9a 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -54,11 +54,11 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QImageTextureGlyphCache(type, matrix) + : QImageTextureGlyphCache(type, matrix), QGLContextGroupResourceBase() , ctx(context) , pex(0) - , m_filterMode(Nearest) , m_blitProgram(0) + , m_filterMode(Nearest) { #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx); @@ -208,8 +208,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) { QString source; - source.append(qglslMainWithTexCoordsVertexShader); - source.append(qglslUntransformedPositionVertexShader); + source.append(QLatin1String(qglslMainWithTexCoordsVertexShader)); + source.append(QLatin1String(qglslUntransformedPositionVertexShader)); QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram); vertexShader->compileSourceCode(source); @@ -219,8 +219,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) { QString source; - source.append(qglslMainFragmentShader); - source.append(qglslImageSrcFragmentShader); + source.append(QLatin1String(qglslMainFragmentShader)); + source.append(QLatin1String(qglslImageSrcFragmentShader)); QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram); fragmentShader->compileSourceCode(source); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index f75cf68..572da82 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -98,7 +98,7 @@ struct QGLGlyphTexture int m_height; }; -class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache, public QGLContextGroupResourceBase { public: QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); @@ -140,6 +140,8 @@ public: FilterMode filterMode() const { return m_filterMode; } void setFilterMode(FilterMode m) { m_filterMode = m; } + void freeResource(void *) { ctx = 0; } + private: QGLContextGroupResource m_textureResource; -- cgit v0.12 From 1c04ebfcaf3f42585e9fceaaca5e798f13fa54c9 Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 28 Oct 2010 10:26:06 +0200 Subject: Clean up some comments --- tests/auto/lancelot/tst_lancelot.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 799aba7..03bee42 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -39,11 +39,6 @@ ** ****************************************************************************/ -// Generalization dimensions TBD: -// ImageFormat: Rendering to different bit formats -// Engine: Rendering with different engines -// Painter renderhints? (set in qps itself) - #include #include #include -- cgit v0.12 From 8e0034b4091e0ad08e16aba194c53d6582710550 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 2 Nov 2010 14:02:43 +0100 Subject: Put more platform info in the report headers --- tests/arthur/baselineserver/src/baselineserver.cpp | 2 +- tests/arthur/baselineserver/src/htmlpage.cpp | 11 +++++------ tests/arthur/baselineserver/src/htmlpage.h | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 1e241c1..2c0a91e 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -182,7 +182,7 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) QDataStream ods(&block, QIODevice::WriteOnly); ods << itemList; proto.sendBlock(BaselineProtocol::Ack, block); - report.start(BaselineServer::storagePath(), runId, plat, itemList); + report.start(BaselineServer::storagePath(), runId, plat, proto.socket.peerAddress().toString(), itemList); } diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 14bcb0c..5eb5a2c 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -20,12 +20,13 @@ QString HTMLPage::filePath() return path; } -void HTMLPage::start(const QString &storagepath, const QString &runId, const PlatformInfo pinfo, const ImageItemList &itemList) +void HTMLPage::start(const QString &storagepath, const QString &runId, const PlatformInfo pinfo, const QString &hostAddress, const ImageItemList &itemList) { end(); id = runId; plat = pinfo; + address = hostAddress; root = storagepath; imageItems = itemList; QString dir = root + QLS("reports/"); @@ -48,11 +49,9 @@ void HTMLPage::writeHeader(const ImageItem &item) out.setDevice(&file); out << "

Lancelot results from run " << id << "

\n\n"; - out << "

Host: " << plat.hostName << "

\n"; - out << "

Qt version: " << plat.qtVersion << "

\n"; - out << "

Build key: " << plat.buildKey << "

\n"; - out << "

Engine: " << item.engineAsString() << "

\n"; - out << "

Format: " << item.formatAsString() << "

\n\n"; + out << "

Host: " << plat.hostName << " [" << address << "] OS: " << plat.osName << " [enum: " << plat.osVersion << "]

\n"; + out << "

Qt version: " << plat.qtVersion << " [commit: " << plat.gitCommit << "] Build key: \"" << plat.buildKey << "\"

\n"; + out << "

Engine: " << item.engineAsString() << " Format: " << item.formatAsString() << "

\n\n"; out << "

ScriptBaselineRenderedComparisonFuzzy ComparisonScoreUpdate
Info/Action
" << item.scriptName << "Update baselineUpdate baseline
" + "Blacklist test
" << imageItems.at(i).scriptName << "N/AN/AN/A"; + if (imageItems.at(i).status == ImageItem::IgnoreItem) { + out << "Blacklisted
" + "Whitelist test"; + } else { + out << "Test passed"; + } + out << "
Update baseline
" "Blacklist test