summaryrefslogtreecommitdiffstats
path: root/tests/auto/texturemanager/tst_texturemanagertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/texturemanager/tst_texturemanagertest.cpp')
-rw-r--r--tests/auto/texturemanager/tst_texturemanagertest.cpp67
1 files changed, 64 insertions, 3 deletions
diff --git a/tests/auto/texturemanager/tst_texturemanagertest.cpp b/tests/auto/texturemanager/tst_texturemanagertest.cpp
index 886dfa0..f69a76a 100644
--- a/tests/auto/texturemanager/tst_texturemanagertest.cpp
+++ b/tests/auto/texturemanager/tst_texturemanagertest.cpp
@@ -62,18 +62,27 @@ private Q_SLOTS:
void requestUpload();
void requestUploadSameImageTwice();
+ void requestUploadSameImageTwiceWithDelay();
void requestUploadAfterSyncUpload();
+ void uploadAfterRequestUpload();
void gracefullyRunOutOfMemory();
void gracefullyFailOnTooLarge();
void maxTextureSize();
+public slots:
+ void textureStatusChanged(int newStatus) {
+ status = newStatus;
+ }
+
private:
QSGContext *context;
QGLWidget *glWidget;
QSGTextureManager *tm;
+
+ int status;
};
@@ -134,15 +143,18 @@ void TextureManagerTest::uploadSameImageTwice()
}
+/*!
+ Requests an image to be uploaded and verifies that it actually works
+ */
void TextureManagerTest::requestUpload()
{
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
QSGTextureRef t = tm->requestUpload(image, 0, 0);
QVERIFY(t->status() == QSGTexture::Ready || t->status() == QSGTexture::Loading);
-
- int maxWait = 1000;
- while (t->status() == QSGTexture::Loading) {
+ QTime time;
+ time.start();
+ while (t->status() == QSGTexture::Loading && time.elapsed() < 1000) {
QTest::qWait(50);
QApplication::processEvents();
}
@@ -155,6 +167,30 @@ void TextureManagerTest::requestUpload()
/*!
+ Requests the same image to be uploaded twice. The second time,
+ the image should be directly available. This is to verify that
+ we are actually caching the uploaded requested images.
+ */
+void TextureManagerTest::requestUploadSameImageTwiceWithDelay()
+{
+ QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+ QSGTextureRef t = tm->requestUpload(image, 0, 0);
+ QTime time;
+ time.start();
+ while (t->status() == QSGTexture::Loading && time.elapsed() < 1000) {
+ QTest::qWait(50);
+ QApplication::processEvents();
+ }
+ QVERIFY(t.isReady());
+
+ QSGTextureRef t2 = tm->requestUpload(image, 0, 0);
+ QVERIFY(t.texture() == t2.texture());
+ QVERIFY(t2.isReady());
+}
+
+
+
+/*!
Test that we don't fail horribly when allocating large amounts of
texture memory. Since some drivers page graphics memory out to disk
and thus never run out, cap the test at 128Mb to not run forever
@@ -234,6 +270,31 @@ void TextureManagerTest::requestUploadAfterSyncUpload()
+/*!
+ Verify that a sync upload after an async upload returns
+ a ready texture and that the async texture then also is
+ ready...
+ */
+void TextureManagerTest::uploadAfterRequestUpload()
+{
+ status = QSGTexture::Null;
+
+ QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+
+ QSGTextureRef async = tm->requestUpload(image, this, SLOT(textureStatusChanged(int)));
+ QSGTextureRef sync = tm->upload(image);
+
+ QVERIFY(sync.isReady());
+ QVERIFY(async.isReady());
+ QCOMPARE(status, int(QSGTexture::Ready));
+
+ QVERIFY(async.texture() == sync.texture());
+}
+
+
+
+
+
QTEST_MAIN(TextureManagerTest);
#include "tst_texturemanagertest.moc"