From 66e7b77d88eb83ef32896da7e23908fc704a1b66 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 1 Dec 2015 14:05:49 +0100 Subject: [PATCH] Squish: Update selection of code model Change-Id: Iee76086dfd886dd8d61db3cfe4600a5eedd36cb7 Reviewed-by: Christian Stenger --- tests/system/objects.map | 1 + tests/system/shared/clang.py | 30 +++++-------------- tests/system/shared/utils.py | 2 +- tests/system/suite_CSUP/tst_CSUP02/test.py | 7 ++--- tests/system/suite_CSUP/tst_CSUP03/test.py | 9 ++---- tests/system/suite_CSUP/tst_CSUP04/test.py | 9 ++---- tests/system/suite_CSUP/tst_CSUP05/test.py | 9 ++---- tests/system/suite_CSUP/tst_CSUP06/test.py | 20 ++++++------- .../suite_editors/tst_memberoperator/test.py | 11 +++---- 9 files changed, 33 insertions(+), 65 deletions(-) diff --git a/tests/system/objects.map b/tests/system/objects.map index 6e2c0b0b68b..294d54ac578 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -212,6 +212,7 @@ :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'} diff --git a/tests/system/shared/clang.py b/tests/system/shared/clang.py index b54eea6c498..4ed6e961df7 100644 --- a/tests/system/shared/clang.py +++ b/tests/system/shared/clang.py @@ -51,30 +51,14 @@ def __openCodeModelOptions__(): clickItem(":Options_QListView", "C++", 14, 15, 0, Qt.LeftButton) clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Code Model") -def iterateAvailableCodeModels(): +def selectClangCodeModel(clangLoaded, enable): + codeModelName = "built-in" + if clangLoaded and enable: + codeModelName = "Clang" + test.log("Testing code model: %s" % codeModelName) __openCodeModelOptions__() - cppChooser = findObject("{type='QComboBox' name='cppChooser' visible='1'}") - models = [str(cppChooser.currentText)] # Make sure default is first in list - if cppChooser.count > 1: - furtherModels = dumpItems(cppChooser.model()) - furtherModels.remove(models[0]) - models.extend(furtherModels) - clickButton(waitForObject(":Options.OK_QPushButton")) - return models - -def selectCodeModel(codeModel): - __openCodeModelOptions__() - expectedObjNames = ['cChooser', 'cppChooser', 'objcChooser', 'objcppChooser', 'hChooser'] - for exp in expectedObjNames: - test.verify(checkIfObjectExists("{type='QComboBox' name='%s' visible='1'}" % exp), - "Verifying whether combobox '%s' exists." % exp) - combo = findObject("{type='QComboBox' name='%s' visible='1'}" % exp) - try: - selectFromCombo(combo, codeModel) - except: - test.fatal("Could not find code model '%s'. Canceling dialog." % codeModel) - clickButton(waitForObject(":Options.Cancel_QPushButton")) - return + 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")) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 47b8fb04805..3f293ebf0df 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -70,7 +70,7 @@ def ensureChecked(objectName, shouldBeChecked = True, timeout=20000): except: # widgets not derived from QCheckbox don't have checkState() if not waitFor('widget.checked == shouldBeChecked', 1000): - clickButton(widget) + mouseClick(widget, 10, 6, 0, Qt.LeftButton) test.verify(waitFor("widget.checked == shouldBeChecked", 1000)) test.log("New state for QCheckBox: %s" % state, str(objectName)) diff --git a/tests/system/suite_CSUP/tst_CSUP02/test.py b/tests/system/suite_CSUP/tst_CSUP02/test.py index ca93b9f7214..ca5fd66b752 100644 --- a/tests/system/suite_CSUP/tst_CSUP02/test.py +++ b/tests/system/suite_CSUP/tst_CSUP02/test.py @@ -38,11 +38,8 @@ def main(): # create qt quick application # Step 1: Open test .pro project. createNewQtQuickApplication(tempDir(), "SampleApp") - models = iterateAvailableCodeModels() - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + for useClang in set([False, clangLoaded]): + selectClangCodeModel(clangLoaded, useClang) # Step 2: Open .cpp file in Edit mode. if not openDocument("SampleApp.Sources.main\\.cpp"): test.fatal("Could not open main.cpp") diff --git a/tests/system/suite_CSUP/tst_CSUP03/test.py b/tests/system/suite_CSUP/tst_CSUP03/test.py index 074065babb8..3644363427c 100644 --- a/tests/system/suite_CSUP/tst_CSUP03/test.py +++ b/tests/system/suite_CSUP/tst_CSUP03/test.py @@ -66,7 +66,7 @@ def constructExpectedCode(original, codeLines, funcSuffix): return "\n".join(tmp) + "\n" def main(): - startCreatorTryingClang() + clangLoaded = startCreatorTryingClang() if not startedWithoutPluginError(): return projectName = createNewNonQtProject() @@ -84,11 +84,8 @@ def main(): "while with braces" : ["", "int dummy = 0;", "while (dummy < 10) {", "++dummy;"], "do while" : ["", "int dummy = 0;", "do", "++dummy;", "while (dummy < 10);"] } - models = iterateAvailableCodeModels() - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + for useClang in set([False, clangLoaded]): + selectClangCodeModel(clangLoaded, useClang) openDocument("%s.Sources.main\\.cpp" % projectName) editor = getEditorForFileSuffix("main.cpp") if not editor: diff --git a/tests/system/suite_CSUP/tst_CSUP04/test.py b/tests/system/suite_CSUP/tst_CSUP04/test.py index b38412e60a0..d576eccaf69 100644 --- a/tests/system/suite_CSUP/tst_CSUP04/test.py +++ b/tests/system/suite_CSUP/tst_CSUP04/test.py @@ -40,18 +40,15 @@ def main(): # copy example project to temp directory templateDir = prepareTemplate(sourceExample) examplePath = os.path.join(templateDir, proFile) - startCreatorTryingClang() + clangLoaded = startCreatorTryingClang() if not startedWithoutPluginError(): return # open example project openQmakeProject(examplePath) # wait for parsing to complete progressBarWait(30000) - models = iterateAvailableCodeModels() - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + for useClang in set([False, clangLoaded]): + selectClangCodeModel(clangLoaded, useClang) # open .cpp file in editor if not openDocument("propertyanimation.Sources.main\\.cpp"): test.fatal("Could not open main.cpp") diff --git a/tests/system/suite_CSUP/tst_CSUP05/test.py b/tests/system/suite_CSUP/tst_CSUP05/test.py index c3e51fbafef..366dc234c54 100644 --- a/tests/system/suite_CSUP/tst_CSUP05/test.py +++ b/tests/system/suite_CSUP/tst_CSUP05/test.py @@ -40,18 +40,15 @@ def main(): # copy example project to temp directory templateDir = prepareTemplate(sourceExample) examplePath = os.path.join(templateDir, proFile) - startCreatorTryingClang() + clangLoaded = startCreatorTryingClang() if not startedWithoutPluginError(): return # open example project openQmakeProject(examplePath) # wait for parsing to complete progressBarWait(30000) - models = iterateAvailableCodeModels() - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + for useClang in set([False, clangLoaded]): + selectClangCodeModel(clangLoaded, useClang) # open .cpp file in editor if not openDocument("propertyanimation.Sources.main\\.cpp"): test.fatal("Could not open main.cpp") diff --git a/tests/system/suite_CSUP/tst_CSUP06/test.py b/tests/system/suite_CSUP/tst_CSUP06/test.py index c71fca6f4a8..76d38ee223b 100644 --- a/tests/system/suite_CSUP/tst_CSUP06/test.py +++ b/tests/system/suite_CSUP/tst_CSUP06/test.py @@ -165,23 +165,21 @@ def main(): templateDir = prepareTemplate(examplePath) examplePath = os.path.join(templateDir, "cplusplus-tools.pro") openQmakeProject(examplePath, Targets.DESKTOP_531_DEFAULT) - models = iterateAvailableCodeModels() - test.compare(len(models), 1 + clangLoaded, "Verifying number of available code models") - test.compare("Qt Creator Built-in", models[0], - "Verifying whether default is Qt Creator's builtin code model") - test.compare("Clang" in models, clangLoaded, - "Verifying whether clang code model can be chosen.") - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + __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) if not openDocument("cplusplus-tools.Sources.main\\.cpp"): earlyExit("Failed to open main.cpp.") return editor = getEditorForFileSuffix("main.cpp") if editor: checkIncludeCompletion(editor) - checkSymbolCompletion(editor, current == "Clang") + 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 diff --git a/tests/system/suite_editors/tst_memberoperator/test.py b/tests/system/suite_editors/tst_memberoperator/test.py index 7b0bbc9b9e9..292a1371894 100644 --- a/tests/system/suite_editors/tst_memberoperator/test.py +++ b/tests/system/suite_editors/tst_memberoperator/test.py @@ -31,15 +31,12 @@ source("../../shared/qtcreator.py") def main(): - startCreatorTryingClang() + clangLoaded = startCreatorTryingClang() if not startedWithoutPluginError(): return createProject_Qt_Console(tempDir(), "SquishProject") - models = iterateAvailableCodeModels() - for current in models: - if current != models[0]: - selectCodeModel(current) - test.log("Testing code model: %s" % current) + for useClang in set([False, clangLoaded]): + selectClangCodeModel(clangLoaded, useClang) selectFromLocator("main.cpp") cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") @@ -56,7 +53,7 @@ def main(): waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 1500) found = str(lineUnderCursor(cppwindow)).strip() exp = testData.field(record, "expected") - if current == "Clang" and exp[-2:] == "->": + if useClang and exp[-2:] == "->": test.xcompare(found, exp) # QTCREATORBUG-11581 else: test.compare(found, exp)