diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index 07f0fe6af82..f6f0a78635b 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -301,10 +301,7 @@ def invokeContextMenuOnProject(projectName, menuItem): 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 if platform.system() == 'Darwin': - for obj in object.topLevelObjects(): - if (className(obj) == "QMenu" and obj.visible): - activateItem(waitForObjectItem(obj, menuItem)) - break + waitFor("macHackActivateContextMenuItem(menuItem)", 6000) else: activateItem(waitForObjectItem("{name='Project.Menu.Project' type='QMenu' visible='1' " "window=':Qt Creator_Core::Internal::MainWindow'}", menuItem)) diff --git a/tests/system/shared/workarounds.py b/tests/system/shared/workarounds.py index 05a413eb574..f1cef9a2b88 100644 --- a/tests/system/shared/workarounds.py +++ b/tests/system/shared/workarounds.py @@ -30,6 +30,35 @@ import urllib2 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' class JIRA: diff --git a/tests/system/suite_tools/tst_designer_autocomplete/test.py b/tests/system/suite_tools/tst_designer_autocomplete/test.py index 25ebf5865d3..fe3f7896d48 100644 --- a/tests/system/suite_tools/tst_designer_autocomplete/test.py +++ b/tests/system/suite_tools/tst_designer_autocomplete/test.py @@ -29,16 +29,6 @@ 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(): startApplication("qtcreator" + SettingsPath) if not startedWithoutPluginError(): diff --git a/tests/system/suite_tools/tst_designer_goto_slot/test.py b/tests/system/suite_tools/tst_designer_goto_slot/test.py index b6d73bdefb8..e11d0afb1da 100644 --- a/tests/system/suite_tools/tst_designer_goto_slot/test.py +++ b/tests/system/suite_tools/tst_designer_goto_slot/test.py @@ -49,11 +49,7 @@ def main(): openContextMenu(waitForObject(con[0]), 5, 5, 0) # hack for Squish 5/Qt5.2 problems of handling menus on Mac - remove asap if platform.system() == 'Darwin': - for obj in object.topLevelObjects(): - if (className(obj) == 'QMenu' and obj.visible - and widgetContainsPoint(waitForObject(con[0]), obj.mapToGlobal(QPoint(0, 0)))): - activateItem(obj, "Go to slot...") - break + waitFor("macHackActivateContextMenuItem('Go to slot...', con[0])", 6000) else: activateItem(waitForObjectItem("{type='QMenu' unnamed='1' visible='1'}", "Go to slot...")) waitForObjectItem(":Select signal.signalList_QTreeWidget", con[1])