diff options
Diffstat (limited to 'tests/auto/gui/kernel/qwindow')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/qwindow.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 58 |
2 files changed, 53 insertions, 6 deletions
diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 363f7dd92e..fb8132afab 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -6,4 +6,5 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp mac: CONFIG += insignificant_test # QTBUG-23059 +win32: CONFIG += insignificant_test # QTBUG-24904 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index f4556f7e32..ebd8823149 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -53,8 +53,10 @@ class tst_QWindow: public QObject Q_OBJECT private slots: + void eventOrderOnShow(); void mapGlobal(); void positioning(); + void isExposed(); void isActive(); void testInputEvents(); void touchToMouseTranslation(); @@ -114,6 +116,7 @@ public: bool event(QEvent *event) { m_received[event->type()]++; + m_order << event->type(); return QWindow::event(event); } @@ -123,10 +126,32 @@ public: return m_received.value(type, 0); } + int eventIndex(QEvent::Type type) + { + return m_order.indexOf(type); + } + private: QHash<QEvent::Type, int> m_received; + QVector<QEvent::Type> m_order; }; +void tst_QWindow::eventOrderOnShow() +{ + QRect geometry(80, 80, 40, 40); + + Window window; + window.setGeometry(geometry); + window.show(); + + QTRY_COMPARE(window.received(QEvent::Show), 1); + QTRY_COMPARE(window.received(QEvent::Resize), 1); + QTRY_VERIFY(window.isExposed()); + + QVERIFY(window.eventIndex(QEvent::Show) < window.eventIndex(QEvent::Resize)); + QVERIFY(window.eventIndex(QEvent::Resize) < window.eventIndex(QEvent::Expose)); +} + void tst_QWindow::positioning() { QRect geometry(80, 80, 40, 40); @@ -137,7 +162,7 @@ void tst_QWindow::positioning() window.show(); QTRY_COMPARE(window.received(QEvent::Resize), 1); - QTRY_COMPARE(window.received(QEvent::Map), 1); + QTRY_VERIFY(window.received(QEvent::Expose) > 0); QMargins originalMargins = window.frameMargins(); @@ -148,6 +173,9 @@ void tst_QWindow::positioning() QPoint originalFramePos = window.framePos(); window.setWindowState(Qt::WindowFullScreen); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24904 - Too many resize events on setting window state", Continue); +#endif QTRY_COMPARE(window.received(QEvent::Resize), 2); window.setWindowState(Qt::WindowNoState); @@ -179,13 +207,32 @@ void tst_QWindow::positioning() } } +void tst_QWindow::isExposed() +{ + QRect geometry(80, 80, 40, 40); + + Window window; + window.setGeometry(geometry); + QCOMPARE(window.geometry(), geometry); + window.show(); + + QTRY_VERIFY(window.received(QEvent::Expose) > 0); + QTRY_VERIFY(window.isExposed()); + + window.hide(); + + QTRY_VERIFY(window.received(QEvent::Expose) > 1); + QTRY_VERIFY(!window.isExposed()); +} + + void tst_QWindow::isActive() { Window window; window.setGeometry(80, 80, 40, 40); window.show(); - QTRY_COMPARE(window.received(QEvent::Map), 1); + QTRY_VERIFY(window.isExposed()); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); QVERIFY(window.isActive()); @@ -195,15 +242,14 @@ void tst_QWindow::isActive() child.setGeometry(10, 10, 20, 20); child.show(); - QTRY_COMPARE(child.received(QEvent::Map), 1); + QTRY_VERIFY(child.isExposed()); child.requestActivateWindow(); QTRY_VERIFY(QGuiApplication::focusWindow() == &child); QVERIFY(child.isActive()); - // parent shouldn't receive new map or resize events from child being shown - QTRY_COMPARE(window.received(QEvent::Map), 1); + // parent shouldn't receive new resize events from child being shown QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 1); QTRY_COMPARE(window.received(QEvent::FocusOut), 1); @@ -219,7 +265,7 @@ void tst_QWindow::isActive() dialog.requestActivateWindow(); - QTRY_COMPARE(dialog.received(QEvent::Map), 1); + QTRY_VERIFY(dialog.isExposed()); QTRY_COMPARE(dialog.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog); QVERIFY(dialog.isActive()); |