summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2017-01-12 10:03:10 -0800
committerOleg Yadrov <oleg.yadrov@qt.io>2017-03-04 00:43:50 +0000
commitad5565b6438cb239ad36722605a31b1006cd6478 (patch)
tree9039c0113bbba5256eabdbc5f27cd8b7f1015b34 /tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
parentd46afc24c177642734ed7a228fc6d3a0d7fa429f (diff)
Wide QMenu: fix size and position
This patch fixes 2 issues related to wide menus: 1) Menu took on full screen height when menu width was larger than screen width; 2) On a multi-display system wide menu might appear on wrong monitor (not the one where show event was triggered). The idea is we limit parent menu and all its submenus within the screen where it was opened. Note that this patch fixes only geometry-related issues and there are also some style flaws which need to be addressed (for example, currently the text does not elide if it doesn’t fit to the menu’s width). Task-number: QTBUG-56917 Change-Id: I7e9ff4a48bf03060d76e34d33a13ad6cc890c133 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp')
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 3218b8ac68..4e82099706 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -42,6 +42,7 @@
#include <qmenu.h>
#include <qstyle.h>
+#include <QStyleHints>
#include <QTimer>
#include <qdebug.h>
@@ -110,6 +111,8 @@ private slots:
void QTBUG_37933_ampersands_data();
void QTBUG_37933_ampersands();
#endif
+ void QTBUG_56917_wideMenuSize();
+ void QTBUG_56917_wideMenuScreenNumber();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -1311,5 +1314,39 @@ void tst_QMenu::QTBUG_37933_ampersands()
}
#endif
+void tst_QMenu::QTBUG_56917_wideMenuSize()
+{
+ // menu shouldn't to take on full screen height when menu width is larger than screen width
+ QMenu menu;
+ QString longString;
+ longString.fill(QLatin1Char('Q'), 3000);
+ menu.addAction(longString);
+ QSize menuSizeHint = menu.sizeHint();
+ menu.popup(QPoint());
+ QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowExposed(&menu));
+ QVERIFY(menu.isVisible());
+ QVERIFY(menu.height() <= menuSizeHint.height());
+}
+
+void tst_QMenu::QTBUG_56917_wideMenuScreenNumber()
+{
+ if (QApplication::styleHints()->showIsFullScreen())
+ QSKIP("The platform defaults to windows being fullscreen.");
+ // menu must appear on the same screen where show action is triggered
+ QString longString;
+ longString.fill(QLatin1Char('Q'), 3000);
+
+ for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
+ QMenu menu;
+ menu.addAction(longString);
+ menu.popup(QApplication::desktop()->screen(i)->geometry().center());
+ QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowExposed(&menu));
+ QVERIFY(menu.isVisible());
+ QCOMPARE(QApplication::desktop()->screenNumber(&menu), i);
+ }
+}
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"