diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-23 07:13:00 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-23 07:13:00 +0100 |
commit | 1ed7a67a4cef8350103e4ea33b4bbd084f5d4c2d (patch) | |
tree | 03dd7b6f8d9ccc02da6d0d882793ec62c71b00f7 /tests/auto/widgets | |
parent | dbb7817e13bc7f7ccb8f04b00a65eb3dcf8d25f8 (diff) | |
parent | 6a2b17eeec2d171d2afa17bdbc36456346bfd13b (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/corelib/kernel/qcoreapplication.cpp
src/corelib/thread/qthread_unix.cpp
Change-Id: Ia08d613c3f0bd08cb6dc3e3a57257207dfd4a099
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 638fad6206..a4a0045265 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -57,6 +57,8 @@ private slots: void asViewport(); void requestUpdate(); void fboRedirect(); + void showHide(); + void nativeWindow(); }; void tst_QOpenGLWidget::create() @@ -81,7 +83,8 @@ public: : QOpenGLWidget(parent), m_initCalled(false), m_paintCalled(false), m_resizeCalled(false), m_resizeOk(false), - m_w(expectedWidth), m_h(expectedHeight) { } + m_w(expectedWidth), m_h(expectedHeight), + r(1.0f), g(0.0f), b(0.0f) { } void initializeGL() Q_DECL_OVERRIDE { m_initCalled = true; @@ -89,13 +92,16 @@ public: } void paintGL() Q_DECL_OVERRIDE { m_paintCalled = true; - glClearColor(1.0f, 0.0f, 0.0f, 1.0f); + glClearColor(r, g, b, 1.0f); glClear(GL_COLOR_BUFFER_BIT); } void resizeGL(int w, int h) Q_DECL_OVERRIDE { m_resizeCalled = true; m_resizeOk = w == m_w && h == m_h; } + void setClearColor(float r, float g, float b) { + this->r = r; this->g = g; this->b = b; + } bool m_initCalled; bool m_paintCalled; @@ -103,6 +109,7 @@ public: bool m_resizeOk; int m_w; int m_h; + float r, g, b; }; void tst_QOpenGLWidget::clearAndGrab() @@ -355,6 +362,69 @@ void tst_QOpenGLWidget::fboRedirect() QVERIFY(reportedDefaultFbo != widgetFbo); } +void tst_QOpenGLWidget::showHide() +{ + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + w->show(); + QTest::qWaitForWindowExposed(w.data()); + + w->hide(); + + QImage image = w->grabFramebuffer(); + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0)); + + w->setClearColor(0, 0, 1); + w->show(); + QTest::qWaitForWindowExposed(w.data()); + + image = w->grabFramebuffer(); + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); +} + +void tst_QOpenGLWidget::nativeWindow() +{ + QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600)); + w->resize(800, 600); + w->show(); + w->winId(); + QTest::qWaitForWindowExposed(w.data()); + + QImage image = w->grabFramebuffer(); + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), w->width()); + QCOMPARE(image.height(), w->height()); + QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0)); + QVERIFY(w->internalWinId()); + + // Now as a native child. + QWidget nativeParent; + nativeParent.resize(800, 600); + nativeParent.setAttribute(Qt::WA_NativeWindow); + ClearWidget *child = new ClearWidget(0, 800, 600); + child->setClearColor(0, 1, 0); + child->setParent(&nativeParent); + child->resize(400, 400); + child->move(23, 34); + nativeParent.show(); + QTest::qWaitForWindowExposed(&nativeParent); + + QVERIFY(nativeParent.internalWinId()); + QVERIFY(!child->internalWinId()); + + image = child->grabFramebuffer(); + QVERIFY(!image.isNull()); + QCOMPARE(image.width(), child->width()); + QCOMPARE(image.height(), child->height()); + QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0)); +} + QTEST_MAIN(tst_QOpenGLWidget) #include "tst_qopenglwidget.moc" |