summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-08-29 12:45:39 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-09-01 07:44:01 +0200
commita3b026475483f9377248b2a00e55da28d17258d1 (patch)
tree33f458aa3a65b09e3d87f71953fd355381fd4983 /tests
parent9cdf9973c60f6974fe9b405b10ef9cffef7ae4f2 (diff)
Clean up shared resources immediately as the last context is destroyed.
By not waiting until deleteLater() kicks in it's easier to auto-test. We can now add a test case for what happens when a shared resource is still valid while the last context is destroyed. Change-Id: I72963928e6a921e49ed59a79e2579b497ba37ccf Reviewed-on: http://codereview.qt.nokia.com/3732 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qopengl/tst_qopengl.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qopengl/tst_qopengl.cpp b/tests/auto/qopengl/tst_qopengl.cpp
index 1df7985df9..173d1e4568 100644
--- a/tests/auto/qopengl/tst_qopengl.cpp
+++ b/tests/auto/qopengl/tst_qopengl.cpp
@@ -146,7 +146,24 @@ void tst_QOpenGL::sharedResourceCleanup()
QCOMPARE(tracker.freeResourceCalls, 1);
QCOMPARE(tracker.destructorCalls, 1);
+ tracker.reset();
+
+ resource = new SharedResource(&tracker);
+
+ // this should cause invalidateResource() to be called
delete ctx2;
+
+ QCOMPARE(tracker.invalidateResourceCalls, 1);
+ QCOMPARE(tracker.freeResourceCalls, 0);
+ QCOMPARE(tracker.destructorCalls, 0);
+
+ // should have no effect other than destroying the resource,
+ // as it has already been invalidated
+ resource->free();
+
+ QCOMPARE(tracker.invalidateResourceCalls, 1);
+ QCOMPARE(tracker.freeResourceCalls, 0);
+ QCOMPARE(tracker.destructorCalls, 1);
}
static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const char* file, int line, int x = -1, int y = -1)