diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-11-24 13:49:44 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-11-27 22:50:17 +0000 |
commit | fb69a09a2490102ad0c3f6015e04942bb5df7505 (patch) | |
tree | 1f086e8f21cb2b312098850b7b602c2fe45776c1 /tests/auto/widgets/widgets | |
parent | b4c8e1517455becb138876c08b3bdd880a80770d (diff) |
QWidget::mapTo/FromGlobal(): Avoid calling QWindow helpers until shown.
The platform window geometry can be misleading until it has
been properly positioned and
QWindowPrivate::resizeEventPending has been cleared.
Task-number: QTBUG-49588
Task-number: QTBUG-48396
Change-Id: Ie065f62478fc8522a9ad51391bb897510afa5aad
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 5ae0733965..b3f9c54f24 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -94,6 +94,7 @@ private slots: void task208001_stylesheet(); void activeSubMenuPosition(); + void activeSubMenuPositionExec(); void task242454_sizeHint(); void task176201_clear(); void task250673_activeMultiColumnSubMenuPosition(); @@ -694,6 +695,61 @@ void tst_QMenu::activeSubMenuPosition() #endif } +// QTBUG-49588, QTBUG-48396: activeSubMenuPositionExec() is the same as +// activeSubMenuPosition(), but uses QMenu::exec(), which produces a different +// sequence of events. Verify that the sub menu is positioned to the right of the +// main menu. +class SubMenuPositionExecMenu : public QMenu +{ + Q_OBJECT +public: + SubMenuPositionExecMenu() : QMenu("Menu-Title"), m_timerId(-1), m_timerTick(0) + { + addAction("Item 1"); + m_subMenu = addMenu("Submenu"); + m_subAction = m_subMenu->addAction("Sub-Item1"); + setActiveAction(m_subMenu->menuAction()); + } + +protected: + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE + { + QVERIFY(m_subMenu->isVisible()); + QVERIFY2(m_subMenu->x() > x(), + (QByteArray::number(m_subMenu->x()) + ' ' + QByteArray::number(x())).constData()); + m_timerId = startTimer(50); + QMenu::showEvent(e); + } + + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE + { + if (e->timerId() == m_timerId) { + switch (m_timerTick++) { + case 0: + m_subMenu->close(); + break; + case 1: + close(); + break; + } + } + } + +private: + int m_timerId; + int m_timerTick; + QMenu *m_subMenu; + QAction *m_subAction; +}; + +void tst_QMenu::activeSubMenuPositionExec() +{ +#ifndef Q_OS_WINCE + SubMenuPositionExecMenu menu; + menu.exec(QGuiApplication::primaryScreen()->availableGeometry().center()); +#endif // !Q_OS_WINCE +} + void tst_QMenu::task242454_sizeHint() { QMenu menu; |