summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
diff options
context:
space:
mode:
authorTang Haixiang <tanghaixiang@uniontech.com>2021-08-06 10:28:28 +0800
committerTang Haixiang <tanghaixiang@uniontech.com>2021-08-12 19:10:27 +0800
commita7b1aaa98be60c739d11f1a7d30440a70c6ea77a (patch)
treeb264aadca54a0b4484738296da1f5575cea5c119 /tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
parentd6661c56222250f75de64cda09aab1f3837db58c (diff)
Close all popup windows when the screen is rotated
Changing the screen orientation will cause the menu position to be displayed incorrectly. When the screen is rotated, the geometry of the application changes. We can refer to the handling of the menu on Android or IOS. Close the popup window when the screen orientation changes. Fixes: QTBUG-95607 Pick-to: 6.2 Change-Id: I55e1cd6a8b89e375c6714a9163dfb1902d52f101 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp')
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index e52df3c84c..4b46c05568 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -133,6 +133,7 @@ private slots:
void menuSize_Scrolling();
void tearOffMenuNotDisplayed();
void QTBUG_61039_menu_shortcuts();
+ void screenOrientationChangedCloseMenu();
protected slots:
void onActivated(QAction*);
@@ -1960,5 +1961,20 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts()
QTRY_COMPARE(actionJoeSpy.count(), 1);
}
+void tst_QMenu::screenOrientationChangedCloseMenu()
+{
+ QMenu menu;
+ menu.addAction("action1");
+ menu.show();
+
+ QTRY_COMPARE(menu.isVisible(),true);
+
+ Qt::ScreenOrientation orientation = menu.screen()->orientation() == Qt::PortraitOrientation ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
+ QScreenOrientationChangeEvent event(menu.screen(), orientation);
+ QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
+
+ QTRY_COMPARE(menu.isVisible(),false);
+}
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"