Squish: Unify hack for invoking context menu items on Mac

Change-Id: I7e4d1cb00ea75e1aa33fa20b30744ffd56f002de
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
This commit is contained in:
Christian Stenger
2014-01-28 14:21:32 +01:00
parent 4dbf2702e0
commit 06d34f5a12
4 changed files with 31 additions and 19 deletions

View File

@@ -301,10 +301,7 @@ def invokeContextMenuOnProject(projectName, menuItem):
str(projItem.text).replace("_", "\\_").replace(".", "\\."), 5, 5, 0) str(projItem.text).replace("_", "\\_").replace(".", "\\."), 5, 5, 0)
# Hack for Squish 5.0.1 handling menus of Qt5.2 on Mac (avoids crash) - remove asap # Hack for Squish 5.0.1 handling menus of Qt5.2 on Mac (avoids crash) - remove asap
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
for obj in object.topLevelObjects(): waitFor("macHackActivateContextMenuItem(menuItem)", 6000)
if (className(obj) == "QMenu" and obj.visible):
activateItem(waitForObjectItem(obj, menuItem))
break
else: else:
activateItem(waitForObjectItem("{name='Project.Menu.Project' type='QMenu' visible='1' " activateItem(waitForObjectItem("{name='Project.Menu.Project' type='QMenu' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", menuItem)) "window=':Qt Creator_Core::Internal::MainWindow'}", menuItem))

View File

@@ -30,6 +30,35 @@
import urllib2 import urllib2
import re import re
############ functions not related to issues tracked inside jira ############
def __checkWithoutWidget__(*args):
return className(args[0]) == 'QMenu' and args[0].visible
def __checkWithWidget__(*args):
return (__checkWithoutWidget__(args[0])
and widgetContainsPoint(waitForObject(args[1]), args[0].mapToGlobal(QPoint(0 ,0))))
# hack for activating context menus on Mac because of Squish5/Qt5.2 problems
# param item a string holding the menu item to invoke (just the label)
# param widget an object; if provided there will be an additional check if the menu's top left
# corner is placed on this widget
def macHackActivateContextMenuItem(item, widget=None):
if widget:
func = __checkWithWidget__
else:
func = __checkWithoutWidget__
for obj in object.topLevelObjects():
try:
if func(obj, widget):
activateItem(waitForObjectItem(obj, item))
return True
except:
pass
return False
################ workarounds for issues tracked inside jira #################
JIRA_URL='https://bugreports.qt-project.org/browse' JIRA_URL='https://bugreports.qt-project.org/browse'
class JIRA: class JIRA:

View File

@@ -29,16 +29,6 @@
source("../../shared/qtcreator.py") source("../../shared/qtcreator.py")
def macHackActivateContextMenuItem(item):
for obj in object.topLevelObjects():
try:
if className(obj) == 'QMenu' and obj.visible:
activateItem(waitForObjectItem(obj, item))
return True
except:
pass
return False
def main(): def main():
startApplication("qtcreator" + SettingsPath) startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError(): if not startedWithoutPluginError():

View File

@@ -49,11 +49,7 @@ def main():
openContextMenu(waitForObject(con[0]), 5, 5, 0) openContextMenu(waitForObject(con[0]), 5, 5, 0)
# hack for Squish 5/Qt5.2 problems of handling menus on Mac - remove asap # hack for Squish 5/Qt5.2 problems of handling menus on Mac - remove asap
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
for obj in object.topLevelObjects(): waitFor("macHackActivateContextMenuItem('Go to slot...', con[0])", 6000)
if (className(obj) == 'QMenu' and obj.visible
and widgetContainsPoint(waitForObject(con[0]), obj.mapToGlobal(QPoint(0, 0)))):
activateItem(obj, "Go to slot...")
break
else: else:
activateItem(waitForObjectItem("{type='QMenu' unnamed='1' visible='1'}", "Go to slot...")) activateItem(waitForObjectItem("{type='QMenu' unnamed='1' visible='1'}", "Go to slot..."))
waitForObjectItem(":Select signal.signalList_QTreeWidget", con[1]) waitForObjectItem(":Select signal.signalList_QTreeWidget", con[1])