diff options
Diffstat (limited to 'tests/arthur')
-rw-r--r-- | tests/arthur/common/baselineprotocol.cpp | 150 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.h | 47 | ||||
-rw-r--r-- | tests/arthur/common/paintcommands.cpp | 34 | ||||
-rw-r--r-- | tests/arthur/common/paintcommands.h | 1 |
4 files changed, 172 insertions, 60 deletions
diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 0e7e507..88cea36 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -50,6 +50,18 @@ #include <QTime> #include <QPointer> +const QString PI_TestCase(QLS("TestCase")); +const QString PI_HostName(QLS("HostName")); +const QString PI_HostAddress(QLS("HostAddress")); +const QString PI_OSName(QLS("OSName")); +const QString PI_OSVersion(QLS("OSVersion")); +const QString PI_QtVersion(QLS("QtVersion")); +const QString PI_BuildKey(QLS("BuildKey")); +const QString PI_GitCommit(QLS("GitCommit")); +const QString PI_QMakeSpec(QLS("QMakeSpec")); +const QString PI_PulseGitBranch(QLS("PulseGitBranch")); +const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); + #ifndef QMAKESPEC #define QMAKESPEC "Unknown" #endif @@ -70,60 +82,117 @@ void BaselineProtocol::sysSleep(int ms) #endif } -PlatformInfo::PlatformInfo(bool useLocal) - : QMap<QString, QString>() +PlatformInfo::PlatformInfo() + : QMap<QString, QString>(), replaceDefault(false) { - if (useLocal) { - insert(PI_HostName, QHostInfo::localHostName()); - insert(PI_QtVersion, QLS(qVersion())); - insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/")))); - insert(PI_BuildKey, QLibraryInfo::buildKey()); +} + +PlatformInfo PlatformInfo::localHostInfo() +{ + PlatformInfo pi; + pi.insert(PI_HostName, QHostInfo::localHostName()); + pi.insert(PI_QtVersion, QLS(qVersion())); + pi.insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/")))); + pi.insert(PI_BuildKey, QLibraryInfo::buildKey()); #if defined(Q_OS_LINUX) - insert(PI_OSName, QLS("Linux")); - QProcess uname; - uname.start(QLS("uname"), QStringList() << QLS("-r")); - if (uname.waitForFinished(3000)) - insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); + pi.insert(PI_OSName, QLS("Linux")); + QProcess uname; + uname.start(QLS("uname"), QStringList() << QLS("-r")); + if (uname.waitForFinished(3000)) + pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); #elif defined(Q_OS_WINCE) - insert(PI_OSName, QLS("WinCE")); - insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); + pi.insert(PI_OSName, QLS("WinCE")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_WIN) - insert(PI_OSName, QLS("Windows")); - insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); + pi.insert(PI_OSName, QLS("Windows")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_MAC) - insert(PI_OSName, QLS("MacOS")); - insert(PI_OSVersion, QString::number(qMacVersion())); + pi.insert(PI_OSName, QLS("MacOS")); + pi.insert(PI_OSVersion, QString::number(qMacVersion())); #elif defined(Q_OS_SYMBIAN) - insert(PI_OSName, QLS("Symbian")); - insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion()); + pi.insert(PI_OSName, QLS("Symbian")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion()); #else - insert(PI_OSName, QLS("Other")); + pi.insert(PI_OSName, QLS("Other")); #endif - QProcess git; - QString cmd; - QStringList args; + QProcess git; + QString cmd; + QStringList args; #if defined(Q_OS_WIN) - cmd = QLS("cmd.exe"); - args << QLS("/c") << QLS("git"); + cmd = QLS("cmd.exe"); + args << QLS("/c") << QLS("git"); #else - cmd = QLS("git"); + cmd = QLS("git"); #endif - args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s"); - git.start(cmd, args); - git.waitForFinished(3000); - if (!git.exitCode()) - insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified()); - else - insert(PI_GitCommit, QLS("Unknown")); - } + args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s"); + git.start(cmd, args); + git.waitForFinished(3000); + if (!git.exitCode()) + pi.insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified()); + else + pi.insert(PI_GitCommit, QLS("Unknown")); QByteArray gb = qgetenv("PULSE_GIT_BRANCH"); if (!gb.isEmpty()) - insert(PI_PulseGitBranch, QString::fromLatin1(gb)); + pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb)); QByteArray tb = qgetenv("PULSE_TESTR_BRANCH"); if (!tb.isEmpty()) - insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); + pi.insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); + + return pi; +} + + +PlatformInfo::PlatformInfo(const PlatformInfo &other) + : QMap<QString, QString>(other) +{ + sigKeys = other.sigKeys; + replaceDefault = other.replaceDefault; +} + + +PlatformInfo &PlatformInfo::operator=(const PlatformInfo &other) +{ + QMap<QString, QString>::operator=(other); + sigKeys = other.sigKeys; + replaceDefault = other.replaceDefault; + return *this; +} + + +void PlatformInfo::addSignificantKeys(const QStringList &keys, bool replaceDefaultKeys) +{ + sigKeys = keys; + replaceDefault = replaceDefaultKeys; +} + + +QStringList PlatformInfo::addedKeys() const +{ + return sigKeys; +} + + +bool PlatformInfo::addedKeysReplaceDefault() const +{ + return replaceDefault; +} + + +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi) +{ + stream << static_cast<const QMap<QString, QString>&>(pi); + stream << pi.sigKeys << pi.replaceDefault; + return stream; +} + + +QDataStream & operator>> (QDataStream &stream, PlatformInfo &pi) +{ + stream >> static_cast<QMap<QString, QString>&>(pi); + stream >> pi.sigKeys >> pi.replaceDefault; + return stream; } @@ -251,7 +320,7 @@ void ImageItem::readImageFromStream(QDataStream &in) QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { - stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums; + stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums << ii.misc; ii.writeImageToStream(stream); return stream; } @@ -259,7 +328,7 @@ QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) QDataStream & operator>> (QDataStream &stream, ImageItem &ii) { quint8 encStatus; - stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums; + stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums >> ii.misc; ii.status = ImageItem::ItemStatus(encStatus); ii.readImageFromStream(stream); return stream; @@ -293,7 +362,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun) } } - PlatformInfo pi(true); + PlatformInfo pi = PlatformInfo::localHostInfo(); pi.insert(PI_TestCase, testCase); QByteArray block; QDataStream ds(&block, QIODevice::ReadWrite); @@ -453,3 +522,4 @@ QString BaselineProtocol::errorMessage() ret += QLS(" Socket state: ") + socket.errorString(); return ret; } + diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 259555d..8a99ace 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -48,29 +48,49 @@ #include <QVector> #include <QMap> #include <QPointer> +#include <QStringList> #define QLS QLatin1String #define QLC QLatin1Char #define FileFormat "png" -const QString PI_TestCase(QLS("TestCase")); -const QString PI_HostName(QLS("HostName")); -const QString PI_HostAddress(QLS("HostAddress")); -const QString PI_OSName(QLS("OSName")); -const QString PI_OSVersion(QLS("OSVersion")); -const QString PI_QtVersion(QLS("QtVersion")); -const QString PI_BuildKey(QLS("BuildKey")); -const QString PI_GitCommit(QLS("GitCommit")); -const QString PI_QMakeSpec(QLS("QMakeSpec")); -const QString PI_PulseGitBranch(QLS("PulseGitBranch")); -const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); +extern const QString PI_TestCase; +extern const QString PI_HostName; +extern const QString PI_HostAddress; +extern const QString PI_OSName; +extern const QString PI_OSVersion; +extern const QString PI_QtVersion; +extern const QString PI_BuildKey; +extern const QString PI_GitCommit; +extern const QString PI_QMakeSpec; +extern const QString PI_PulseGitBranch; +extern const QString PI_PulseTestrBranch; class PlatformInfo : public QMap<QString, QString> { public: - PlatformInfo(bool useLocal = false); + PlatformInfo(); + PlatformInfo(const PlatformInfo &other); + ~PlatformInfo() + {} + PlatformInfo &operator=(const PlatformInfo &other); + + static PlatformInfo localHostInfo(); + + void addSignificantKeys(const QStringList& keys, bool replaceDefaultKeys=false); + QStringList addedKeys() const; + bool addedKeysReplaceDefault() const; + +private: + QStringList sigKeys; + bool replaceDefault; + friend QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi); + friend QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi); }; +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi); +QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi); + struct ImageItem { @@ -99,6 +119,7 @@ public: QImage image; QList<quint64> imageChecksums; quint16 itemChecksum; + QByteArray misc; void writeImageToStream(QDataStream &stream) const; void readImageFromStream(QDataStream &stream); @@ -123,7 +144,7 @@ public: // Important constants here // **************************************************** enum Constant { - ProtocolVersion = 4, + ProtocolVersion = 5, ServerPort = 54129, Timeout = 5000 }; diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index b00ce81..7a018e3 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -96,6 +96,13 @@ const char *PaintCommands::fontWeightTable[] = { "Black" }; +const char *PaintCommands::fontHintingTable[] = { + "Default", + "None", + "Vertical", + "Full" +}; + const char *PaintCommands::clipOperationTable[] = { "NoClip", "ReplaceClip", @@ -177,8 +184,9 @@ const char *PaintCommands::imageFormatTable[] = { int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit) { + QByteArray p = pattern.toLatin1().toLower(); for (int i=0; i<limit; ++i) - if (pattern.toLower() == QString(QLatin1String(table[i])).toLower()) + if (p == QByteArray::fromRawData(table[i], qstrlen(table[i])).toLower()) return i; return -1; } @@ -287,9 +295,9 @@ void PaintCommands::staticInit() "setCompositionMode <composition mode enum>", "setCompositionMode SourceOver"); DECL_PAINTCOMMAND("setFont", command_setFont, - "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", - "setFont <fontFace> [size] [font weight|font weight enum] [italic]\n - font weight is an integer between 0 and 99", - "setFont \"times\" normal"); + "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", + "setFont <fontFace> [size] [font weight|font weight enum] [italic] [hinting enum]\n - font weight is an integer between 0 and 99", + "setFont \"times\" 12"); DECL_PAINTCOMMAND("setPen", command_setPen, "^setPen\\s+#?(\\w*)$", "setPen <color>\nsetPen <pen style enum>\nsetPen brush", @@ -641,6 +649,7 @@ void PaintCommands::staticInit() ADD_ENUMLIST("brush styles", brushStyleTable); ADD_ENUMLIST("pen styles", penStyleTable); ADD_ENUMLIST("font weights", fontWeightTable); + ADD_ENUMLIST("font hintings", fontHintingTable); ADD_ENUMLIST("clip operations", clipOperationTable); ADD_ENUMLIST("spread methods", spreadMethodTable); ADD_ENUMLIST("composition modes", compositionModeTable); @@ -2061,11 +2070,22 @@ void PaintCommands::command_setFont(QRegExp re) bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic"; + QFont font(family, size, weight, italic); + +#if QT_VERSION >= 0x040800 + int hinting = translateEnum(fontHintingTable, caps.at(5), 4); + if (hinting == -1) + hinting = 0; + else + font.setHintingPreference(QFont::HintingPreference(hinting)); +#else + int hinting = 1; +#endif if (m_verboseMode) - printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d\n", - qPrintable(family), size, weight, italic); + printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d hinting=%s\n", + qPrintable(family), size, weight, italic, fontHintingTable[hinting]); - m_painter->setFont(QFont(family, size, weight, italic)); + m_painter->setFont(font); } /***************************************************************************************************/ diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index b2516e1..2740412 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -290,6 +290,7 @@ private: static const char *brushStyleTable[]; static const char *penStyleTable[]; static const char *fontWeightTable[]; + static const char *fontHintingTable[]; static const char *clipOperationTable[]; static const char *spreadMethodTable[]; static const char *coordinateMethodTable[]; |