diff options
author | Robert Loehning <robert.loehning@qt.io> | 2022-11-09 12:29:21 +0100 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2022-11-09 13:21:38 +0000 |
commit | c4164738b8b24469a012e628a4b2c45fbe8b292b (patch) | |
tree | 3d8bfede05c191ed8120159eeb9a95e0b9f551a1 /tests | |
parent | 0be6ba955d3c7e434524dca9084cbfcac75808c8 (diff) |
SquishTests: Stabilize tst_basic_cpp_support
Make sure the CppEditor is available before proceeding.
Change-Id: I34ed4f581637cc3608283ac045ceb5b4e6ada55a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/system/suite_editors/tst_basic_cpp_support/test.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/tests/system/suite_editors/tst_basic_cpp_support/test.py b/tests/system/suite_editors/tst_basic_cpp_support/test.py index c6da9872b4a..b5af8467280 100644 --- a/tests/system/suite_editors/tst_basic_cpp_support/test.py +++ b/tests/system/suite_editors/tst_basic_cpp_support/test.py @@ -3,6 +3,11 @@ source("../../shared/qtcreator.py") + +def waitForCppEditor(): + return waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + + def main(): projectDir = os.path.join(srcPath, "creator", "tests", "manual", "cplusplus-tools") proFileName = "cplusplus-tools.pro" @@ -31,27 +36,26 @@ def main(): # t3 = t2.file() # t4 = t3.fileName # test.compare(editorManager.currentEditor().file().fileName, "base.cpp") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") # - Move the cursor to the usage of a variable. # - Press F2 or select from the menu: Tools / C++ / Follow Symbol under Cursor # Creator will show you the declaration of the variable. - type(cppwindow, "<Ctrl+f>") + type(waitForCppEditor(), "<Ctrl+f>") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), " xi") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "<Return>") - __typeAndWaitForAction__(cppwindow, "<F2>") - test.compare(lineUnderCursor(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "extern int xi;") + __typeAndWaitForAction__(waitForCppEditor(), "<F2>") + test.compare(lineUnderCursor(waitForCppEditor()), "extern int xi;") # - Move the cursor to a function call. # - Press F2 or select from the menu: Tools / C++ / Follow Symbol under Cursor # Creator will show you the definition of the function. - type(cppwindow, "<Ctrl+f>") + type(waitForCppEditor(), "<Ctrl+f>") clickButton(waitForObject(":*Qt Creator_Utils::IconButton")) type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "freefunc2") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "<Return>") - __typeAndWaitForAction__(cppwindow, "<F2>") - test.compare(lineUnderCursor(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "int freefunc2(double)") + __typeAndWaitForAction__(waitForCppEditor(), "<F2>") + test.compare(lineUnderCursor(waitForCppEditor()), "int freefunc2(double)") # - Move the cursor to a function declaration # - Press Shift+F2 or select from menu: Tools / C++ / Switch Between Method Declaration/Definition @@ -63,20 +67,18 @@ def main(): if not waitFor("str(mainWin.windowTitle).startswith('dummy.cpp ') and ' @ cplusplus-tools ' in str(mainWin.windowTitle)", 5000): test.warning("Opening dummy.cpp seems to have failed") # Reset cursor to the start of the document - jumpToFirstLine(cppwindow) + jumpToFirstLine(waitForCppEditor()) - type(cppwindow, "<Ctrl+f>") + type(waitForCppEditor(), "<Ctrl+f>") clickButton(waitForObject(":*Qt Creator_Utils::IconButton")) type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "Dummy::Dummy") # Take us to the second instance type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "<Return>") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - __typeAndWaitForAction__(cppwindow, "<Shift+F2>") - test.compare(lineUnderCursor(findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), " Dummy(int a);") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + __typeAndWaitForAction__(waitForCppEditor(), "<Shift+F2>") + test.compare(lineUnderCursor(waitForCppEditor()), " Dummy(int a);") snooze(2) - __typeAndWaitForAction__(cppwindow, "<Shift+F2>") - test.compare(lineUnderCursor(findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "Dummy::Dummy(int)") + __typeAndWaitForAction__(waitForCppEditor(), "<Shift+F2>") + test.compare(lineUnderCursor(waitForCppEditor()), "Dummy::Dummy(int)") invokeMenuItem("File", "Exit") def __typeAndWaitForAction__(editor, keyCombination): @@ -88,7 +90,6 @@ def __typeAndWaitForAction__(editor, keyCombination): def cppEditorPositionChanged(origPos): try: - editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget", 500) - return editor.textCursor().position() != origPos + return waitForCppEditor().textCursor().position() != origPos except: return False |