############################################################################# ## ## Copyright (C) 2015 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing ## ## This file is part of Qt Creator. ## ## Commercial License Usage ## Licensees holding valid commercial Qt licenses may use this file in ## accordance with the commercial license agreement provided with the ## Software or, alternatively, in accordance with the terms contained in ## a written agreement between you and The Qt Company. For licensing terms and ## conditions see http://www.qt.io/terms-conditions. For further information ## use the contact form at http://www.qt.io/contact-us. ## ## GNU Lesser General Public License Usage ## Alternatively, this file may be used under the terms of the GNU Lesser ## General Public License version 2.1 or version 3 as published by the Free ## Software Foundation and appearing in the file LICENSE.LGPLv21 and ## LICENSE.LGPLv3 included in the packaging of this file. Please review the ## following information to ensure the GNU Lesser General Public License ## requirements will be met: https://www.gnu.org/licenses/lgpl.html and ## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ## ## In addition, as a special exception, The Qt Company gives you certain additional ## rights. These rights are described in The Qt Company LGPL Exception ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ## ############################################################################# source("../../shared/qtcreator.py") import re import tempfile import __builtin__ currentSelectedTreeItem = None warningOrError = re.compile('
((Error|Warning).*?)
') def main(): emptySettings = tempDir() __createMinimumIni__(emptySettings) SettingsPath = ' -settingspath "%s"' % emptySettings startApplication("qtcreator" + SettingsPath) if not startedWithoutPluginError(): return invokeMenuItem("Tools", "Options...") __checkBuildAndRun__() clickButton(waitForObject(":Options.Cancel_QPushButton")) invokeMenuItem("File", "Exit") __checkCreatedSettings__(emptySettings) def __createMinimumIni__(emptyParent): qtProjDir = os.path.join(emptyParent, "QtProject") os.mkdir(qtProjDir) iniFile = open(os.path.join(qtProjDir, "QtCreator.ini"), "w") iniFile.write("[%General]\n") iniFile.write("OverrideLanguage=C\n") iniFile.close() def __checkBuildAndRun__(): waitForObjectItem(":Options_QListView", "Build & Run") clickItem(":Options_QListView", "Build & Run", 14, 15, 0, Qt.LeftButton) # check compilers expectedCompilers = __getExpectedCompilers__() foundCompilers = [] foundCompilerNames = [] clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Compilers") __iterateTree__(":BuildAndRun_QTreeView", __compFunc__, foundCompilers, foundCompilerNames) test.verify(__compareCompilers__(foundCompilers, expectedCompilers), "Verifying found and expected compilers are equal.") # check debugger expectedDebuggers = __getExpectedDebuggers__() clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Debuggers") foundDebugger = [] __iterateTree__(":BuildAndRun_QTreeView", __dbgFunc__, foundDebugger) test.verify(__compareDebuggers__(foundDebugger, expectedDebuggers), "Verifying found and expected debuggers are equal.") # check Qt versions qmakePath = which("qmake") foundQt = [] clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Qt Versions") __iterateTree__(":QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget", __qtFunc__, foundQt, qmakePath) test.verify(not qmakePath or len(foundQt) == 1, "Was qmake from %s autodetected? Found %s" % (qmakePath, foundQt)) if foundQt: foundQt = foundQt[0] # qmake from "which" should be used in kits # check kits clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Kits") __iterateTree__(":BuildAndRun_QTreeView", __kitFunc__, foundQt, foundCompilerNames) def __iterateTree__(treeObjStr, additionalFunc, *additionalParameters): global currentSelectedTreeItem model = waitForObject(treeObjStr).model() # 1st row: Auto-detected, 2nd row: Manual for sect in dumpIndices(model): sObj = "%s container='%s'}" % (objectMap.realName(sect)[:-1], treeObjStr) items = dumpIndices(model, sect) doneItems = [] for it in items: indexName = str(it.data().toString()) itObj = "%s container=%s}" % (objectMap.realName(it)[:-1], sObj) alreadyDone = doneItems.count(itObj) doneItems.append(itObj) if alreadyDone: itObj = "%s occurrence='%d'}" % (itObj[:-1], alreadyDone + 1) currentSelectedTreeItem = waitForObject(itObj, 3000) mouseClick(currentSelectedTreeItem, 5, 5, 0, Qt.LeftButton) additionalFunc(indexName, *additionalParameters) currentSelectedTreeItem = None def __compFunc__(it, foundComp, foundCompNames): try: waitFor("object.exists(':Path.Utils_BaseValidatingLineEdit')", 1000) pathLineEdit = findObject(":Path.Utils_BaseValidatingLineEdit") foundComp.append(str(pathLineEdit.text)) except: label = findObject("{buddy={container=':qt_tabwidget_stackedwidget_QWidget' " "text='Initialization:' type='QLabel' unnamed='1' visible='1'} " "type='QLabel' unnamed='1' visible='1'}") foundComp.append({it:str(label.text)}) foundCompNames.append(it) def __dbgFunc__(it, foundDbg): waitFor("object.exists(':Path.Utils_BaseValidatingLineEdit')", 1000) pathLineEdit = findObject(":Path.Utils_BaseValidatingLineEdit") foundDbg.append(str(pathLineEdit.text)) def __qtFunc__(it, foundQt, qmakePath): qtPath = str(waitForObject(":QtSupport__Internal__QtVersionManager.qmake_QLabel").text) if platform.system() in ('Microsoft', 'Windows'): qtPath = qtPath.lower() qmakePath = qmakePath.lower() test.verify(os.path.isfile(qtPath) and os.access(qtPath, os.X_OK), "Verifying found Qt (%s) is executable." % qtPath) # Two Qt versions will be found when using qtchooser: QTCREATORBUG-14697 # Only add qmake from "which" to list if qtPath == qmakePath: foundQt.append(it) try: errorLabel = findObject(":QtSupport__Internal__QtVersionManager.errorLabel.QLabel") test.warning("Detected error or warning: '%s'" % errorLabel.text) except: pass def __kitFunc__(it, foundQt, foundCompNames): global currentSelectedTreeItem, warningOrError qtVersionStr = str(waitForObject(":Kits_QtVersion_QComboBox").currentText) test.compare(it, "Desktop (default)", "Verifying whether default Desktop kit has been created.") if foundQt: test.compare(qtVersionStr, foundQt, "Verifying if Qt versions match.") compilerCombo = findObject(":Compiler:_QComboBox") test.compare(compilerCombo.enabled, compilerCombo.count > 1, "Verifying whether compiler combo is enabled/disabled correctly.") test.verify(str(compilerCombo.currentText) in foundCompNames, "Verifying if one of the found compilers had been set.") if currentSelectedTreeItem: foundWarningOrError = warningOrError.search(str(currentSelectedTreeItem.toolTip)) if foundWarningOrError: details = str(foundWarningOrError.group(1)).replace("