summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp20
-rw-r--r--tests/auto/qgl/tst_qgl.cpp118
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp14
3 files changed, 143 insertions, 9 deletions
diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index fa36845..19fa502 100644
--- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -69,6 +69,8 @@ private slots:
void cacheControl_data();
void cacheControl();
+ void deleteCache();
+
private:
void check();
};
@@ -84,8 +86,8 @@ public:
#ifdef Q_OS_SYMBIAN
QString location = QLatin1String("./cache/");
#else
- QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
- + QLatin1String("/cache/");
+ QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation)
+ + QLatin1String("/qnetworkdiskcache/");
#endif
setCacheDirectory(location);
clear();
@@ -275,6 +277,20 @@ void tst_QAbstractNetworkCache::check()
QCOMPARE(diskCache->gotData, fetchFromCache);
}
+void tst_QAbstractNetworkCache::deleteCache()
+{
+ QNetworkAccessManager manager;
+ NetworkDiskCache *diskCache = new NetworkDiskCache(&manager);
+ manager.setCache(diskCache);
+
+ QString url = "httpcachetest_cachecontrol.cgi?max-age=1000";
+ QNetworkRequest request(QUrl(TESTFILE + url));
+ QNetworkReply *reply = manager.get(request);
+ QSignalSpy downloaded1(reply, SIGNAL(finished()));
+ manager.setCache(0);
+ QTRY_COMPARE(downloaded1.count(), 1);
+}
+
QTEST_MAIN(tst_QAbstractNetworkCache)
#include "tst_qabstractnetworkcache.moc"
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 073afc8..f979174 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -46,6 +46,7 @@
#include <qdebug.h>
#include <qgl.h>
#include <qglpixelbuffer.h>
+#include <qglframebufferobject.h>
#include <qglcolormap.h>
#include <qpaintengine.h>
@@ -71,6 +72,8 @@ private slots:
void partialGLWidgetUpdates_data();
void partialGLWidgetUpdates();
void glWidgetRendering();
+ void glFBORendering();
+ void glFBOUseInGLWidget();
void glPBufferRendering();
void glWidgetReparent();
void colormap();
@@ -706,6 +709,121 @@ void tst_QGL::glWidgetRendering()
QCOMPARE(fb, reference);
}
+// NOTE: This tests that CombinedDepthStencil attachment works by assuming the
+// GL2 engine is being used and is implemented the same way as it was when
+// this autotest was written. If this is not the case, there may be some
+// false-positives: I.e. The test passes when either the depth or stencil
+// buffer is actually missing. But that's probably ok anyway.
+void tst_QGL::glFBORendering()
+{
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
+
+ QGLWidget glw;
+ glw.makeCurrent();
+
+ // No multisample with combined depth/stencil attachment:
+ QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+
+ // Don't complicate things by using NPOT:
+ QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat);
+
+ QPainter fboPainter;
+ bool painterBegun = fboPainter.begin(fbo);
+ QVERIFY(painterBegun);
+
+ QPainterPath intersectingPath;
+ intersectingPath.moveTo(0, 0);
+ intersectingPath.lineTo(100, 0);
+ intersectingPath.lineTo(0, 100);
+ intersectingPath.lineTo(100, 100);
+ intersectingPath.closeSubpath();
+
+ QPainterPath trianglePath;
+ trianglePath.moveTo(50, 0);
+ trianglePath.lineTo(100, 100);
+ trianglePath.lineTo(0, 100);
+ trianglePath.closeSubpath();
+
+ fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::red); // Background
+ fboPainter.translate(14, 14);
+ fboPainter.fillPath(intersectingPath, Qt::blue); // Test stencil buffer works
+ fboPainter.translate(128, 0);
+ fboPainter.setClipPath(trianglePath); // Test depth buffer works
+ fboPainter.setTransform(QTransform()); // reset xform
+ fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::green);
+ fboPainter.end();
+
+ QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
+ delete fbo;
+
+ // As we're doing more than trivial painting, we can't just compare to
+ // an image rendered with raster. Instead, we sample at well-defined
+ // test-points:
+ QCOMPARE(fb.pixel(39, 64), QColor(Qt::red).rgb());
+ QCOMPARE(fb.pixel(89, 64), QColor(Qt::red).rgb());
+ QCOMPARE(fb.pixel(64, 39), QColor(Qt::blue).rgb());
+ QCOMPARE(fb.pixel(64, 89), QColor(Qt::blue).rgb());
+
+ QCOMPARE(fb.pixel(167, 39), QColor(Qt::red).rgb());
+ QCOMPARE(fb.pixel(217, 39), QColor(Qt::red).rgb());
+ QCOMPARE(fb.pixel(192, 64), QColor(Qt::green).rgb());
+}
+
+class FBOUseInGLWidget : public QGLWidget
+{
+public:
+ bool widgetPainterBeginOk;
+ bool fboPainterBeginOk;
+ QImage fboImage;
+protected:
+ void paintEvent(QPaintEvent*)
+ {
+ QPainter widgetPainter;
+ widgetPainterBeginOk = widgetPainter.begin(this);
+ QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat);
+
+ QPainter fboPainter;
+ fboPainterBeginOk = fboPainter.begin(fbo);
+ fboPainter.fillRect(0, 0, 128, 128, Qt::red);
+ fboPainter.end();
+ fboImage = fbo->toImage();
+
+ widgetPainter.fillRect(rect(), Qt::blue);
+
+ delete fbo;
+ }
+
+};
+
+void tst_QGL::glFBOUseInGLWidget()
+{
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
+
+ FBOUseInGLWidget w;
+ w.resize(128, 128);
+ w.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&w);
+#endif
+ QTest::qWait(200);
+
+ QVERIFY(w.widgetPainterBeginOk);
+ QVERIFY(w.fboPainterBeginOk);
+
+ QImage widgetFB = w.grabFrameBuffer(false);
+ QImage widgetReference(widgetFB.size(), widgetFB.format());
+ widgetReference.fill(0xff0000ff);
+ QCOMPARE(widgetFB, widgetReference);
+
+ QImage fboReference(w.fboImage.size(), w.fboImage.format());
+ fboReference.fill(0xffff0000);
+ QCOMPARE(w.fboImage, fboReference);
+}
+
void tst_QGL::glWidgetReparent()
{
// Try it as a top-level first:
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index 68f0620..8fe6839 100644
--- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
+++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
@@ -155,7 +155,7 @@ struct ScriptEngineEvent
lineNumber(lineNumber)
{ }
- ScriptEngineEvent(Type type, qint64 scriptId = -1)
+ ScriptEngineEvent(Type type, qint64 scriptId = -777)
: type(type), scriptId(scriptId)
{ }
@@ -1593,8 +1593,6 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch()
{
spy->clear();
eng.evaluate("try { throw new Error('ciao'); } catch (e) { }");
- if (qt_script_isJITEnabled())
- QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort);
QCOMPARE(spy->count(), 2);
QCOMPARE(spy->at(0).type, ScriptEngineEvent::ExceptionThrow);
@@ -1606,6 +1604,8 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch()
QCOMPARE(spy->at(1).type, ScriptEngineEvent::ExceptionCatch);
QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId);
+ if (qt_script_isJITEnabled())
+ QEXPECT_FAIL("", "Exception value is not passed in exceptionCatch event when JIT is enabled", Continue);
QVERIFY(spy->at(1).value.strictlyEquals(spy->at(0).value));
}
}
@@ -1728,8 +1728,6 @@ void tst_QScriptEngineAgent::eventOrder_throwAndCatch()
{
spy->clear();
eng.evaluate("try { throw new Error('ciao') } catch (e) { void(e); }");
- if (qt_script_isJITEnabled())
- QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort);
QCOMPARE(spy->count(), 12);
// load
QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad);
@@ -1751,6 +1749,8 @@ void tst_QScriptEngineAgent::eventOrder_throwAndCatch()
QVERIFY(spy->at(7).hasExceptionHandler);
// catch
QCOMPARE(spy->at(8).type, ScriptEngineEvent::ExceptionCatch);
+ if (qt_script_isJITEnabled())
+ QEXPECT_FAIL("", "Exception value is not passed in exceptionCatch event when JIT is enabled", Continue);
QVERIFY(spy->at(8).value.isError());
// void(e)
QCOMPARE(spy->at(9).type, ScriptEngineEvent::PositionChange);
@@ -1914,8 +1914,6 @@ void tst_QScriptEngineAgent::eventOrder_throwCatchFinally()
{
spy->clear();
eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }");
- if (qt_script_isJITEnabled())
- QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort);
QCOMPARE(spy->count(), 9);
// load
@@ -2100,6 +2098,7 @@ void tst_QScriptEngineAgent::syntaxError()
i = 2;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPush);
+ QEXPECT_FAIL("","The test is broken, contextPush event do not provide scriptId", Continue);
QVERIFY(spy->at(i).scriptId == -1);
i = 3;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry);
@@ -2109,6 +2108,7 @@ void tst_QScriptEngineAgent::syntaxError()
QVERIFY(spy->at(i).scriptId == -1);
i = 5;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPop);
+ QEXPECT_FAIL("","The test is broken, contextPop event do not provide scriptId", Continue);
QVERIFY(spy->at(i).scriptId == -1);
i = 6;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ExceptionThrow);