diff options
author | Christian Stenger <christian.stenger@digia.com> | 2013-01-31 15:51:09 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@digia.com> | 2013-01-31 16:16:33 +0100 |
commit | 58c45ca766ba04229e6e5950d585f2e059ba266e (patch) | |
tree | ea74bb697222b645e8ccc740670945c77c7e4e20 | |
parent | 0a02ce6ae23e15f7ddd394ec2edd4cbf03dd66a6 (diff) | |
download | qt-creator-58c45ca766ba04229e6e5950d585f2e059ba266e.tar.gz |
Squish: Added test case for default settings
Change-Id: I669a4a464b966ef9cf5a89f38e95e142e3574a1c
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
-rw-r--r-- | tests/system/objects.map | 4 | ||||
-rw-r--r-- | tests/system/shared/project_explorer.py | 2 | ||||
-rw-r--r-- | tests/system/shared/utils.py | 6 | ||||
-rw-r--r-- | tests/system/suite_general/suite.conf | 2 | ||||
-rw-r--r-- | tests/system/suite_general/tst_default_settings/test.py | 236 | ||||
-rw-r--r-- | tests/system/suite_general/tst_default_settings/testdata/win_compiler_paths.tsv | 19 |
6 files changed, 263 insertions, 6 deletions
diff --git a/tests/system/objects.map b/tests/system/objects.map index 2e50fd33c8..327d4eeff8 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -28,6 +28,7 @@ :CMake Wizard.Next_QPushButton {name='__qt__passive_wizardbutton1' text~='(Next.*|Continue)' type='QPushButton' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard.Run CMake_QPushButton {text='Run CMake' type='QPushButton' unnamed='1' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard {type='CMakeProjectManager::Internal::CMakeOpenProjectWizard' unnamed='1' visible='1' windowTitle='CMake Wizard'} +:CompilerPath.Utils_BaseValidatingLineEdit {container=':qt_tabwidget_stackedwidget_QWidget' name='LineEdit' type='Utils::BaseValidatingLineEdit' visible='1'} :Core__Internal__GeneralSettings.User Interface_QGroupBox {container=':qt_tabwidget_stackedwidget.Core__Internal__GeneralSettings_QWidget' name='interfaceBox' title='User Interface' type='QGroupBox' visible='1'} :CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox {container=':qt_tabwidget_stackedwidget.CppTools__Internal__CompletionSettingsPage_QWidget' name='groupBox' title='Behavior' type='QGroupBox' visible='1'} :CreateProject_QStyleItem {clip='false' container=':Qt Creator_QDeclarativeView' enabled='true' text='Create Project' type='LinkedText' unnamed='1' visible='true'} @@ -50,7 +51,7 @@ :Generator:_QComboBox {buddy=':CMake Wizard.Generator:_QLabel' type='QComboBox' unnamed='1' visible='1'} :Hits_QCLuceneResultWidget {aboveWidget=':Hits_QLabel' type='QCLuceneResultWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Hits_QLabel {text~='\\\\d+ - \\\\d+ of \\\\d+ Hits' type='QLabel' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} -:Kits_QTreeView {container=':qt_tabwidget_stackedwidget_QWidget' type='QTreeView' unnamed='1' visible='1'} +:Kits_Or_Compilers_QTreeView {container=':qt_tabwidget_stackedwidget_QWidget' type='QTreeView' unnamed='1' visible='1'} :Kits_QtVersion_QComboBox {container=':qt_tabwidget_stackedwidget_QWidget' occurrence='4' type='QComboBox' unnamed='1' visible='1'} :New.frame_QFrame {name='frame' type='QFrame' visible='1' window=':New_Core::Internal::NewDialog'} :New.templateCategoryView_QTreeView {name='templateCategoryView' type='QTreeView' visible='1' window=':New_Core::Internal::NewDialog'} @@ -113,6 +114,7 @@ :Qt Gui Application.Source file:_QLabel {name='sourceLabel' text='Source file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'} :Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog {type='Qt4ProjectManager::Internal::GuiAppWizardDialog' unnamed='1' visible='1' windowTitle='Qt Gui Application'} :QtSupport__Internal__QtVersionManager.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' type='QLabel' unnamed='1' visible='1'} +:QtSupport__Internal__QtVersionManager.errorLabel.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='errorLabel' type='QLabel' visible='1'} :QtSupport__Internal__QtVersionManager.qmake_QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qmakePath' type='QLabel' visible='1'} :QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qtdirList' type='QTreeWidget' visible='1'} :Restart required.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Restart required_QMessageBox'} diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index aacc57bbfa..1f2a1470ac 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -155,7 +155,7 @@ def getQtInformationForQmlProject(): waitForObjectItem(":Options_QListView", "Build & Run") clickItem(":Options_QListView", "Build & Run", 14, 15, 0, Qt.LeftButton) clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Kits") - targetsTreeView = waitForObject(":Kits_QTreeView") + targetsTreeView = waitForObject(":Kits_Or_Compilers_QTreeView") if not __selectTreeItemOnBuildAndRun__(targetsTreeView, "%s(\s\(default\))?" % kit, True): test.fatal("Found no matching kit - this shouldn't happen.") clickButton(waitForObject(":Options.Cancel_QPushButton")) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 3430b50d5f..4e015fd437 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -291,7 +291,7 @@ def getConfiguredKits(): return treeWidget.currentItem().text(0) # end of internal function for iterateQtVersions def __setQtVersionForKit__(kit, kitName, kitsQtVersionName): - treeView = waitForObject(":Kits_QTreeView") + treeView = waitForObject(":Kits_Or_Compilers_QTreeView") clickItem(treeView, kit, 5, 5, 0, Qt.LeftButton) qtVersionStr = str(waitForObject(":Kits_QtVersion_QComboBox").currentText) kitsQtVersionName[kitName] = qtVersionStr @@ -343,7 +343,7 @@ def regexVerify(text, expectedTexts): def checkDebuggingLibrary(kitIDs): def __getQtVersionForKit__(kit, kitName): - treeView = waitForObject(":Kits_QTreeView") + treeView = waitForObject(":Kits_Or_Compilers_QTreeView") clickItem(treeView, kit, 5, 5, 0, Qt.LeftButton) return str(waitForObject(":Kits_QtVersion_QComboBox").currentText) # end of internal function for iterate kits @@ -490,7 +490,7 @@ def iterateKits(keepOptionsOpen=False, alreadyOnOptionsDialog=False, waitForObjectItem(":Options_QListView", "Build & Run") clickItem(":Options_QListView", "Build & Run", 14, 15, 0, Qt.LeftButton) clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Kits") - treeView = waitForObject(":Kits_QTreeView") + treeView = waitForObject(":Kits_Or_Compilers_QTreeView") model = treeView.model() test.compare(model.rowCount(), 2, "Verifying expected target section count") autoDetected = model.index(0, 0) diff --git a/tests/system/suite_general/suite.conf b/tests/system/suite_general/suite.conf index 0eebd931d6..19ee1d31df 100644 --- a/tests/system/suite_general/suite.conf +++ b/tests/system/suite_general/suite.conf @@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=0 LANGUAGE=Python OBJECTMAP=../objects.map -TEST_CASES=tst_build_speedcrunch tst_cmake_speedcrunch tst_create_proj_wizard tst_installed_languages tst_openqt_creator +TEST_CASES=tst_build_speedcrunch tst_cmake_speedcrunch tst_create_proj_wizard tst_default_settings tst_installed_languages tst_openqt_creator VERSION=2 WRAPPERS=Qt diff --git a/tests/system/suite_general/tst_default_settings/test.py b/tests/system/suite_general/tst_default_settings/test.py new file mode 100644 index 0000000000..c7523eba2c --- /dev/null +++ b/tests/system/suite_general/tst_default_settings/test.py @@ -0,0 +1,236 @@ +source("../../shared/qtcreator.py") + +import re +import tempfile +import __builtin__ + +currentSelectedTreeItem = None +warningOrError = re.compile('<p><b>((Error|Warning).*?)</p>') + +def main(): + emptySettings = tempDir() + __createMinimumIni__(emptySettings) + SettingsPath = ' -settingspath "%s"' % emptySettings + startApplication("qtcreator" + SettingsPath) + 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 = [] + clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Compilers") + compilerTV = waitForObject(":Kits_Or_Compilers_QTreeView") + __iterateTree__(compilerTV, __compFunc__, foundCompilers, foundCompilerNames) + test.verify(__compareCompilers__(foundCompilers, expectedCompilers), + "Verifying found and expected compilers are equal.") + # check Qt versions + qmakePath = which("qmake") + foundQt = [] + clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Qt Versions") + qtTW = waitForObject(":QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget") + __iterateTree__(qtTW, __qtFunc__, foundQt, qmakePath) + if foundQt: + foundQt = foundQt[0] + # check kits + clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Kits") + kitsTV = waitForObject(":Kits_Or_Compilers_QTreeView") + __iterateTree__(kitsTV, __kitFunc__, foundQt, foundCompilerNames) + +def __iterateTree__(treeObj, additionalFunc, *additionalParameters): + global currentSelectedTreeItem + model = treeObj.model() + # 1st row: Auto-detected, 2nd row: Manual + for sect in dumpIndices(model): + sObj = "%s container=%s}" % (objectMap.realName(sect)[:-1], objectMap.realName(treeObj)) + 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(':CompilerPath.Utils_BaseValidatingLineEdit')", 1000) + pathLineEdit = findObject(":CompilerPath.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 __qtFunc__(it, foundQt, qmakePath): + foundQt.append(it) + qtPath = str(waitForObject(":QtSupport__Internal__QtVersionManager.qmake_QLabel").text) + if platform.system() in ('Microsoft', 'Windows'): + qtPath = qtPath.lower() + qmakePath = qmakePath.lower() + test.compare(qtPath, qmakePath, "Verifying found and expected Qt version are equal.") + 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 = waitForObject("{occurrence='3' type='QComboBox' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}") + 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("<br>", "\n") + details = details.replace("<b>", "").replace("</b>", "") + test.warning("Detected error and/or warning: %s" % details) + +def __getExpectedCompilers__(): + expected = [] + if platform.system() in ('Microsoft', 'Windows'): + expected.extend(__getWinCompilers__()) + compilers = ["g++"] + if platform.system() in ('Linux', 'Darwin'): + compilers.extend(["g++-4.0", "g++-4.2", "clang++"]) + for compiler in compilers: + compilerPath = which(compiler) + if compilerPath: + if compiler == 'clang++': + if subprocess.call(['clang++', '-dumpmachine']) != 0: + test.warning("clang found in PATH, but version is not supported.") + continue + expected.append(compilerPath) + return expected + +def __getWinCompilers__(): + result = [] + winEnvVars = __getWinEnvVars__() + for record in testData.dataset("win_compiler_paths.tsv"): + envvar = winEnvVars.get(testData.field(record, "envvar"), "") + compiler = os.path.abspath(os.path.join(envvar, testData.field(record, "path"), + testData.field(record, "file"))) + if os.path.exists(compiler): + parameters = testData.field(record, "displayedParameters").split(",") + usedParameters = testData.field(record, "usedParameters").split(",") + if testData.field(record, "isSDK") == "true": + for para, used in zip(parameters, usedParameters): + result.append( + {"%s \(.*?\) \(%s\)" % (testData.field(record, 'displayName'), + para) + :"%s %s" % (compiler, used)}) + else: + for para, used in zip(parameters, usedParameters): + result.append({"%s (%s)" % (testData.field(record, 'displayName'), para) + :"%s %s" % (compiler, used)}) + return result + +# using os.getenv() or getOutputFromCmdline() do not work - they would return C:\Program Files (x86) +# for %ProgramFiles% as well as for %ProgramFiles(x86)% when using Python 32bit on 64bit machines +def __getWinEnvVars__(): + result = {} + tmpF, tmpFPath = tempfile.mkstemp() + envvars = subprocess.call('set', stdout=tmpF, shell=True) + os.close(tmpF) + tmpF = open(tmpFPath, "r") + for line in tmpF: + tmp = line.split("=") + result[tmp[0]] = tmp[1] + tmpF.close() + os.remove(tmpFPath) + return result + + +def __compareCompilers__(foundCompilers, expectedCompilers): + equal = True + flags = 0 + isWin = platform.system() in ('Microsoft', 'Windows') + if isWin: + flags = re.IGNORECASE + for currentFound in foundCompilers: + if isinstance(currentFound, dict): + foundExp = False + for currentExp in expectedCompilers: + if isinstance(currentExp, (str, unicode)): + continue + key = currentExp.keys()[0] + # the regex .*? is used for the different possible version strings of the WinSDK + # if it's present a regex will be validated otherwise simple string comparison + if (((".*?" in key and re.match(key, currentFound.keys()[0], flags)) + or currentFound.keys() == currentExp.keys())): + if ((isWin and os.path.abspath(currentFound.values()[0].lower()) + == os.path.abspath(currentExp.values()[0].lower())) + or currentFound.values() == currentExp.values()): + foundExp = True + break + equal = foundExp + else: + if isWin: + equal = currentFound.lower() in __lowerStrs__(expectedCompilers) + else: + equal = currentFound in expectedCompilers + if not equal: + test.fail("Found '%s' but was not expected." % str(currentFound), + str(expectedCompilers)) + break + return equal + +def __lowerStrs__(iterable): + for it in iterable: + if isinstance(it, (str, unicode)): + yield it.lower() + else: + yield it + +def __checkCreatedSettings__(settingsFolder): + qtProj = os.path.join(settingsFolder, "QtProject") + folders = [] + files = [{os.path.join(qtProj, "QtCreator.db"):0}, + {os.path.join(qtProj, "QtCreator.ini"):30}] + folders.append(os.path.join(qtProj, "qtcreator")) + files.extend([{os.path.join(folders[0], "devices.xml"):0}, + {os.path.join(folders[0], "helpcollection.qhc"):0}, + {os.path.join(folders[0], "profiles.xml"):0}, + {os.path.join(folders[0], "qtversion.xml"):0}, + {os.path.join(folders[0], "toolchains.xml"):0}]) + folders.extend([os.path.join(folders[0], "generic-highlighter"), + os.path.join(folders[0], "json"), + os.path.join(folders[0], "macros")]) + for f in folders: + test.verify(os.path.isdir(f), + "Verifying whether folder '%s' has been created." % os.path.basename(f)) + for f in files: + fName = f.keys()[0] + fMinSize = f.values()[0] + text = "created non-empty" + if fMinSize > 0: + text = "modified" + test.verify(os.path.isfile(fName) and os.path.getsize(fName) > fMinSize, + "Verifying whether file '%s' has been %s." % (os.path.basename(fName), text)) diff --git a/tests/system/suite_general/tst_default_settings/testdata/win_compiler_paths.tsv b/tests/system/suite_general/tst_default_settings/testdata/win_compiler_paths.tsv new file mode 100644 index 0000000000..0438a4698b --- /dev/null +++ b/tests/system/suite_general/tst_default_settings/testdata/win_compiler_paths.tsv @@ -0,0 +1,19 @@ +"envvar" "path" "file" "displayName" "displayedParameters" "usedParameters" "isSDK" +"ProgramFiles" "Microsoft SDKs\Windows\v7.0\Bin" "SetEnv.cmd" "Microsoft Windows SDK for Windows 7" "x86,amd64,x86_amd64,ia64,x86_ia64" "/x86,/x64,/x64,/ia64,/ia64" "true" +"ProgramFiles(x86)" "Microsoft SDKs\Windows\v7.0\Bin" "SetEnv.cmd" "Microsoft Windows SDK for Windows 7" "x86,amd64,x86_amd64,ia64,x86_ia64" "/x86,/x64,/x64,/ia64,/ia64" "true" +"ProgramFiles" "Microsoft SDKs\Windows\v7.1\Bin" "SetEnv.cmd" "Microsoft Windows SDK for Windows 7" "x86,amd64,x86_amd64,ia64,x86_ia64" "/x86,/x64,/x64,/ia64,/ia64" "true" +"ProgramFiles(x86)" "Microsoft SDKs\Windows\v7.1\Bin" "SetEnv.cmd" "Microsoft Windows SDK for Windows 7" "x86,amd64,x86_amd64,ia64,x86_ia64" "/x86,/x64,/x64,/ia64,/ia64" "true" +"VS80COMNTOOLS" "..\..\VC\Bin" "vcvars32.bat" "Microsoft Visual C++ Compiler 8.0" "x86" "" "false" +"VS80COMNTOOLS" "..\..\VC\Bin\amd64" "vcvarsamd64.bat" "Microsoft Visual C++ Compiler 8.0" "amd64" "amd64" "false" +"VS80COMNTOOLS" "..\..\VC\Bin" "vcvarsx86_amd64.bat" "Microsoft Visual C++ Compiler 8.0" "x86_amd64" "x86_amd64" "false" +"VS80COMNTOOLS" "..\..\VC\Bin" "vcvars64.bat" "Microsoft Visual C++ Compiler 8.0" "ia64" "ia64" "false" +"VS80COMNTOOLS" "..\..\VC\Bin" "vcvarsx86_ia64.bat" "Microsoft Visual C++ Compiler 8.0" "x86_ia64" "x86_ia64" "false" +"VS90COMNTOOLS" "..\..\VC\Bin" "vcvars32.bat" "Microsoft Visual C++ Compiler 9.0" "x86" "" "false" +"VS90COMNTOOLS" "..\..\VC\Bin\amd64" "vcvarsamd64.bat" "Microsoft Visual C++ Compiler 9.0" "amd64" "amd64" "false" +"VS90COMNTOOLS" "..\..\VC\Bin" "vcvarsx86_amd64.bat" "Microsoft Visual C++ Compiler 9.0" "x86_amd64" "x86_amd64" "false" +"VS90COMNTOOLS" "..\..\VC\Bin" "vcvars64.bat" "Microsoft Visual C++ Compiler 9.0" "ia64" "ia64" "false" +"VS90COMNTOOLS" "..\..\VC\Bin" "vcvarsx86_ia64.bat" "Microsoft Visual C++ Compiler 9.0" "x86_ia64" "x86_ia64" "false" +"VS100COMNTOOLS" "..\..\VC\Bin" "vcvars32.bat" "Microsoft Visual C++ Compiler 10.0" "x86" "" "false" +"VS100COMNTOOLS" "..\..\VC" "vcvarsall.bat" "Microsoft Visual C++ Compiler 10.0" "x86,amd64,x86_amd64,ia64,x86_ia64" "x86,amd64,x86_amd64,ia64,x86_ia64" "false" +"VS110COMNTOOLS" "..\..\VC\Bin" "vcvars32.bat" "Microsoft Visual C++ Compiler 11.0" "x86" "" "false" +"VS110COMNTOOLS" "..\..\VC" "vcvarsall.bat" "Microsoft Visual C++ Compiler 11.0" "x86,amd64,x86_amd64,ia64,x86_ia64" "x86,amd64,x86_amd64,ia64,x86_ia64" "false" |