SquishTests: Simplify and stabilize special handling of Mac menus

- Check condition only once
- Make sure correct length is being used

Change-Id: I8c9627d91b4f022d60bae039c0478248cc30d183
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Löhning
2023-07-26 16:19:57 +02:00
parent a6a95420b6
commit 5c1b8dee32

View File

@@ -171,11 +171,13 @@ def invokeMenuItem(menu, item, *subItems):
numberedPrefix = "%d | "
for subItem in subItems:
# we might have numbered sub items (e.g. "Recent Files") - these have this special prefix
# but on macOS we don't add these prefixes
if platform.system() == 'Darwin' and subItem.startswith(numberedPrefix):
subItem = subItem[5:]
hasNumPrefix = subItem.startswith(numberedPrefix)
if hasNumPrefix and platform.system() == 'Darwin':
# on macOS we don't add these prefixes
subItem = subItem[len(numberedPrefix):]
hasNumPrefix = False
if subItem.startswith(numberedPrefix):
if hasNumPrefix:
triggered = False
for i in range(1, 10):
try: