diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-12 15:28:12 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-16 15:56:29 +0000 |
commit | effc6b4cd15aefa1bef30c27f0458390735fafb5 (patch) | |
tree | d77f1e07cf62e80f53e43bdeb117c0b4efa9843b /tests/auto/widgets/widgets/qopenglwidget | |
parent | 1748b7e7d2f619dc32df7ccbd3aa24316aa63c82 (diff) |
Add widget support for requestUpdate() and improve its docs and tests
We must do something when requestUpdate() is called on a QWidgetWindow.
The semantics of UpdateRequest for QWindow and QWidget are unfortunately
different: for widgets an UpdateRequest means "sync the backing store".
For QWindow it also involves marking as dirty.
Change-Id: Idf40b3fc0873652dc081edeb12c96b3007a126ef
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qopenglwidget')
-rw-r--r-- | tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index ade70b0eec..0c0c50ac64 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -55,6 +55,7 @@ private slots: void reparentToAlreadyCreated(); void reparentToNotYetCreated(); void asViewport(); + void requestUpdate(); }; void tst_QOpenGLWidget::create() @@ -305,6 +306,29 @@ void tst_QOpenGLWidget::asViewport() QVERIFY(view->paintCount() == 0); } +class PaintCountWidget : public QOpenGLWidget +{ +public: + PaintCountWidget() : m_count(0) { } + void reset() { m_count = 0; } + void paintGL() Q_DECL_OVERRIDE { ++m_count; } + int m_count; +}; + +void tst_QOpenGLWidget::requestUpdate() +{ + PaintCountWidget w; + w.resize(640, 480); + w.show(); + QTest::qWaitForWindowExposed(&w); + + w.reset(); + QCOMPARE(w.m_count, 0); + + w.windowHandle()->requestUpdate(); + QTRY_VERIFY(w.m_count > 0); +} + QTEST_MAIN(tst_QOpenGLWidget) #include "tst_qopenglwidget.moc" |