aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-07-04 23:50:50 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-07-29 19:13:39 +0200
commit15ce5d915b6bda4bf1d3c85cbdc79b2e11690bca (patch)
tree83668da1212904d81a73208211861c36a74261ee /tests/auto/quick/qquickwindow
parent9c67029ee5aca18ae02e740afbf6d0f883799ebd (diff)
Introducing QQuickWindow::scheduleRenderJob()
[ChangeLog][QtQuick][QQuickWindow] Added QQuickWindow::scheduleRenderJob(), a convenience alternative to the equivalent signals for one-shot tasks. Change-Id: I5e4f0d67d5223f7fd77bca394e2a85810fadd335 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickwindow')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 17773fcfc4..6c1d46b191 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -55,6 +55,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <private/qquickwindow_p.h>
#include <private/qguiapplication_p.h>
+#include <QRunnable>
struct TouchEventData {
QEvent::Type type;
@@ -367,6 +368,8 @@ private slots:
void defaultSurfaceFormat();
void glslVersion();
+ void testRenderJob();
+
private:
QTouchDevice *touchDevice;
QTouchDevice *touchDeviceWithVelocity;
@@ -1971,6 +1974,58 @@ void tst_qquickwindow::glslVersion()
}
}
+class RenderJob : public QRunnable
+{
+public:
+ RenderJob(QQuickWindow::RenderStage s, QList<QQuickWindow::RenderStage> *l) : stage(s), list(l) { }
+ ~RenderJob() { ++deleted; }
+ QQuickWindow::RenderStage stage;
+ QList<QQuickWindow::RenderStage> *list;
+ void run() {
+ list->append(stage);
+ }
+ static int deleted;
+};
+
+int RenderJob::deleted = 0;
+
+void tst_qquickwindow::testRenderJob()
+{
+ QList<QQuickWindow::RenderStage> completedJobs;
+
+ QQuickWindow window;
+
+ QQuickWindow::RenderStage stages[] = {
+ QQuickWindow::BeforeSynchronizingStage,
+ QQuickWindow::AfterSynchronizingStage,
+ QQuickWindow::BeforeRenderingStage,
+ QQuickWindow::AfterRenderingStage,
+ QQuickWindow::AfterSwapStage
+ };
+ // Schedule the jobs
+ for (int i=0; i<5; ++i)
+ window.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]);
+ window.show();
+
+ QTRY_COMPARE(completedJobs.size(), 5);
+
+ for (int i=0; i<5; ++i) {
+ QCOMPARE(completedJobs.at(i), stages[i]);
+ }
+
+ // Verify that jobs are deleted when window has not been rendered at all...
+ completedJobs.clear();
+ RenderJob::deleted = 0;
+ {
+ QQuickWindow window2;
+ for (int i=0; i<5; ++i) {
+ window2.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]);
+ }
+ }
+ QCOMPARE(completedJobs.size(), 0);
+ QCOMPARE(RenderJob::deleted, 5);
+}
+
QTEST_MAIN(tst_qquickwindow)
#include "tst_qquickwindow.moc"