2016-01-15 14:55:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Copyright (C) 2016 The Qt Company Ltd.
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-21 10:12:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								source("../../shared/qtcreator.py")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def moveDownToNextNonEmptyLine(editor):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    currentLine = "" # there's no do-while in python - so use empty line which fails
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    while not currentLine:
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-21 15:17:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if waitFor("object.exists(':Utils::FakeToolTip')", 100):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            type(editor, "<Esc>")   # close possibly shown completion tooltip so pressing
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, "<Down>")      # down scrolls the line, not completion alternatives
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        currentLine = str(lineUnderCursor(editor)).strip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return currentLine
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def performAutoCompletionTest(editor, lineToStartRegEx, linePrefix, testFunc, *funcArgs):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if platform.system() == "Darwin":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        bol = "<Ctrl+Left>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        eol = "<Ctrl+Right>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        autoComp = "<Meta+Space>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        bol = "<Home>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        eol = "<End>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        autoComp = "<Ctrl+Space>"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not placeCursorToLine(editor, lineToStartRegEx, True):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    type(editor, bol)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # place cursor onto the first statement to be tested
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    while not str(lineUnderCursor(editor)).strip().startswith(linePrefix):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, "<Down>")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    currentLine = str(lineUnderCursor(editor)).strip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    while currentLine.startswith(linePrefix):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, eol)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, "<Ctrl+/>")      # uncomment current line
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-06 18:18:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, autoComp)        # invoke auto-completion
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        testFunc(currentLine, *funcArgs)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, "<Ctrl+/>")      # comment current line again
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        type(editor, bol)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        currentLine = moveDownToNextNonEmptyLine(editor)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-30 13:32:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def checkIncludeCompletion(editor, isClangCodeModel):
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    test.log("Check auto-completion of include statements.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # define special handlings
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    noProposal = []
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    specialHandling = {"ios":"iostream", "cstd":"cstdio"}
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if isClangCodeModel:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        specialHandling["QDe"] = "QDebug"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for i in specialHandling.keys():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            specialHandling[i] = " %s>" % specialHandling[i]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        noProposal += ["detail/hea"]
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # define test function to perform the _real_ auto completion test on the current line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def testIncl(currentLine, *args):
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-20 12:06:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        noProposal, specialHandling = args
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        inclSnippet = currentLine.split("//#include")[-1].strip().strip('<"')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        propShown = waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 2500)
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-20 12:06:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.compare(not propShown, inclSnippet in noProposal,
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-10 18:16:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     "Proposal widget is (not) shown as expected (%s)" % inclSnippet)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if propShown:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            proposalListView = waitForObject(':popupFrame_Proposal_QListView')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if inclSnippet in specialHandling:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                doubleClickItem(':popupFrame_Proposal_QListView', specialHandling[inclSnippet],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                5, 5, 0, Qt.LeftButton)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                type(proposalListView, "<Return>")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        changedLine = str(lineUnderCursor(editor)).strip()
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-20 12:06:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.verify(changedLine[-1] in '>"/',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    "'%s' has been completed to '%s'" % (currentLine.lstrip("/"), changedLine))
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    performAutoCompletionTest(editor, ".*Complete includes.*", "//#include",
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-20 12:06:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                              testIncl, noProposal, specialHandling)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def checkSymbolCompletion(editor, isClangCodeModel):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    test.log("Check auto-completion of symbols.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # define special handlings
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expectedSuggestion = {"in":["internal", "int", "intmax_t"],
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          "Dum":["Dummy", "dummy"], "Dummy::O":["ONE","one"],
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                          "dummy.":["one", "ONE", "PI", "v1", "v2", "v3"],
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          "dummy.o":["one", "ONE"], "Dummy::In":["Internal", "INT"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          "Dummy::Internal::":["DOUBLE", "one"]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          }
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-30 22:03:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    missing = ["Dummy::s", "Dummy::P", "dummy.b", "dummy.bla(", "internal.o", "freefunc2"]
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expectedResults = {"Dummy::s":"Dummy::sfunc()",
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       "Dummy::P":"Dummy::PI", "dummy.b":"dummy.bla(", "dummy.bla(":"dummy.bla(",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       "internal.o":"internal.one", "freefunc2":"freefunc2(",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       "using namespace st":"using namespace std", "afun":"afunc()"}
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-19 16:20:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if isClangCodeModel:
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-05 09:43:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        missing = ["dummy.bla(", "freefunc2("]
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expectedSuggestion["internal.o"] = ["one"]
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-16 12:34:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if platform.system() in ('Microsoft', 'Windows'):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            expectedSuggestion["using namespace st"] = ["std", "stdext"]
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-19 16:20:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            expectedSuggestion["using namespace st"] = ["std", "struct", "struct template"]
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-19 16:20:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expectedSuggestion["using namespace st"] = ["std", "st"]
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # define test function to perform the _real_ auto completion test on the current line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def testSymb(currentLine, *args):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        missing, expectedSug, expectedRes = args
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        symbol = currentLine.lstrip("/").strip()
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-08 14:34:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        timeout = 2500
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        propShown = waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", timeout)
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-10 18:16:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.compare(not propShown, symbol in missing,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     "Proposal widget is (not) shown as expected (%s)" % symbol)
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-18 18:10:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        found = []
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if propShown:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            proposalListView = waitForObject(':popupFrame_Proposal_QListView')
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            found = [i.strip() for i in dumpItems(proposalListView.model())]
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            diffShownExp = set(expectedSug.get(symbol, [])) - set(found)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if not test.verify(len(diffShownExp) == 0,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                               "Verify if all expected suggestions could be found"):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                test.log("Expected but not found suggestions: %s" % diffShownExp,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                         "%s | %s" % (expectedSug[symbol], str(found)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            # select first item of the expected suggestion list
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            suggestionToClick = expectedSug.get(symbol, found)[0]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if isClangCodeModel:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                suggestionToClick = " " + suggestionToClick
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            doubleClickItem(':popupFrame_Proposal_QListView', suggestionToClick,
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                            5, 5, 0, Qt.LeftButton)
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-05 09:43:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        try:
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-10 10:50:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            multiSuggestionToolTip = waitForObject(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                "{leftWidget={text~='[0-9]+ of [0-9]+' type='QLabel'} type='QToolButton'}", 1000)
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-05 09:43:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if multiSuggestionToolTip is not None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                test.log("Closing tooltip containing overloaded function completion.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                type(editor, "<Esc>")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        except LookupError: # no proposal or tool tip for unambiguous stuff - direct completion
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            pass
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        changedLine = str(lineUnderCursor(editor)).strip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if symbol in expectedRes:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            exp = expectedRes[symbol]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            exp = (symbol[:max(symbol.rfind(":"), symbol.rfind(".")) + 1]
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                   + expectedSug.get(symbol, found)[0]).strip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.compare(changedLine, exp, "Verify completion matches.")
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-11 15:55:13 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    performAutoCompletionTest(editor, ".*Complete symbols.*", "//",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                              testSymb, missing, expectedSuggestion, expectedResults)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def main():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    examplePath = os.path.join(srcPath, "creator", "tests", "manual", "cplusplus-tools")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not neededFilePresent(os.path.join(examplePath, "cplusplus-tools.pro")):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    templateDir = prepareTemplate(examplePath)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    examplePath = os.path.join(templateDir, "cplusplus-tools.pro")
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-26 13:55:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for useClang in [False, True]:
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-01 15:23:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        with TestSection(getCodeModelString(useClang)):
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-22 14:37:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if not startCreatorVerifyingClang(useClang):
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-01 15:23:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-06 21:05:01 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            openQmakeProject(examplePath, [Targets.DESKTOP_5_14_1_DEFAULT])
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-01 15:23:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            checkCodeModelSettings(useClang)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if not openDocument("cplusplus-tools.Sources.main\\.cpp"):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                earlyExit("Failed to open main.cpp.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            editor = getEditorForFileSuffix("main.cpp")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if editor:
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-07 01:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                if useClang:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    test.log("Wait for parsing to finish...")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    progressBarWait(15000)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    test.log("Parsing done.")
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-01 15:23:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                checkIncludeCompletion(editor, useClang)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                checkSymbolCompletion(editor, useClang)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                invokeMenuItem('File', 'Revert "main.cpp" to Saved')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            invokeMenuItem("File", "Exit")
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-07 08:26:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            waitForCleanShutdown()
							 |