From b58dadfecc36255c0e64e0cc02e162e1595953b5 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 1 Sep 2017 15:23:34 +0200 Subject: Squish: Enclose code model tests in sections Change-Id: I4478acfc5ea7b3fa22d1cd17576e04fdda81dbb9 Reviewed-by: Christian Stenger --- tests/system/README | 2 +- tests/system/shared/clang.py | 6 +- tests/system/shared/classes.py | 10 ++ tests/system/suite_CSUP/tst_CSUP01/test.py | 157 +++++++++++---------- tests/system/suite_CSUP/tst_CSUP02/test.py | 107 +++++++------- tests/system/suite_CSUP/tst_CSUP03/test.py | 79 ++++++----- tests/system/suite_CSUP/tst_CSUP04/test.py | 75 +++++----- tests/system/suite_CSUP/tst_CSUP05/test.py | 111 +++++++-------- tests/system/suite_CSUP/tst_CSUP06/test.py | 35 ++--- .../suite_editors/tst_memberoperator/test.py | 51 +++---- 10 files changed, 326 insertions(+), 307 deletions(-) diff --git a/tests/system/README b/tests/system/README index 6a62bb8d05..294f1bdba2 100644 --- a/tests/system/README +++ b/tests/system/README @@ -2,7 +2,7 @@ Prerequisites - general information ----------------------------------- Squish tests inside this folder have several prerequisites to get them running. -First - and most important - you have to own a valid Squish license. Currently it's recommended to use Squish 6.0. +First - and most important - you have to own a valid Squish license. At least Squish 6.0 is required. Second - some of the test suites/test cases expect a build of Qt 4.8.7 to be available: 1. Download the source code from: diff --git a/tests/system/shared/clang.py b/tests/system/shared/clang.py index 70a0e8ac67..dc07789740 100644 --- a/tests/system/shared/clang.py +++ b/tests/system/shared/clang.py @@ -61,11 +61,13 @@ def __openCodeModelOptions__(): clickItem(":Options_QListView", "C++", 14, 15, 0, Qt.LeftButton) clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Code Model") -def checkCodeModelSettings(useClang): +def getCodeModelString(useClang): codeModelName = "built-in" if useClang: codeModelName = "Clang" - test.log("Testing code model: %s" % codeModelName) + return "Testing code model: %s" % codeModelName + +def checkCodeModelSettings(useClang): __openCodeModelOptions__() test.verify(verifyChecked("{name='ignorePCHCheckBox' type='QCheckBox' visible='1'}"), "Verifying whether 'Ignore pre-compiled headers' is checked by default.") diff --git a/tests/system/shared/classes.py b/tests/system/shared/classes.py index 47c6012c9f..eb74c9ad0d 100644 --- a/tests/system/shared/classes.py +++ b/tests/system/shared/classes.py @@ -231,3 +231,13 @@ class Qt5Path: path = "Docs/Qt-5.%d" % qtMinorVersion return os.path.join(Qt5Path.__createPlatformQtPath__(qtMinorVersion), path) + +class TestSection: + def __init__(self, description): + self.description = description + + def __enter__(self): + test.startSection(self.description) + + def __exit__(self, exc_type, exc_value, traceback): + test.endSection() diff --git a/tests/system/suite_CSUP/tst_CSUP01/test.py b/tests/system/suite_CSUP/tst_CSUP01/test.py index 5463bd4248..3512630ea4 100644 --- a/tests/system/suite_CSUP/tst_CSUP01/test.py +++ b/tests/system/suite_CSUP/tst_CSUP01/test.py @@ -44,89 +44,90 @@ def triggerCompletion(editorWidget): # entry of test def main(): for useClang in [False, True]: - if not startCreator(useClang): - continue - # create qt quick application + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + # create qt quick application # Step 1: Open test .pro project. - createNewQtQuickApplication(tempDir(), "SampleApp") - checkCodeModelSettings(useClang) - changeAutocompleteToManual(False) + createNewQtQuickApplication(tempDir(), "SampleApp") + checkCodeModelSettings(useClang) + changeAutocompleteToManual(False) # Step 2: Open .cpp file in Edit mode. - if not openDocument("SampleApp.Sources.main\\.cpp"): - test.fatal("Could not open main.cpp") - invokeMenuItem("File", "Exit") - return - test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), - "Step 2: Verifying if: .cpp file is opened in Edit mode.") + if not openDocument("SampleApp.Sources.main\\.cpp"): + test.fatal("Could not open main.cpp") + invokeMenuItem("File", "Exit") + return + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Step 2: Verifying if: .cpp file is opened in Edit mode.") # Step 3: Insert text "re" to new line in Editor mode and press Ctrl+Space. - editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - if not placeCursorToLine(editorWidget, "QGuiApplication app(argc, argv);"): - earlyExit("Did not find first line in function block.") - return - type(editorWidget, "") - type(editorWidget, "re") - triggerCompletion(editorWidget) - functionName = "realpath" - if platform.system() in ('Windows', 'Microsoft'): - functionName = "realloc" - waitForObjectItem(":popupFrame_Proposal_QListView", functionName) - doubleClickItem(":popupFrame_Proposal_QListView", functionName, 5, 5, 0, Qt.LeftButton) - test.compare(str(lineUnderCursor(editorWidget)).strip(), functionName + "()", - "Step 3: Verifying if: The list of suggestions is opened. It is " - "possible to select one of the suggestions.") + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + if not placeCursorToLine(editorWidget, "QGuiApplication app(argc, argv);"): + earlyExit("Did not find first line in function block.") + return + type(editorWidget, "") + type(editorWidget, "re") + triggerCompletion(editorWidget) + functionName = "realpath" + if platform.system() in ('Windows', 'Microsoft'): + functionName = "realloc" + waitForObjectItem(":popupFrame_Proposal_QListView", functionName) + doubleClickItem(":popupFrame_Proposal_QListView", functionName, 5, 5, 0, Qt.LeftButton) + test.compare(str(lineUnderCursor(editorWidget)).strip(), functionName + "()", + "Step 3: Verifying if: The list of suggestions is opened. It is " + "possible to select one of the suggestions.") # Step 4: Insert text "voi" to new line and press Tab. - resetLine(editorWidget) - type(editorWidget, "voi") - try: - waitForObjectItem(":popupFrame_Proposal_QListView", "void") - type(waitForObject(":popupFrame_Proposal_QListView"), "") - test.compare(str(lineUnderCursor(editorWidget)).strip(), "void", - "Step 4: Verifying if: Word 'void' is completed because only one option is available.") - except: - test.fail("The expected completion popup was not shown.") + resetLine(editorWidget) + type(editorWidget, "voi") + try: + waitForObjectItem(":popupFrame_Proposal_QListView", "void") + type(waitForObject(":popupFrame_Proposal_QListView"), "") + test.compare(str(lineUnderCursor(editorWidget)).strip(), "void", + "Step 4: Verifying if: Word 'void' is completed because only one option is available.") + except: + test.fail("The expected completion popup was not shown.") # Step 4.5: Insert text "2." to new line and verify that code completion is not triggered (QTCREATORBUG-16188) - resetLine(editorWidget) - lineWithFloat = "float fl = 2." - type(editorWidget, lineWithFloat) - try: - waitForObject(":popupFrame_Proposal_QListView", 5000) - test.fail("Typing a float value triggered code completion") - except: - test.compare(str(lineUnderCursor(editorWidget)), " " + lineWithFloat, - "Typing a float value does not trigger code completion") - triggerCompletion(editorWidget) - try: - waitForObject(":popupFrame_Proposal_QListView", 5000) - if useClang and JIRA.isBugStillOpen(16607): - test.xfail("User can trigger code completion manually in a float value") - else: - test.fail("User can trigger code completion manually in a float value") - except: - test.passes("User can't trigger code completion manually in a float value") + resetLine(editorWidget) + lineWithFloat = "float fl = 2." + type(editorWidget, lineWithFloat) + try: + waitForObject(":popupFrame_Proposal_QListView", 5000) + test.fail("Typing a float value triggered code completion") + except: + test.compare(str(lineUnderCursor(editorWidget)), " " + lineWithFloat, + "Typing a float value does not trigger code completion") + triggerCompletion(editorWidget) + try: + waitForObject(":popupFrame_Proposal_QListView", 5000) + if useClang and JIRA.isBugStillOpen(16607): + test.xfail("User can trigger code completion manually in a float value") + else: + test.fail("User can trigger code completion manually in a float value") + except: + test.passes("User can't trigger code completion manually in a float value") # Step 5: From "Tools -> Options -> Text Editor -> Completion" select Activate completion Manually, # uncheck Autocomplete common prefix and press Apply and then Ok . Return to Edit mode. - test.log("Step 5: Change Code Completion settings") - changeAutocompleteToManual() + test.log("Step 5: Change Code Completion settings") + changeAutocompleteToManual() # Step 6: Insert text "ret" and press Ctrl+Space. - editorWidget = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - resetLine(editorWidget) - type(editorWidget, "retu") - triggerCompletion(editorWidget) - try: - proposal = "return" - if useClang: - # clang adds a whitespace because the function needs to return a value - proposal += " " - waitForObjectItem(":popupFrame_Proposal_QListView", proposal) - except: - test.fail("Could not find proposal popup.") - type(editorWidget, "") - type(editorWidget, "") - test.compare(str(lineUnderCursor(editorWidget)).strip(), "retu", - "Step 6: Verifying if: Suggestion is displayed but text is not " - "completed automatically even there is only one suggestion.") - invokeMenuItem('File', 'Revert "main.cpp" to Saved') - clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) - # exit qt creator - invokeMenuItem("File", "Save All") - invokeMenuItem("File", "Exit") + editorWidget = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + resetLine(editorWidget) + type(editorWidget, "retu") + triggerCompletion(editorWidget) + try: + proposal = "return" + if useClang: + # clang adds a whitespace because the function needs to return a value + proposal += " " + waitForObjectItem(":popupFrame_Proposal_QListView", proposal) + except: + test.fail("Could not find proposal popup.") + type(editorWidget, "") + type(editorWidget, "") + test.compare(str(lineUnderCursor(editorWidget)).strip(), "retu", + "Step 6: Verifying if: Suggestion is displayed but text is not " + "completed automatically even there is only one suggestion.") + invokeMenuItem('File', 'Revert "main.cpp" to Saved') + clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) + # exit qt creator + invokeMenuItem("File", "Save All") + invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_CSUP/tst_CSUP02/test.py b/tests/system/suite_CSUP/tst_CSUP02/test.py index f6563d0b7f..144f0456ed 100644 --- a/tests/system/suite_CSUP/tst_CSUP02/test.py +++ b/tests/system/suite_CSUP/tst_CSUP02/test.py @@ -28,61 +28,62 @@ source("../../shared/qtcreator.py") # entry of test def main(): for useClang in [False, True]: - if not startCreator(useClang): - continue - # create qt quick application + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + # create qt quick application # Step 1: Open test .pro project. - createNewQtQuickApplication(tempDir(), "SampleApp") - checkCodeModelSettings(useClang) + createNewQtQuickApplication(tempDir(), "SampleApp") + checkCodeModelSettings(useClang) # Step 2: Open .cpp file in Edit mode. - if not openDocument("SampleApp.Sources.main\\.cpp"): - test.fatal("Could not open main.cpp") - invokeMenuItem("File", "Exit") - return - test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), - "Step 2: Verifying if: .cpp file is opened in Edit mode.") + if not openDocument("SampleApp.Sources.main\\.cpp"): + test.fatal("Could not open main.cpp") + invokeMenuItem("File", "Exit") + return + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Step 2: Verifying if: .cpp file is opened in Edit mode.") # Steps 3&4: Insert text "class" to new line in Editor mode and press Ctrl+Space. # Focus "class derived from QObject" in the list and press Tab or Enter to complete the code. - editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton) - type(editorWidget, "") - type(editorWidget, "") - type(editorWidget, "class") - if useClang and JIRA.isBugStillOpen(18769): - snooze(4) - if platform.system() == "Darwin": - type(editorWidget, "") - else: - type(editorWidget, "") - listView = waitForObject(":popupFrame_Proposal_QListView") - shownProposals = dumpItems(listView.model()) - usedProposal = "class derived from QObject" - expectedProposals = ["class", "class ", "class template", - usedProposal, "class derived from QWidget"] - test.compare(len(shownProposals), len(expectedProposals), "Number of proposed templates") - test.compare(set(shownProposals), set(expectedProposals), - "Expected proposals shown, ignoring order?") - doubleClickItem(listView, usedProposal, 5, 5, 0, Qt.LeftButton) - pattern = ("(?<=class)\s+name\s*:\s*public\s+QObject\s*\{\s*Q_OBJECT\s+" - "public:\s+name\(\)\s*\{\}\s+virtual\s+~name\(\)\s*\{\}\s+\};") - test.verify(re.search(pattern, str(editorWidget.plainText)), - "Code with several variables is inserted?") + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton) + type(editorWidget, "") + type(editorWidget, "") + type(editorWidget, "class") + if useClang and JIRA.isBugStillOpen(18769): + snooze(4) + if platform.system() == "Darwin": + type(editorWidget, "") + else: + type(editorWidget, "") + listView = waitForObject(":popupFrame_Proposal_QListView") + shownProposals = dumpItems(listView.model()) + usedProposal = "class derived from QObject" + expectedProposals = ["class", "class ", "class template", + usedProposal, "class derived from QWidget"] + test.compare(len(shownProposals), len(expectedProposals), "Number of proposed templates") + test.compare(set(shownProposals), set(expectedProposals), + "Expected proposals shown, ignoring order?") + doubleClickItem(listView, usedProposal, 5, 5, 0, Qt.LeftButton) + pattern = ("(?<=class)\s+name\s*:\s*public\s+QObject\s*\{\s*Q_OBJECT\s+" + "public:\s+name\(\)\s*\{\}\s+virtual\s+~name\(\)\s*\{\}\s+\};") + test.verify(re.search(pattern, str(editorWidget.plainText)), + "Code with several variables is inserted?") # Step 5: Press Tab to move between the variables and specify values for them. For example write "Myname" for variable "name". - type(editorWidget, "") - type(editorWidget, "") - type(editorWidget, "") - type(editorWidget, "Myname") - result = re.search(pattern.replace("name", "Myname"), str(editorWidget.plainText)) - if result: - test.passes("Step 5: Verifying if: A value for a variable is inserted and all " - "instances of the variable within the snippet are renamed.") - else: - test.fail("Step 5: Seems that not all instances of variable had been renamed " - "- Content of editor:\n%s" % editorWidget.plainText) - invokeMenuItem('File', 'Revert "main.cpp" to Saved') - clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) - snooze(1) # 'Close "main.cpp"' might still be disabled - # editor must be closed to get the second code model applied on re-opening the file - invokeMenuItem('File', 'Close "main.cpp"') - # exit qt creator - invokeMenuItem("File", "Exit") + type(editorWidget, "") + type(editorWidget, "") + type(editorWidget, "") + type(editorWidget, "Myname") + result = re.search(pattern.replace("name", "Myname"), str(editorWidget.plainText)) + if result: + test.passes("Step 5: Verifying if: A value for a variable is inserted and all " + "instances of the variable within the snippet are renamed.") + else: + test.fail("Step 5: Seems that not all instances of variable had been renamed " + "- Content of editor:\n%s" % editorWidget.plainText) + invokeMenuItem('File', 'Revert "main.cpp" to Saved') + clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) + snooze(1) # 'Close "main.cpp"' might still be disabled + # editor must be closed to get the second code model applied on re-opening the file + invokeMenuItem('File', 'Close "main.cpp"') + # exit qt creator + invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_CSUP/tst_CSUP03/test.py b/tests/system/suite_CSUP/tst_CSUP03/test.py index ac106eb8d4..bd4478000e 100644 --- a/tests/system/suite_CSUP/tst_CSUP03/test.py +++ b/tests/system/suite_CSUP/tst_CSUP03/test.py @@ -76,44 +76,45 @@ def main(): "do while" : ["", "int dummy = 0;", "do", "++dummy;", "while (dummy < 10);"] } for useClang in [False, True]: - if not startCreator(useClang): - continue - projectName = createNewNonQtProject() - checkCodeModelSettings(useClang) - openDocument("%s.Sources.main\\.cpp" % projectName) - editor = getEditorForFileSuffix("main.cpp") - if not editor: - test.fatal("Failed to get an editor - leaving test.") - invokeMenuItem("File", "Exit") - return - - originalContent = str(editor.plainText) - for case, codeLines in code.items(): - funcSuffix = case.title().replace(" ", "") - test.log("Testing: Extract Function for '%s'" % case) - if not placeCursorToLine(editor, "{"): + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): continue - typeLines(editor, codeLines) - if not placeCursorToLine(editor, codeLines[2]): + projectName = createNewNonQtProject() + checkCodeModelSettings(useClang) + openDocument("%s.Sources.main\\.cpp" % projectName) + editor = getEditorForFileSuffix("main.cpp") + if not editor: + test.fatal("Failed to get an editor - leaving test.") + invokeMenuItem("File", "Exit") + return + + originalContent = str(editor.plainText) + for case, codeLines in code.items(): + funcSuffix = case.title().replace(" ", "") + test.log("Testing: Extract Function for '%s'" % case) + if not placeCursorToLine(editor, "{"): + continue + typeLines(editor, codeLines) + if not placeCursorToLine(editor, codeLines[2]): + revertMainCpp() + continue + type(editor, home) + markText(editor, "Right", 2) + snooze(1) # avoid timing issue with the parser + invokeContextMenuItem(editor, 'Refactor', 'Extract Function') + funcEdit = waitForObject("{buddy={text='Function name' type='QLabel' unnamed='1' " + "visible='1' window=%s} type='Utils::FancyLineEdit' " + "unnamed='1' visible='1'}" % inputDialog) + replaceEditorContent(funcEdit, "myFunc%s" % funcSuffix) + clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" + % inputDialog)) + waitFor("'void myFunc%s' in str(editor.plainText)" % funcSuffix, 2500) + # verify the change + modifiedCode = str(editor.plainText) + expectedCode = constructExpectedCode(originalContent, codeLines, funcSuffix) + test.compare(modifiedCode, expectedCode, "Verifying whether code matches expected.") + # reverting to initial state of main.cpp revertMainCpp() - continue - type(editor, home) - markText(editor, "Right", 2) - snooze(1) # avoid timing issue with the parser - invokeContextMenuItem(editor, 'Refactor', 'Extract Function') - funcEdit = waitForObject("{buddy={text='Function name' type='QLabel' unnamed='1' " - "visible='1' window=%s} type='Utils::FancyLineEdit' " - "unnamed='1' visible='1'}" % inputDialog) - replaceEditorContent(funcEdit, "myFunc%s" % funcSuffix) - clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" - % inputDialog)) - waitFor("'void myFunc%s' in str(editor.plainText)" % funcSuffix, 2500) - # verify the change - modifiedCode = str(editor.plainText) - expectedCode = constructExpectedCode(originalContent, codeLines, funcSuffix) - test.compare(modifiedCode, expectedCode, "Verifying whether code matches expected.") - # reverting to initial state of main.cpp - revertMainCpp() - snooze(1) # "Close All" might be disabled - invokeMenuItem('File', 'Close All') - invokeMenuItem('File', 'Exit') + snooze(1) # "Close All" might be disabled + invokeMenuItem('File', 'Close All') + invokeMenuItem('File', 'Exit') diff --git a/tests/system/suite_CSUP/tst_CSUP04/test.py b/tests/system/suite_CSUP/tst_CSUP04/test.py index 482a616f6d..a933ea5921 100644 --- a/tests/system/suite_CSUP/tst_CSUP04/test.py +++ b/tests/system/suite_CSUP/tst_CSUP04/test.py @@ -36,41 +36,42 @@ def main(): templateDir = prepareTemplate(sourceExample) examplePath = os.path.join(templateDir, proFile) for useClang in [False, True]: - if not startCreator(useClang): - continue - # open example project - openQmakeProject(examplePath) - # wait for parsing to complete - progressBarWait(30000) - checkCodeModelSettings(useClang) - # open .cpp file in editor - if not openDocument("property-animation.Sources.main\\.cpp"): - test.fatal("Could not open main.cpp") + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + # open example project + openQmakeProject(examplePath) + # wait for parsing to complete + progressBarWait(30000) + checkCodeModelSettings(useClang) + # open .cpp file in editor + if not openDocument("property-animation.Sources.main\\.cpp"): + test.fatal("Could not open main.cpp") + invokeMenuItem("File", "Exit") + return + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Verifying if: .cpp file is opened in Edit mode.") + # place cursor on line "QmlApplicationViewer viewer;" + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + # invoke find usages from context menu on word "viewer" + if not invokeFindUsage(editorWidget, "QmlApplicationViewer viewer;", "", 10): + invokeMenuItem("File", "Exit") + return + # wait until search finished and verify search results + waitForSearchResults() + validateSearchResult(21) + result = re.search("QmlApplicationViewer", str(editorWidget.plainText)) + test.verify(result, "Verifying if: The list of all usages of the selected text is displayed in Search Results. " + "File with used text is opened.") + # move cursor to the other word and test Find Usages function by pressing Ctrl+Shift+U. + openDocument("property-animation.Sources.main\\.cpp") + if not placeCursorToLine(editorWidget, "viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);"): + return + for i in range(4): + type(editorWidget, "") + type(editorWidget, "") + # wait until search finished and verify search results + waitForSearchResults() + validateSearchResult(3) + invokeMenuItem("File", "Close All") invokeMenuItem("File", "Exit") - return - test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), - "Verifying if: .cpp file is opened in Edit mode.") - # place cursor on line "QmlApplicationViewer viewer;" - editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - # invoke find usages from context menu on word "viewer" - if not invokeFindUsage(editorWidget, "QmlApplicationViewer viewer;", "", 10): - invokeMenuItem("File", "Exit") - return - # wait until search finished and verify search results - waitForSearchResults() - validateSearchResult(21) - result = re.search("QmlApplicationViewer", str(editorWidget.plainText)) - test.verify(result, "Verifying if: The list of all usages of the selected text is displayed in Search Results. " - "File with used text is opened.") - # move cursor to the other word and test Find Usages function by pressing Ctrl+Shift+U. - openDocument("property-animation.Sources.main\\.cpp") - if not placeCursorToLine(editorWidget, "viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);"): - return - for i in range(4): - type(editorWidget, "") - type(editorWidget, "") - # wait until search finished and verify search results - waitForSearchResults() - validateSearchResult(3) - invokeMenuItem("File", "Close All") - invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_CSUP/tst_CSUP05/test.py b/tests/system/suite_CSUP/tst_CSUP05/test.py index 3b9409c56c..2a4e64fcc0 100644 --- a/tests/system/suite_CSUP/tst_CSUP05/test.py +++ b/tests/system/suite_CSUP/tst_CSUP05/test.py @@ -36,59 +36,60 @@ def main(): templateDir = prepareTemplate(sourceExample) examplePath = os.path.join(templateDir, proFile) for useClang in [False, True]: - if not startCreator(useClang): - continue - # open example project - openQmakeProject(examplePath) - # wait for parsing to complete - progressBarWait(30000) - checkCodeModelSettings(useClang) - # open .cpp file in editor - if not openDocument("property-animation.Sources.main\\.cpp"): - test.fatal("Could not open main.cpp") - invokeMenuItem("File", "Exit") - return - test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), - "Verifying if: .cpp file is opened in Edit mode.") - # select some word for example "viewer" and press Ctrl+F. - editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - if not placeCursorToLine(editorWidget, "QmlApplicationViewer viewer;"): - invokeMenuItem("File", "Exit") - return - type(editorWidget, "") - markText(editorWidget, "Left", 6) - type(editorWidget, "") - # verify if find toolbar exists and if search text contains selected word - test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"), - "Verifying if: Find/Replace pane is displayed at the bottom of the view.") - test.compare(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit").displayText, "viewer", - "Verifying if: Find line edit contains 'viewer' text.") - # insert some word to "Replace with:" field and select "Replace All". - replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "find") - oldCodeText = str(editorWidget.plainText) - clickButton(waitForObject(":Qt Creator.Replace All_QToolButton")) - mouseClick(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), 5, 5, 0, Qt.LeftButton) - newCodeText = str(editorWidget.plainText) - test.compare(newCodeText, oldCodeText.replace("viewer", "find").replace("Viewer", "find"), - "Verifying if: Found text is replaced with new word properly.") - # select some other word in .cpp file and select "Edit" -> "Find/Replace". - clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) - placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);") - for i in range(25): + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + # open example project + openQmakeProject(examplePath) + # wait for parsing to complete + progressBarWait(30000) + checkCodeModelSettings(useClang) + # open .cpp file in editor + if not openDocument("property-animation.Sources.main\\.cpp"): + test.fatal("Could not open main.cpp") + invokeMenuItem("File", "Exit") + return + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Verifying if: .cpp file is opened in Edit mode.") + # select some word for example "viewer" and press Ctrl+F. + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + if not placeCursorToLine(editorWidget, "QmlApplicationViewer viewer;"): + invokeMenuItem("File", "Exit") + return type(editorWidget, "") - markText(editorWidget, "Left", 18) - invokeMenuItem("Edit", "Find/Replace", "Find/Replace") - replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer") - oldCodeText = str(editorWidget.plainText) - clickButton(waitForObject(":Qt Creator.Replace_QToolButton")) - newCodeText = str(editorWidget.plainText) - # "::" is used to replace only one occurrence by python - test.compare(newCodeText, oldCodeText.replace("QmlApplicationfind::", "QmlApplicationViewer::"), - "Verifying if: Only selected word is replaced, the rest of found words are not replaced.") - # close Find/Replace tab. - clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) - test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar", False), - "Verifying if: Find/Replace tab is closed.") - invokeMenuItem("File", "Close All") - clickButton(waitForObject(":Save Changes.Do not Save_QPushButton")) - invokeMenuItem("File", "Exit") + markText(editorWidget, "Left", 6) + type(editorWidget, "") + # verify if find toolbar exists and if search text contains selected word + test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"), + "Verifying if: Find/Replace pane is displayed at the bottom of the view.") + test.compare(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit").displayText, "viewer", + "Verifying if: Find line edit contains 'viewer' text.") + # insert some word to "Replace with:" field and select "Replace All". + replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "find") + oldCodeText = str(editorWidget.plainText) + clickButton(waitForObject(":Qt Creator.Replace All_QToolButton")) + mouseClick(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), 5, 5, 0, Qt.LeftButton) + newCodeText = str(editorWidget.plainText) + test.compare(newCodeText, oldCodeText.replace("viewer", "find").replace("Viewer", "find"), + "Verifying if: Found text is replaced with new word properly.") + # select some other word in .cpp file and select "Edit" -> "Find/Replace". + clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) + placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);") + for i in range(25): + type(editorWidget, "") + markText(editorWidget, "Left", 18) + invokeMenuItem("Edit", "Find/Replace", "Find/Replace") + replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer") + oldCodeText = str(editorWidget.plainText) + clickButton(waitForObject(":Qt Creator.Replace_QToolButton")) + newCodeText = str(editorWidget.plainText) + # "::" is used to replace only one occurrence by python + test.compare(newCodeText, oldCodeText.replace("QmlApplicationfind::", "QmlApplicationViewer::"), + "Verifying if: Only selected word is replaced, the rest of found words are not replaced.") + # close Find/Replace tab. + clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) + test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar", False), + "Verifying if: Find/Replace tab is closed.") + invokeMenuItem("File", "Close All") + clickButton(waitForObject(":Save Changes.Do not Save_QPushButton")) + invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_CSUP/tst_CSUP06/test.py b/tests/system/suite_CSUP/tst_CSUP06/test.py index 2ab54ca4bf..f703669755 100644 --- a/tests/system/suite_CSUP/tst_CSUP06/test.py +++ b/tests/system/suite_CSUP/tst_CSUP06/test.py @@ -162,20 +162,21 @@ def main(): templateDir = prepareTemplate(examplePath) examplePath = os.path.join(templateDir, "cplusplus-tools.pro") for useClang in [False, True]: - if not startCreator(useClang): - continue - openQmakeProject(examplePath, [Targets.DESKTOP_531_DEFAULT]) - checkCodeModelSettings(useClang) - if not openDocument("cplusplus-tools.Sources.main\\.cpp"): - earlyExit("Failed to open main.cpp.") - return - editor = getEditorForFileSuffix("main.cpp") - if editor: - checkIncludeCompletion(editor, useClang) - checkSymbolCompletion(editor, useClang) - invokeMenuItem('File', 'Revert "main.cpp" to Saved') - clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) - snooze(1) # 'Close "main.cpp"' might still be disabled - # editor must be closed to get the second code model applied on re-opening the file - invokeMenuItem('File', 'Close "main.cpp"') - invokeMenuItem("File", "Exit") + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + openQmakeProject(examplePath, [Targets.DESKTOP_531_DEFAULT]) + checkCodeModelSettings(useClang) + if not openDocument("cplusplus-tools.Sources.main\\.cpp"): + earlyExit("Failed to open main.cpp.") + return + editor = getEditorForFileSuffix("main.cpp") + if editor: + checkIncludeCompletion(editor, useClang) + checkSymbolCompletion(editor, useClang) + invokeMenuItem('File', 'Revert "main.cpp" to Saved') + clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) + snooze(1) # 'Close "main.cpp"' might still be disabled + # editor must be closed to get the second code model applied on re-opening the file + invokeMenuItem('File', 'Close "main.cpp"') + invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_editors/tst_memberoperator/test.py b/tests/system/suite_editors/tst_memberoperator/test.py index 7efeb4e91f..1b7087329c 100644 --- a/tests/system/suite_editors/tst_memberoperator/test.py +++ b/tests/system/suite_editors/tst_memberoperator/test.py @@ -27,29 +27,30 @@ source("../../shared/qtcreator.py") def main(): for useClang in [False, True]: - if not startCreator(useClang): - continue - createProject_Qt_Console(tempDir(), "SquishProject") - checkCodeModelSettings(useClang) - selectFromLocator("main.cpp") - cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + with TestSection(getCodeModelString(useClang)): + if not startCreator(useClang): + continue + createProject_Qt_Console(tempDir(), "SquishProject") + checkCodeModelSettings(useClang) + selectFromLocator("main.cpp") + cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - for record in testData.dataset("usages.tsv"): - include = testData.field(record, "include") - if include: - placeCursorToLine(cppwindow, "#include ") - typeLines(cppwindow, ("", "#include " + include)) - placeCursorToLine(cppwindow, "return a.exec();") - typeLines(cppwindow, ("", testData.field(record, "declaration"))) - type(cppwindow, testData.field(record, "usage")) - snooze(1) # maybe find something better - type(cppwindow, testData.field(record, "operator")) - waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 1500) - found = str(lineUnderCursor(cppwindow)).strip() - exp = testData.field(record, "expected") - test.compare(found, exp) - invokeMenuItem("File", 'Revert "main.cpp" to Saved') - clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) - snooze(1) - invokeMenuItem("File", "Close All") - invokeMenuItem("File", "Exit") + for record in testData.dataset("usages.tsv"): + include = testData.field(record, "include") + if include: + placeCursorToLine(cppwindow, "#include ") + typeLines(cppwindow, ("", "#include " + include)) + placeCursorToLine(cppwindow, "return a.exec();") + typeLines(cppwindow, ("", testData.field(record, "declaration"))) + type(cppwindow, testData.field(record, "usage")) + snooze(1) # maybe find something better + type(cppwindow, testData.field(record, "operator")) + waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 1500) + found = str(lineUnderCursor(cppwindow)).strip() + exp = testData.field(record, "expected") + test.compare(found, exp) + invokeMenuItem("File", 'Revert "main.cpp" to Saved') + clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton")) + snooze(1) + invokeMenuItem("File", "Close All") + invokeMenuItem("File", "Exit") -- cgit v1.2.1