diff options
author | aavit <qt-info@nokia.com> | 2010-09-03 08:29:10 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-09-03 08:29:10 (GMT) |
commit | 0d18809a78021709f024e85c5251815a5864a7e3 (patch) | |
tree | 0066a909bb2941c853c9f6596b70de9a44f51302 /tests/arthur/common | |
parent | 38f0e9dbf41ebc8707398279ccb7038d3927c2d8 (diff) | |
download | Qt-0d18809a78021709f024e85c5251815a5864a7e3.zip Qt-0d18809a78021709f024e85c5251815a5864a7e3.tar.gz Qt-0d18809a78021709f024e85c5251815a5864a7e3.tar.bz2 |
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.
Diffstat (limited to 'tests/arthur/common')
-rw-r--r-- | tests/arthur/common/baselineprotocol.cpp | 58 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.h | 11 |
2 files changed, 7 insertions, 62 deletions
diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index e5545a9..a6306b9 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -141,39 +141,17 @@ bool BaselineProtocol::requestBaselineChecksums(ImageItemList *itemList) } -bool BaselineProtocol::requestBaseline(const QString &caseId, Command *response, QImage *baseline) +bool BaselineProtocol::submitNewBaseline(const ImageItem &item, QByteArray *serverMsg) { - //### TBD: rewrite to use ImageItem - 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; + 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); |