forked from qt-creator/qt-creator
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:
@@ -171,6 +171,10 @@ def invokeMenuItem(menu, item, *subItems):
|
|||||||
numberedPrefix = "%d | "
|
numberedPrefix = "%d | "
|
||||||
for subItem in subItems:
|
for subItem in subItems:
|
||||||
# we might have numbered sub items (e.g. "Recent Files") - these have this special prefix
|
# 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):
|
if subItem.startswith(numberedPrefix):
|
||||||
triggered = False
|
triggered = False
|
||||||
for i in range(1, 10):
|
for i in range(1, 10):
|
||||||
@@ -186,7 +190,10 @@ def invokeMenuItem(menu, item, *subItems):
|
|||||||
"Function arguments: '%s', '%s', %s" % (menu, item, str(subItems)))
|
"Function arguments: '%s', '%s', %s" % (menu, item, str(subItems)))
|
||||||
break # we failed to trigger - no need to process subItems further
|
break # we failed to trigger - no need to process subItems further
|
||||||
else:
|
else:
|
||||||
|
noAmpersandItem = item.replace('&', '')
|
||||||
|
waitForObject("{type='QMenu' title='%s'}" % noAmpersandItem, 2000)
|
||||||
itemObject = waitForObjectItem(itemObject, subItem)
|
itemObject = waitForObjectItem(itemObject, subItem)
|
||||||
|
waitFor("itemObject.enabled", 2000)
|
||||||
activateItem(itemObject)
|
activateItem(itemObject)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user