summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond.kjernasen@nokia.com>2010-09-03 10:33:03 (GMT)
committerTrond Kjernåsen <trond.kjernasen@nokia.com>2010-09-03 10:43:20 (GMT)
commitc6a8721bc87709dd60c68c67877f3fdc0f2d3300 (patch)
treed5a9398dd283886d1cc1a379acd40f65f8fff168 /tests/auto
parent0d18809a78021709f024e85c5251815a5864a7e3 (diff)
downloadQt-c6a8721bc87709dd60c68c67877f3fdc0f2d3300.zip
Qt-c6a8721bc87709dd60c68c67877f3fdc0f2d3300.tar.gz
Qt-c6a8721bc87709dd60c68c67877f3fdc0f2d3300.tar.bz2
Add basic OpenGL testing support.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/lancelot/tst_lancelot.cpp70
1 files changed, 63 insertions, 7 deletions
diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp
index 4485880..93b9346 100644
--- a/tests/auto/lancelot/tst_lancelot.cpp
+++ b/tests/auto/lancelot/tst_lancelot.cpp
@@ -50,6 +50,8 @@
#include <QLibraryInfo>
#include <baselineprotocol.h>
+#include <QtOpenGL>
+
#ifndef SRCDIR
#define SRCDIR "."
#endif
@@ -65,6 +67,7 @@ public:
private:
ImageItem render(const ImageItem &item);
+ void paint(QPaintDevice *device, const QStringList &script, const QString &filePath);
QStringList loadScriptFile(const QString &filePath);
void runTestSuite();
@@ -77,6 +80,9 @@ private slots:
void testRasterARGB32PM_data();
void testRasterARGB32PM();
+
+ void testOpenGL_data();
+ void testOpenGL();
};
tst_Lancelot::tst_Lancelot()
@@ -143,6 +149,36 @@ void tst_Lancelot::testRasterARGB32PM()
}
+void tst_Lancelot::testOpenGL_data()
+{
+ QTest::addColumn<ImageItem>("item");
+
+ ImageItemList itemList(baseList);
+
+ for(int i = 0; i < itemList.size(); i++) {
+ itemList[i].engine = ImageItem::OpenGL;
+ itemList[i].renderFormat = QImage::Format_RGB32;
+ }
+
+ if (!proto.requestBaselineChecksums(&itemList)) {
+ QWARN(qPrintable(proto.errorMessage()));
+ QSKIP("Communication with baseline image server failed.", SkipAll);
+ }
+
+ qDebug() << "items:" << itemList.count();
+ foreach(const ImageItem& item, itemList) {
+ if (item.scriptName != QLatin1String("sizes.qps")) // Hardcoded blacklisting for this enigine/format
+ QTest::newRow(item.scriptName.toLatin1()) << item;
+ }
+}
+
+
+void tst_Lancelot::testOpenGL()
+{
+ runTestSuite();
+}
+
+
void tst_Lancelot::runTestSuite()
{
QFETCH(ImageItem, baseline);
@@ -178,20 +214,40 @@ ImageItem tst_Lancelot::render(const ImageItem &item)
if (script.isEmpty()) {
res.image = QImage();
res.imageChecksum = 0;
- } else {
+ } else if (item.engine == ImageItem::Raster) {
QImage img(800, 800, item.renderFormat);
- QPainter p(&img);
- PaintCommands pcmd(script, 800, 800);
- pcmd.setPainter(&p);
- pcmd.setFilePath(QFileInfo(filePath).absoluteFilePath()); // eh yuck
- pcmd.runCommands();
- p.end();
+ paint(&img, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff)
res.image = img;
res.imageChecksum = ImageItem::computeChecksum(img);
+ } else if (item.engine == ImageItem::OpenGL) {
+ QGLWidget glWidget;
+ if (!glWidget.isValid()) {
+ res.image = QImage();
+ res.imageChecksum = 0;
+ return res;
+ }
+ glWidget.resize(800, 800);
+ glWidget.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&glWidget);
+#endif
+ paint(&glWidget, script, QFileInfo(filePath).absoluteFilePath()); // eh yuck (filePath stuff)
+ res.image = glWidget.grabFrameBuffer().convertToFormat(item.renderFormat);
+ res.imageChecksum = ImageItem::computeChecksum(res.image);
}
+
return res;
}
+void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const QString &filePath)
+{
+ QPainter p(device);
+ PaintCommands pcmd(script, 800, 800);
+ pcmd.setPainter(&p);
+ pcmd.setFilePath(filePath);
+ pcmd.runCommands();
+ p.end();
+}
QStringList tst_Lancelot::loadScriptFile(const QString &filePath)
{