summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond.kjernasen@nokia.com>2010-09-07 13:55:27 (GMT)
committerTrond Kjernåsen <trond.kjernasen@nokia.com>2010-09-07 13:59:47 (GMT)
commita59566262ebd226a901172fc06c7bcb9023d5a33 (patch)
tree5bef597d469780f6fde314307bcd4ebcc89d11c5 /tests
parent5e3d55cc6fc3216e0079bb9d0c835338c9ac2ef8 (diff)
downloadQt-a59566262ebd226a901172fc06c7bcb9023d5a33.zip
Qt-a59566262ebd226a901172fc06c7bcb9023d5a33.tar.gz
Qt-a59566262ebd226a901172fc06c7bcb9023d5a33.tar.bz2
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/arthur/baselineserver/src/baselineserver.cpp12
-rw-r--r--tests/arthur/common/baselineprotocol.cpp26
-rw-r--r--tests/arthur/common/baselineprotocol.h8
-rw-r--r--tests/auto/lancelot/tst_lancelot.cpp18
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<quint64> &checkSumList)
+{
+ stream << quint32(checkSumList.count());
+ foreach(quint64 checksum, checkSumList)
+ stream << checksum;
+ return stream;
+}
+
+QDataStream & operator>> (QDataStream &stream, QList<quint64> &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<quint64> 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<quint64> &checkSumList);
+QDataStream & operator>> (QDataStream &stream, QList<quint64> &checkSumList);
+
typedef QVector<ImageItem> 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;