Squish: Fix menu handling on macOS

Some menus inside QC have special numbering - but this only
applies to Linux and Windows. On macOS we do not add this
special numbering.
Additionally this patch stabilizes the triggering of
submenus. When they get triggered it takes a split of a
second until the items inside the menu are usable.
Let squish wait until the sub menu is fully present before
trying to activate some of its items.

Change-Id: I32c688a937ada1da07506d4ebd22730e4f2bcaef
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Christian Stenger
2023-07-18 15:14:40 +02:00
parent c0b29f28c0
commit a86356ce8a

View File

@@ -171,6 +171,10 @@ 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:]
if subItem.startswith(numberedPrefix):
triggered = False
for i in range(1, 10):
@@ -186,7 +190,10 @@ def invokeMenuItem(menu, item, *subItems):
"Function arguments: '%s', '%s', %s" % (menu, item, str(subItems)))
break # we failed to trigger - no need to process subItems further
else:
noAmpersandItem = item.replace('&', '')
waitForObject("{type='QMenu' title='%s'}" % noAmpersandItem, 2000)
itemObject = waitForObjectItem(itemObject, subItem)
waitFor("itemObject.enabled", 2000)
activateItem(itemObject)