diff options
author | aavit <qt-info@nokia.com> | 2010-12-08 15:35:54 +0100 |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-12-08 15:35:54 +0100 |
commit | d21eee4fb39ee8378bb87187cec5e46275dc31ed (patch) | |
tree | baf380d2e6c34922e7c0e83527c42fe619f7839d /tests/auto/lancelot | |
parent | 993f9b23d72ec74453163413403d0cf06d9f08f4 (diff) | |
download | qt4-tools-d21eee4fb39ee8378bb87187cec5e46275dc31ed.tar.gz |
Make protocol less lancelot-specific, prepare use in other testcases
Diffstat (limited to 'tests/auto/lancelot')
-rw-r--r-- | tests/auto/lancelot/tst_lancelot.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 7c6fe664da..d1b093fd35 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -66,10 +66,15 @@ public: static bool simfail; private: - ImageItem render(const ImageItem &item); + enum GraphicsEngine { + Raster = 0, + OpenGL = 1 + }; + + bool setupTestSuite(const QStringList& blacklist); + void runTestSuite(GraphicsEngine engine, QImage::Format format); + ImageItem render(const ImageItem &item, GraphicsEngine engine, QImage::Format format); void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); - void runTestSuite(); - bool setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist); BaselineProtocol proto; ImageItemList baseList; @@ -108,7 +113,7 @@ void tst_Lancelot::initTestCase() #if defined(Q_OS_SOMEPLATFORM) QSKIP("This test is not supported on this platform.", SkipAll); #endif - if (!proto.connect(&dryRunMode)) + if (!proto.connect(QLatin1String("tst_Lancelot"), &dryRunMode)) QSKIP(qPrintable(proto.errorMessage()), SkipAll); QDir qpsDir(scriptsDir); @@ -125,8 +130,8 @@ void tst_Lancelot::initTestCase() 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->itemName = fileName; + it->itemChecksum = qChecksum(cont.constData(), cont.size()); it++; } } @@ -135,42 +140,42 @@ void tst_Lancelot::initTestCase() void tst_Lancelot::testRasterARGB32PM_data() { QStringList localBlacklist; - if (!setupTestSuite(ImageItem::Raster, QImage::Format_ARGB32_Premultiplied, localBlacklist)) + if (!setupTestSuite(localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } void tst_Lancelot::testRasterARGB32PM() { - runTestSuite(); + runTestSuite(Raster, QImage::Format_ARGB32_Premultiplied); } void tst_Lancelot::testRasterRGB32_data() { QStringList localBlacklist; - if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB32, localBlacklist)) + if (!setupTestSuite(localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } void tst_Lancelot::testRasterRGB32() { - runTestSuite(); + runTestSuite(Raster, QImage::Format_RGB32); } void tst_Lancelot::testRasterRGB16_data() { QStringList localBlacklist; - if (!setupTestSuite(ImageItem::Raster, QImage::Format_RGB16, localBlacklist)) + if (!setupTestSuite(localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } void tst_Lancelot::testRasterRGB16() { - runTestSuite(); + runTestSuite(Raster, QImage::Format_RGB16); } @@ -178,7 +183,7 @@ void tst_Lancelot::testRasterRGB16() void tst_Lancelot::testOpenGL_data() { QStringList localBlacklist = QStringList() << QLatin1String("rasterops.qps"); - if (!setupTestSuite(ImageItem::OpenGL, QImage::Format_RGB32, localBlacklist)) + if (!setupTestSuite(localBlacklist)) QSKIP("Communication with baseline image server failed.", SkipAll); } @@ -197,45 +202,39 @@ void tst_Lancelot::testOpenGL() ok = true; } if (ok) - runTestSuite(); + runTestSuite(OpenGL, QImage::Format_RGB32); else QSKIP("System under test does not meet preconditions for GL testing. Skipping.", SkipAll); } #endif -bool tst_Lancelot::setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist) +bool tst_Lancelot::setupTestSuite(const QStringList& blacklist) { QTest::addColumn<ImageItem>("baseline"); ImageItemList itemList(baseList); - - for(ImageItemList::iterator it = itemList.begin(); it != itemList.end(); it++) { - it->engine = engine; - it->renderFormat = format; - } - - if (!proto.requestBaselineChecksums(&itemList)) { + if (!proto.requestBaselineChecksums(QTest::currentTestFunction(), &itemList)) { QWARN(qPrintable(proto.errorMessage())); return false; } foreach(const ImageItem& item, itemList) { - if (!blacklist.contains(item.scriptName)) - QTest::newRow(item.scriptName.toLatin1()) << item; + if (!blacklist.contains(item.itemName)) + QTest::newRow(item.itemName.toLatin1()) << item; } return true; } -void tst_Lancelot::runTestSuite() +void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format) { QFETCH(ImageItem, baseline); if (baseline.status == ImageItem::IgnoreItem) QSKIP("Blacklisted by baseline server.", SkipSingle); - ImageItem rendered = render(baseline); + ImageItem rendered = render(baseline, engine, format); 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); @@ -258,21 +257,21 @@ void tst_Lancelot::runTestSuite() } -ImageItem tst_Lancelot::render(const ImageItem &item) +ImageItem tst_Lancelot::render(const ImageItem &item, GraphicsEngine engine, QImage::Format format) { ImageItem res = item; res.imageChecksums.clear(); res.image = QImage(); - QString filePath = scriptsDir + item.scriptName; - QStringList script = scripts.value(item.scriptName); + QString filePath = scriptsDir + item.itemName; + QStringList script = scripts.value(item.itemName); - if (item.engine == ImageItem::Raster) { - QImage img(800, 800, item.renderFormat); + if (engine == Raster) { + QImage img(800, 800, format); paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff) res.image = img; res.imageChecksums.append(ImageItem::computeChecksum(img)); #ifndef QT_NO_OPENGL - } else if (item.engine == ImageItem::OpenGL) { + } else if (engine == OpenGL) { QGLWidget glWidget; if (glWidget.isValid()) { glWidget.makeCurrent(); @@ -281,7 +280,7 @@ ImageItem tst_Lancelot::render(const ImageItem &item) 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.image = fbo.toImage().convertToFormat(format); res.imageChecksums.append(ImageItem::computeChecksum(res.image)); } #endif |