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, "") + type(waitForCppEditor(), "") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), " xi") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "") - __typeAndWaitForAction__(cppwindow, "") - test.compare(lineUnderCursor(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "extern int xi;") + __typeAndWaitForAction__(waitForCppEditor(), "") + 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, "") + type(waitForCppEditor(), "") clickButton(waitForObject(":*Qt Creator_Utils::IconButton")) type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "freefunc2") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), "") - __typeAndWaitForAction__(cppwindow, "") - test.compare(lineUnderCursor(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "int freefunc2(double)") + __typeAndWaitForAction__(waitForCppEditor(), "") + 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, "") + type(waitForCppEditor(), "") 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"), "") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - __typeAndWaitForAction__(cppwindow, "") - test.compare(lineUnderCursor(findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), " Dummy(int a);") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + __typeAndWaitForAction__(waitForCppEditor(), "") + test.compare(lineUnderCursor(waitForCppEditor()), " Dummy(int a);") snooze(2) - __typeAndWaitForAction__(cppwindow, "") - test.compare(lineUnderCursor(findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "Dummy::Dummy(int)") + __typeAndWaitForAction__(waitForCppEditor(), "") + 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