forked from qt-creator/qt-creator
Squish: Update tests using clang code model
Code models can't be swapped at runtime anymore. Change-Id: I76a9894d0413d7d5a368ec6d506180a3837a6e2c Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -213,7 +213,6 @@
|
||||
:Working Copy_Utils::BaseValidatingLineEdit {type='Utils::FancyLineEdit' unnamed='1' visible='1' window=':New Text File_ProjectExplorer::JsonWizard'}
|
||||
:WritePermissions_Core::Internal::ReadOnlyFilesDialog {name='Core__Internal__ReadOnlyFilesDialog' type='Core::ReadOnlyFilesDialog' visible='1' windowTitle='Files Without Write Permissions'}
|
||||
:addToVersionControlComboBox_QComboBox {name='addToVersionControlComboBox' type='QComboBox' visible='1'}
|
||||
:clangSettingsGroupBox_QGroupBox {container=':qt_tabwidget_stackedwidget_QScrollArea' name='clangSettingsGroupBox' type='QGroupBox' visible='1'}
|
||||
:formFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Form file:_QLabel' name='formFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'}
|
||||
:frame.templateDescription_QTextBrowser {container=':New.frame_QFrame' name='templateDescription' type='QTextBrowser' visible='1'}
|
||||
:headerFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Header file:_QLabel' name='headerFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'}
|
||||
|
||||
@@ -24,22 +24,27 @@
|
||||
############################################################################
|
||||
|
||||
def startCreatorTryingClang():
|
||||
try:
|
||||
# start Qt Creator with enabled ClangCodeModel plugin (without modifying settings)
|
||||
startApplication("qtcreator -load ClangCodeModel" + SettingsPath)
|
||||
errorMsg = "{type='QMessageBox' unnamed='1' visible='1' windowTitle='Qt Creator'}"
|
||||
errorOK = "{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" % errorMsg
|
||||
if waitFor("object.exists(errorOK)", 5000):
|
||||
clickButton(errorOK) # Error message
|
||||
clickButton(errorOK) # Help message
|
||||
raise Exception("ClangCodeModel not found.")
|
||||
# start Qt Creator with enabled ClangCodeModel plugin (without modifying settings)
|
||||
startApplication("qtcreator -load ClangCodeModel" + SettingsPath)
|
||||
errorMsg = "{type='QMessageBox' unnamed='1' visible='1' windowTitle='Qt Creator'}"
|
||||
errorOK = "{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" % errorMsg
|
||||
if not waitFor("object.exists(errorOK)", 5000):
|
||||
return True
|
||||
except:
|
||||
# ClangCodeModel plugin has not been built - start without it
|
||||
test.warning("ClangCodeModel plugin not available - performing test without.")
|
||||
clickButton(errorOK) # Error message
|
||||
clickButton(errorOK) # Help message
|
||||
test.fatal("ClangCodeModel plugin not available.")
|
||||
return False
|
||||
|
||||
def startCreator(useClang):
|
||||
try:
|
||||
if useClang:
|
||||
if not startCreatorTryingClang():
|
||||
return False
|
||||
else:
|
||||
startApplication("qtcreator" + SettingsPath)
|
||||
finally:
|
||||
overrideStartApplication()
|
||||
startApplication("qtcreator" + SettingsPath)
|
||||
return False
|
||||
return startedWithoutPluginError()
|
||||
|
||||
def __openCodeModelOptions__():
|
||||
invokeMenuItem("Tools", "Options...")
|
||||
@@ -47,14 +52,12 @@ def __openCodeModelOptions__():
|
||||
clickItem(":Options_QListView", "C++", 14, 15, 0, Qt.LeftButton)
|
||||
clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Code Model")
|
||||
|
||||
def selectClangCodeModel(clangLoaded, enable):
|
||||
def checkCodeModelSettings(useClang):
|
||||
codeModelName = "built-in"
|
||||
if clangLoaded and enable:
|
||||
if useClang:
|
||||
codeModelName = "Clang"
|
||||
test.log("Testing code model: %s" % codeModelName)
|
||||
__openCodeModelOptions__()
|
||||
if clangLoaded:
|
||||
ensureChecked(":clangSettingsGroupBox_QGroupBox", enable)
|
||||
test.verify(verifyChecked("{name='ignorePCHCheckBox' type='QCheckBox' visible='1'}"),
|
||||
"Verifying whether 'Ignore pre-compiled headers' is checked by default.")
|
||||
clickButton(waitForObject(":Options.OK_QPushButton"))
|
||||
|
||||
@@ -43,14 +43,13 @@ def triggerCompletion(editorWidget):
|
||||
|
||||
# entry of test
|
||||
def main():
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
# create qt quick application
|
||||
for useClang in [False, True]:
|
||||
if not startCreator(useClang):
|
||||
continue
|
||||
# create qt quick application
|
||||
# Step 1: Open test .pro project.
|
||||
createNewQtQuickApplication(tempDir(), "SampleApp")
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
createNewQtQuickApplication(tempDir(), "SampleApp")
|
||||
checkCodeModelSettings(useClang)
|
||||
changeAutocompleteToManual(False)
|
||||
# Step 2: Open .cpp file in Edit mode.
|
||||
if not openDocument("SampleApp.Sources.main\\.cpp"):
|
||||
@@ -103,6 +102,6 @@ def main():
|
||||
"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")
|
||||
# exit qt creator
|
||||
invokeMenuItem("File", "Save All")
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
@@ -27,14 +27,13 @@ source("../../shared/qtcreator.py")
|
||||
|
||||
# entry of test
|
||||
def main():
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
# create qt quick application
|
||||
for useClang in [False, True]:
|
||||
if not startCreator(useClang):
|
||||
continue
|
||||
# create qt quick application
|
||||
# Step 1: Open test .pro project.
|
||||
createNewQtQuickApplication(tempDir(), "SampleApp")
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, 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")
|
||||
@@ -83,5 +82,5 @@ def main():
|
||||
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")
|
||||
# exit qt creator
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
@@ -61,10 +61,6 @@ def constructExpectedCode(original, codeLines, funcSuffix):
|
||||
return "\n".join(tmp) + "\n"
|
||||
|
||||
def main():
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
projectName = createNewNonQtProject()
|
||||
if platform.system() == 'Darwin':
|
||||
home = '<Ctrl+Left>'
|
||||
else:
|
||||
@@ -79,8 +75,11 @@ def main():
|
||||
"while with braces" : ["", "int dummy = 0;", "while (dummy < 10) {", "++dummy;"],
|
||||
"do while" : ["", "int dummy = 0;", "do", "++dummy;", "while (dummy < 10);"]
|
||||
}
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
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:
|
||||
@@ -117,5 +116,4 @@ def main():
|
||||
revertMainCpp()
|
||||
snooze(1) # "Close All" might be disabled
|
||||
invokeMenuItem('File', 'Close All')
|
||||
|
||||
invokeMenuItem('File', 'Exit')
|
||||
invokeMenuItem('File', 'Exit')
|
||||
|
||||
@@ -35,15 +35,14 @@ def main():
|
||||
# copy example project to temp directory
|
||||
templateDir = prepareTemplate(sourceExample)
|
||||
examplePath = os.path.join(templateDir, proFile)
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
# open example project
|
||||
openQmakeProject(examplePath)
|
||||
# wait for parsing to complete
|
||||
progressBarWait(30000)
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
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("propertyanimation.Sources.main\\.cpp"):
|
||||
test.fatal("Could not open main.cpp")
|
||||
@@ -74,4 +73,4 @@ def main():
|
||||
waitForSearchResults()
|
||||
validateSearchResult(3)
|
||||
invokeMenuItem("File", "Close All")
|
||||
invokeMenuItem("File", "Exit")
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
@@ -35,15 +35,14 @@ def main():
|
||||
# copy example project to temp directory
|
||||
templateDir = prepareTemplate(sourceExample)
|
||||
examplePath = os.path.join(templateDir, proFile)
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
# open example project
|
||||
openQmakeProject(examplePath)
|
||||
# wait for parsing to complete
|
||||
progressBarWait(30000)
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
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("propertyanimation.Sources.main\\.cpp"):
|
||||
test.fatal("Could not open main.cpp")
|
||||
@@ -92,4 +91,4 @@ def main():
|
||||
"Verifying if: Find/Replace tab is closed.")
|
||||
invokeMenuItem("File", "Close All")
|
||||
clickButton(waitForObject(":Save Changes.Do not Save_QPushButton"))
|
||||
invokeMenuItem("File", "Exit")
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
@@ -161,21 +161,13 @@ def main():
|
||||
examplePath = os.path.join(srcPath, "creator", "tests", "manual", "cplusplus-tools")
|
||||
if not neededFilePresent(os.path.join(examplePath, "cplusplus-tools.pro")):
|
||||
return
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
|
||||
templateDir = prepareTemplate(examplePath)
|
||||
examplePath = os.path.join(templateDir, "cplusplus-tools.pro")
|
||||
openQmakeProject(examplePath, Targets.DESKTOP_531_DEFAULT)
|
||||
__openCodeModelOptions__()
|
||||
clangSettingsGroupBox = findObject(":clangSettingsGroupBox_QGroupBox")
|
||||
test.compare(clangSettingsGroupBox.enabled, clangLoaded, "Verifying number of available code models")
|
||||
test.verify(not clangSettingsGroupBox.checked,
|
||||
"Verifying whether default is Qt Creator's builtin code model")
|
||||
clickButton(waitForObject(":Options.Cancel_QPushButton"))
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
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
|
||||
@@ -188,5 +180,4 @@ def main():
|
||||
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")
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
@@ -26,12 +26,11 @@
|
||||
source("../../shared/qtcreator.py")
|
||||
|
||||
def main():
|
||||
clangLoaded = startCreatorTryingClang()
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
createProject_Qt_Console(tempDir(), "SquishProject")
|
||||
for useClang in set([False, clangLoaded]):
|
||||
selectClangCodeModel(clangLoaded, useClang)
|
||||
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")
|
||||
|
||||
@@ -44,17 +43,15 @@ def main():
|
||||
typeLines(cppwindow, ("<Up>", testData.field(record, "declaration")))
|
||||
type(cppwindow, testData.field(record, "usage"))
|
||||
snooze(1) # maybe find something better
|
||||
if useClang:
|
||||
snooze(1) # QTCREATORBUG-15639
|
||||
type(cppwindow, testData.field(record, "operator"))
|
||||
waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 1500)
|
||||
found = str(lineUnderCursor(cppwindow)).strip()
|
||||
exp = testData.field(record, "expected")
|
||||
if useClang and exp[-2:] == "->":
|
||||
test.xcompare(found, exp) # QTCREATORBUG-11581
|
||||
else:
|
||||
test.compare(found, exp)
|
||||
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")
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
||||
Reference in New Issue
Block a user