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