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
|
2013-05-15 13:17:33 +02:00
|
|
|
|
2012-04-23 13:17:40 +02:00
|
|
|
source("../../shared/qtcreator.py")
|
|
|
|
|
|
|
|
|
|
# entry of test
|
|
|
|
|
def main():
|
|
|
|
|
# prepare example project
|
2020-02-06 21:05:01 +01:00
|
|
|
sourceExample = os.path.join(Qt5Path.examplesPath(Targets.DESKTOP_5_14_1_DEFAULT),
|
2018-02-20 13:59:35 +01:00
|
|
|
"gui", "openglwindow")
|
|
|
|
|
proFile = "openglwindow.pro"
|
|
|
|
|
|
2012-09-27 15:05:38 +02:00
|
|
|
if not neededFilePresent(os.path.join(sourceExample, proFile)):
|
2012-04-23 13:17:40 +02:00
|
|
|
return
|
|
|
|
|
# copy example project to temp directory
|
|
|
|
|
templateDir = prepareTemplate(sourceExample)
|
2012-09-27 15:05:38 +02:00
|
|
|
examplePath = os.path.join(templateDir, proFile)
|
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
|
|
|
|
|
# open example project
|
|
|
|
|
openQmakeProject(examplePath)
|
|
|
|
|
# wait for parsing to complete
|
2019-08-16 08:36:52 +02:00
|
|
|
waitForProjectParsing()
|
2017-09-01 15:23:34 +02:00
|
|
|
checkCodeModelSettings(useClang)
|
|
|
|
|
# open .cpp file in editor
|
2018-02-20 13:59:35 +01:00
|
|
|
if not openDocument("openglwindow.Sources.main\\.cpp"):
|
2017-09-01 15:23:34 +02:00
|
|
|
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.")
|
|
|
|
|
editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
|
2019-05-20 18:23:21 +02:00
|
|
|
# place cursor on line "class TriangleWindow : public OpenGLWindow"
|
|
|
|
|
# invoke find usages from context menu on word "OpenGLWindow"
|
2018-02-20 13:59:35 +01:00
|
|
|
if not invokeFindUsage(editorWidget, "class TriangleWindow : public OpenGLWindow",
|
|
|
|
|
"<Left>"):
|
2017-09-01 15:23:34 +02:00
|
|
|
invokeMenuItem("File", "Exit")
|
|
|
|
|
return
|
|
|
|
|
# wait until search finished and verify search results
|
|
|
|
|
waitForSearchResults()
|
2018-02-20 13:59:35 +01:00
|
|
|
validateSearchResult(16)
|
|
|
|
|
result = re.search("OpenGLWindow", str(editorWidget.plainText))
|
2017-09-01 15:23:34 +02:00
|
|
|
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.
|
2018-02-20 13:59:35 +01:00
|
|
|
openDocument("openglwindow.Sources.main\\.cpp")
|
|
|
|
|
if not placeCursorToLine(editorWidget, 'm_posAttr = m_program->attributeLocation("posAttr");'):
|
2017-09-01 15:23:34 +02:00
|
|
|
return
|
2018-08-02 13:45:34 +02:00
|
|
|
for _ in range(13):
|
2017-09-01 15:23:34 +02:00
|
|
|
type(editorWidget, "<Left>")
|
|
|
|
|
type(editorWidget, "<Ctrl+Shift+u>")
|
|
|
|
|
# wait until search finished and verify search results
|
|
|
|
|
waitForSearchResults()
|
2022-11-01 14:37:58 +01:00
|
|
|
validateSearchResult(3 if useClang else 5)
|
2014-09-25 12:13:23 +02:00
|
|
|
invokeMenuItem("File", "Exit")
|
2018-09-07 08:26:01 +02:00
|
|
|
waitForCleanShutdown()
|