From 7c9d2e3a1a3e1fa8a2159bdb33edab5d23700cd0 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@digia.com> Date: Wed, 20 Feb 2013 19:49:32 +0100 Subject: [PATCH] Squish: Fix invoking context menu sub items Change-Id: I7d498ac3d4e2e2d25b3c504a95f96e434d0d1619 Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com> --- tests/system/shared/debugger.py | 3 +-- tests/system/shared/editor_utils.py | 3 ++- tests/system/suite_QMLS/tst_QMLS03/test.py | 3 +-- tests/system/suite_QMLS/tst_QMLS04/test.py | 4 +--- tests/system/suite_QMLS/tst_QMLS05/test.py | 4 +--- tests/system/suite_QMLS/tst_QMLS06/test.py | 4 +--- tests/system/suite_QMLS/tst_QMLS07/test.py | 4 +--- tests/system/suite_editors/tst_qml_editor/test.py | 3 +-- 8 files changed, 9 insertions(+), 19 deletions(-) diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py index db78d54db7..8737cfd479 100644 --- a/tests/system/shared/debugger.py +++ b/tests/system/shared/debugger.py @@ -30,8 +30,7 @@ def takeDebuggerLog(): debuggerLogWindow = waitForObject("{container=':DebugModeWidget.Debugger Log_QDockWidget' type='Debugger::Internal::CombinedPane' unnamed='1' visible='1'}") debuggerLog = str(debuggerLogWindow.plainText) mouseClick(debuggerLogWindow, 5, 5, 0, Qt.LeftButton) - activateItem(waitForObjectItem(openContextMenuOnTextCursorPosition(debuggerLogWindow), - "Clear Contents")) + invokeContextMenuItem(debuggerLogWindow, "Clear Contents") waitFor("str(debuggerLogWindow.plainText)==''", 5000) invokeMenuItem("Window", "Views", "Debugger Log") return debuggerLog diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 0e7afe7361..431c6087ae 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -274,7 +274,8 @@ def invokeContextMenuItem(editorArea, command1, command2 = None): ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command1, 2000)) if command2: - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command2, 2000)) + activateItem(waitForObjectItem("{type='QMenu' visible='1' window=%s}" + % objectMap.realName(ctxtMenu), command2, 2000)) # this function invokes the "Find Usages" item from context menu # param editor an editor object diff --git a/tests/system/suite_QMLS/tst_QMLS03/test.py b/tests/system/suite_QMLS/tst_QMLS03/test.py index abb3ab3a5a..992736eef5 100644 --- a/tests/system/suite_QMLS/tst_QMLS03/test.py +++ b/tests/system/suite_QMLS/tst_QMLS03/test.py @@ -60,8 +60,7 @@ def main(): return for i in range(5): type(editorArea, "<Left>") - ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Find Usages")) + invokeContextMenuItem(editorArea, "Find Usages") # check if usage was properly found expectedResults = [ExpectedResult("color-animation.qml", 49, "Rectangle {"), ExpectedResult("color-animation.qml", 96, "Rectangle {"), diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py index 8b88e610fb..e807c7f88b 100644 --- a/tests/system/suite_QMLS/tst_QMLS04/test.py +++ b/tests/system/suite_QMLS/tst_QMLS04/test.py @@ -8,9 +8,7 @@ def main(): for i in range(5): type(editorArea, "<Left>") # invoke Refactoring - Move Component into separate file - ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring")) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Move Component into Separate File")) + invokeContextMenuItem(editorArea, "Refactoring", "Move Component into Separate File") # give component name and proceed replaceEditorContent(waitForObject(":Dialog.componentNameEdit_QLineEdit"), "MyComponent") clickButton(waitForObject(":Dialog.OK_QPushButton")) diff --git a/tests/system/suite_QMLS/tst_QMLS05/test.py b/tests/system/suite_QMLS/tst_QMLS05/test.py index c036438299..76f93bcb32 100644 --- a/tests/system/suite_QMLS/tst_QMLS05/test.py +++ b/tests/system/suite_QMLS/tst_QMLS05/test.py @@ -18,9 +18,7 @@ def main(): invokeMenuItem("File", "Save All") # activate menu and apply 'Refactoring - Split initializer' numLinesExpected = len(str(editorArea.plainText).splitlines()) + 4 - ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring")) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Split Initializer")) + invokeContextMenuItem(editorArea, "Refactoring", "Split Initializer") # wait until refactoring ended waitFor("len(str(editorArea.plainText).splitlines()) == numLinesExpected", 5000) # verify if refactoring was properly applied - each part on separate line diff --git a/tests/system/suite_QMLS/tst_QMLS06/test.py b/tests/system/suite_QMLS/tst_QMLS06/test.py index 61cc916519..7c15748cd0 100644 --- a/tests/system/suite_QMLS/tst_QMLS06/test.py +++ b/tests/system/suite_QMLS/tst_QMLS06/test.py @@ -12,9 +12,7 @@ def main(): invokeMenuItem("File", "Save All") # invoke Refactoring - Wrap Component in Loader numLinesExpected = len(str(editorArea.plainText).splitlines()) + 10 - ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring")) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Wrap Component in Loader")) + invokeContextMenuItem(editorArea, "Refactoring", "Wrap Component in Loader") # wait until refactoring ended waitFor("len(str(editorArea.plainText).splitlines()) >= numLinesExpected", 5000) # verify if refactoring was properly applied diff --git a/tests/system/suite_QMLS/tst_QMLS07/test.py b/tests/system/suite_QMLS/tst_QMLS07/test.py index f8502c7af4..dc6678314c 100644 --- a/tests/system/suite_QMLS/tst_QMLS07/test.py +++ b/tests/system/suite_QMLS/tst_QMLS07/test.py @@ -11,9 +11,7 @@ def main(): invokeMenuItem("File", "Save All") # invoke Refactoring - Add a message suppression comment. numLinesExpected = len(str(editorArea.plainText).splitlines()) + 1 - ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring")) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Add a Comment to Suppress This Message")) + invokeContextMenuItem(editorArea, "Refactoring", "Add a Comment to Suppress This Message") # wait until refactoring ended waitFor("len(str(editorArea.plainText).splitlines()) >= numLinesExpected", 5000) # verify if refactoring was properly applied diff --git a/tests/system/suite_editors/tst_qml_editor/test.py b/tests/system/suite_editors/tst_qml_editor/test.py index 975d673ad8..57080c3ac1 100644 --- a/tests/system/suite_editors/tst_qml_editor/test.py +++ b/tests/system/suite_editors/tst_qml_editor/test.py @@ -52,8 +52,7 @@ def testRenameId(): return False type(editor, "<Down>") searchFinished = False - ctxtMenu = openContextMenuOnTextCursorPosition(editor) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Rename Symbol Under Cursor")) + invokeContextMenuItem(editor, "Rename Symbol Under Cursor") waitFor("searchFinished") type(waitForObject("{leftWidget={text='Replace with:' type='QLabel' unnamed='1' visible='1'} " "type='Find::Internal::WideEnoughLineEdit' unnamed='1' visible='1' " -- GitLab