aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/shared/visualtestutil.h
diff options
context:
space:
mode:
authorYuya Nishihara <yuya.nishihara@qt.io>2020-08-28 18:32:20 +0900
committerYuya Nishihara <yuya.nishihara@qt.io>2020-09-02 10:44:40 +0900
commitde007e507ca2693203d15506aede3294e6236a83 (patch)
tree8055b3e144555ae2be90e28009e65c0d21cfebaa /tests/auto/shared/visualtestutil.h
parent704c009d839f69ad02a4112f1c0450a6d0d44096 (diff)
Menu: Close menu by Alt key on platforms supporting mnemonic shortcuts
This is close to what the widget QMenu (and Windows native menu) do. Before, the active menu was left open and Alt+<key> shortcut would be delivered to one of the matching items, which might be an item shadowed by the active menu popup. With this patch, the active menu is closed on Alt key pressed so the subsequent shortcut event will (likely) be delivered to the matching MenuBar item. Since I'm going to fix the issue of &mnemonic key conflict resolution, I need to first change the way of delivering a shortcut event to the parent MenuBar. The test cases use the undocumented function to simulate low-level behavior of Alt itself and Alt+<key> events. Apparently, there's no public QTest function to send multiple key events without releasing Alt modifier. Task-number: QTBUG-86276 Pick-to: 5.15 Change-Id: I0ed6ea94f0fee7983a5cb6352d388036d3a1f8df Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/shared/visualtestutil.h')
-rw-r--r--tests/auto/shared/visualtestutil.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h
index 726daa27..cbc0bade 100644
--- a/tests/auto/shared/visualtestutil.h
+++ b/tests/auto/shared/visualtestutil.h
@@ -39,6 +39,7 @@
#include <functional>
+#include <QtCore/QPointer>
#include <QtQuick/QQuickItem>
#include <QtQml/QQmlExpression>
#include <QtQuick/private/qquickitem_p.h>
@@ -190,6 +191,22 @@ namespace QQuickVisualTestUtil
void forEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skipList, ForEachCallback callback);
void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skipList = QStringList());
+
+ // Helper to simulate Alt itself and Alt+<key> events.
+ class MnemonicKeySimulator
+ {
+ Q_DISABLE_COPY(MnemonicKeySimulator)
+ public:
+ explicit MnemonicKeySimulator(QWindow *window);
+
+ void press(Qt::Key key);
+ void release(Qt::Key key);
+ void click(Qt::Key key);
+
+ private:
+ QPointer<QWindow> m_window;
+ Qt::KeyboardModifiers m_modifiers;
+ };
}
#define QQUICK_VERIFY_POLISH(item) \