summaryrefslogtreecommitdiff
path: root/tests/system
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2014-06-13 10:51:51 +0200
committerEike Ziller <eike.ziller@digia.com>2014-06-13 10:51:51 +0200
commit2786250c172138c1ece456305264f7b5039b8f2a (patch)
treedd0a56d98aefe9e1c6a3042b5cbcc37e87bd903b /tests/system
parente9d433a99a8fa4769df92f9caaaaaec049596c34 (diff)
parent27cc89eb4a1e157c68793718602416448547de20 (diff)
downloadqt-creator-2786250c172138c1ece456305264f7b5039b8f2a.tar.gz
Merge remote-tracking branch 'origin/3.1'
Conflicts: qtcreator.pri qtcreator.qbs src/shared/qbs Change-Id: Iba59e41db72e2afdf594f1f7003215d7d8d1e6d3
Diffstat (limited to 'tests/system')
-rw-r--r--tests/system/objects.map2
-rw-r--r--tests/system/shared/build_utils.py7
-rw-r--r--tests/system/shared/debugger.py2
-rw-r--r--tests/system/shared/editor_utils.py9
-rw-r--r--tests/system/shared/utils.py7
-rwxr-xr-xtests/system/suite_HELP/tst_HELP04/test.py11
-rw-r--r--tests/system/suite_editors/suite.conf2
-rw-r--r--tests/system/suite_editors/tst_generic_highlighter/test.py217
-rw-r--r--tests/system/suite_general/tst_save_before_build/test.py2
9 files changed, 244 insertions, 15 deletions
diff --git a/tests/system/objects.map b/tests/system/objects.map
index 4402360719..a67704818e 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -131,7 +131,6 @@
:Qt Creator.Compile Output_Core::OutputWindow {type='Core::OutputWindow' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Compile Output'}
:Qt Creator.DebugModeWidget_QSplitter {name='DebugModeWidget' type='QSplitter' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Go to Help Mode_QToolButton {text='Go to Help Mode' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:Qt Creator.Help_Search for:_QLineEdit {leftWidget=':Qt Creator.Search for:_QLabel' type='QLineEdit' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Issues_QListView {type='QListView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Issues'}
:Qt Creator.Project.Menu.File_QMenu {name='Project.Menu.File' type='QMenu'}
:Qt Creator.Project.Menu.Folder_QMenu {name='Project.Menu.Folder' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
@@ -139,7 +138,6 @@
:Qt Creator.ReRun_QToolButton {toolTip='Re-run this run-configuration' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Replace All_QToolButton {name='replaceAllButton' text='Replace All' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Replace_QToolButton {name='replaceButton' text='Replace' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:Qt Creator.Search for:_QLabel {text='Search for:' type='QLabel' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Stop_QToolButton {text='Stop' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.replaceEdit_Utils::FilterLineEdit {name='replaceEdit' type='Utils::FancyLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
diff --git a/tests/system/shared/build_utils.py b/tests/system/shared/build_utils.py
index 7811915546..51eb4c71d0 100644
--- a/tests/system/shared/build_utils.py
+++ b/tests/system/shared/build_utils.py
@@ -84,8 +84,7 @@ def waitForCompile(timeout=60000):
def dumpBuildIssues(listModel):
issueDump = []
- for row in range(listModel.rowCount()):
- index = listModel.index(row, 0)
+ for index in dumpIndices(listModel):
issueDump.extend([map(lambda role: index.data(role).toString(),
range(Qt.UserRole, Qt.UserRole + 6))])
return issueDump
@@ -165,8 +164,8 @@ def iterateBuildConfigs(kitCount, filter = ""):
def selectBuildConfig(targetCount, currentTarget, configName, afterSwitchTo=ViewConstants.EDIT):
switchViewTo(ViewConstants.PROJECTS)
switchToBuildOrRunSettingsFor(targetCount, currentTarget, ProjectSettings.BUILD)
- selectFromCombo(":scrollArea.Edit build configuration:_QComboBox", configName)
- progressBarWait(30000)
+ if selectFromCombo(":scrollArea.Edit build configuration:_QComboBox", configName) or targetCount > 1:
+ progressBarWait(30000)
return getQtInformationForBuildSettings(targetCount, True, afterSwitchTo)
# This will not trigger a rebuild. If needed, caller has to do this.
diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py
index 754ce55fc1..069a390db1 100644
--- a/tests/system/shared/debugger.py
+++ b/tests/system/shared/debugger.py
@@ -81,7 +81,7 @@ def setBreakpointsForCurrentProject(filesAndLines):
for curFile,curLine in current.iteritems():
if not openDocument(curFile):
return False
- editor = getEditorForFileSuffix(curFile)
+ editor = getEditorForFileSuffix(curFile, True)
if not placeCursorToLine(editor, curLine, True):
return False
invokeMenuItem("Debug", "Toggle Breakpoint")
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py
index 4b3a279990..d29465d2df 100644
--- a/tests/system/shared/editor_utils.py
+++ b/tests/system/shared/editor_utils.py
@@ -255,7 +255,7 @@ def verifyProperties(properties, expectedProps):
result[key] = None
return result
-def getEditorForFileSuffix(curFile):
+def getEditorForFileSuffix(curFile, treeViewSyntax=False):
cppEditorSuffixes = ["cpp", "cc", "CC", "h", "H", "cp", "cxx", "C", "c++", "inl", "moc", "qdoc",
"tcc", "tpp", "t++", "c", "cu", "m", "mm", "hh", "hxx", "h++", "hpp", "hp"]
qmlEditorSuffixes = ["qml", "qmlproject", "js", "qs", "qtt"]
@@ -263,6 +263,13 @@ def getEditorForFileSuffix(curFile):
glslEditorSuffixes= ["frag", "vert", "fsh", "vsh", "glsl", "shader", "gsh"]
pytEditorSuffixes = ["py", "pyw", "wsgi"]
suffix = __getFileSuffix__(curFile)
+ expected = os.path.basename(curFile)
+ if treeViewSyntax:
+ expected = simpleFileName(curFile)
+ mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
+ if not waitFor("expected in str(mainWindow.windowTitle)", 5000):
+ test.fatal("Window title (%s) did not switch to expected file (%s)."
+ % (str(mainWindow.windowTitle), expected))
try:
if suffix in cppEditorSuffixes:
editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py
index c24fd69dac..b1076c2d1a 100644
--- a/tests/system/shared/utils.py
+++ b/tests/system/shared/utils.py
@@ -603,7 +603,12 @@ def readFile(filename):
return content
def simpleFileName(navigatorFileName):
- return ".".join(navigatorFileName.split(".")[-2:]).replace("\\","")
+ # try to find the last part of the given name, assume it's inside a (folder) structure
+ search = re.search(".*[^\\\\]\.(.*)$", navigatorFileName)
+ if search:
+ return search.group(1).replace("\\", "")
+ # it's just the filename
+ return navigatorFileName.replace("\\", "")
def clickOnTab(tabBarStr, tabText, timeout=5000):
if not waitFor("object.exists(tabBarStr)", timeout):
diff --git a/tests/system/suite_HELP/tst_HELP04/test.py b/tests/system/suite_HELP/tst_HELP04/test.py
index 74fe163543..db49936605 100755
--- a/tests/system/suite_HELP/tst_HELP04/test.py
+++ b/tests/system/suite_HELP/tst_HELP04/test.py
@@ -96,10 +96,13 @@ def main():
mouseClick(waitForObject("{column='0' container=':Qt Creator_QHelpContentWidget' "
"text='Qt Reference Documentation' type='QModelIndex'}"))
# try to search keyword from list
+ searchLineEdit = getChildByClass(waitForObject("{type='QHelpSearchQueryWidget' unnamed='1' visible='1' "
+ "window=':Qt Creator_Core::Internal::MainWindow'}"),
+ "QLineEdit")
for searchKeyword,shouldFind in searchKeywordDictionary.items():
- mouseClick(waitForObject(":Qt Creator.Help_Search for:_QLineEdit"))
- replaceEditorContent(":Qt Creator.Help_Search for:_QLineEdit", searchKeyword)
- type(waitForObject(":Qt Creator.Help_Search for:_QLineEdit"), "<Return>")
+ mouseClick(searchLineEdit)
+ replaceEditorContent(searchLineEdit, searchKeyword)
+ type(searchLineEdit, "<Return>")
progressBarWait(warn=False)
if shouldFind:
test.verify(waitFor("re.match('[1-9]\d* - [1-9]\d* of [1-9]\d* Hits',"
@@ -153,7 +156,7 @@ def main():
test.verify("sql" in str(__getSelectedText__()).lower(),
"sql advanced search result can be found")
# verify if simple search is properly disabled
- test.verify(findObject(":Qt Creator.Help_Search for:_QLineEdit").enabled == False,
+ test.verify(not searchLineEdit.enabled,
"Verifying if simple search is not active in advanced mode.")
# exit
invokeMenuItem("File", "Exit")
diff --git a/tests/system/suite_editors/suite.conf b/tests/system/suite_editors/suite.conf
index cbb4aed981..b6c5a0fdb3 100644
--- a/tests/system/suite_editors/suite.conf
+++ b/tests/system/suite_editors/suite.conf
@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
-TEST_CASES=tst_basic_cpp_support tst_delete_externally tst_edit_externally tst_memberoperator tst_modify_readonly tst_qml_editor tst_qml_indent tst_rename_macros tst_revert_changes tst_select_all
+TEST_CASES=tst_basic_cpp_support tst_delete_externally tst_edit_externally tst_generic_highlighter tst_memberoperator tst_modify_readonly tst_qml_editor tst_qml_indent tst_rename_macros tst_revert_changes tst_select_all
VERSION=2
WRAPPERS=Qt
diff --git a/tests/system/suite_editors/tst_generic_highlighter/test.py b/tests/system/suite_editors/tst_generic_highlighter/test.py
new file mode 100644
index 0000000000..df2ab56eff
--- /dev/null
+++ b/tests/system/suite_editors/tst_generic_highlighter/test.py
@@ -0,0 +1,217 @@
+#############################################################################
+##
+## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/legal
+##
+## 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 Digia. For licensing terms and
+## conditions see http://qt.digia.com/licensing. For further information
+## use the contact form at http://qt.digia.com/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 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 2.1 requirements
+## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+##
+## In addition, as a special exception, Digia gives you certain additional
+## rights. These rights are described in the Digia Qt LGPL Exception
+## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+##
+#############################################################################
+
+source("../../shared/qtcreator.py")
+
+def createFile(folder, filename):
+ __createProjectOrFileSelectType__(" General", "Text File", isProject = False)
+ replaceEditorContent(waitForObject("{name='nameLineEdit' visible='1' "
+ "type='Utils::FileNameValidatingLineEdit'}"), filename)
+ replaceEditorContent(waitForObject("{type='Utils::FancyLineEdit' unnamed='1' visible='1' "
+ "window=':New Text File_Utils::FileWizardDialog'}"), folder)
+ clickButton(waitForObject(":Next_QPushButton"))
+ __createProjectHandleLastPage__()
+
+def clickTableGetPatternLineEdit(table, row):
+ clickItem(table, "%d/0" % row, 5, 5, 0, Qt.LeftButton)
+ return waitForObject("{name='patternsLineEdit' type='QLineEdit' visible='1'}")
+
+def getOrModifyFilePatternsFor(mimeType, filter='', toBePresent=None):
+ toSuffixArray = lambda x : [pat.replace("*", "") for pat in x.split(";")]
+
+ result = []
+ invokeMenuItem("Tools", "Options...")
+ waitForObjectItem(":Options_QListView", "Environment")
+ clickItem(":Options_QListView", "Environment", 14, 15, 0, Qt.LeftButton)
+ waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' type='TabItem' "
+ "text='MIME Types'}")
+ clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "MIME Types")
+ replaceEditorContent(waitForObject("{name='filterLineEdit' type='QLineEdit' visible='1'}"),
+ filter)
+ mimeTypeTable = waitForObject("{name='mimeTypesTableView' type='QTableView' visible='1'}")
+ model = mimeTypeTable.model()
+ if filter == '':
+ for row in range(model.rowCount()):
+ if str(model.data(model.index(row, 0)).toString()) == mimeType:
+ result = toSuffixArray(str(clickTableGetPatternLineEdit(mimeTypeTable, row).text))
+ break
+ clickButton(":Options.Cancel_QPushButton")
+ if result == ['']:
+ test.warning("MIME type '%s' seems to have no file patterns." % mimeType)
+ return result
+ waitFor('model.rowCount() == 1', 2000)
+ if model.rowCount() == 1:
+ patternsLineEd = clickTableGetPatternLineEdit(mimeTypeTable, 0)
+ patterns = str(patternsLineEd.text)
+ if toBePresent:
+ actualSuffixes = toSuffixArray(patterns)
+ toBeAddedSet = set(toBePresent).difference(set(actualSuffixes))
+ if toBeAddedSet:
+ patterns += ";*" + ";*".join(toBeAddedSet)
+ replaceEditorContent(patternsLineEd, patterns)
+ clickButton(":Options.OK_QPushButton")
+ try:
+ mBox = waitForObject("{type='QMessageBox' unnamed='1' visible='1' "
+ "text?='Conflicting pattern*'}", 2000)
+ conflictingSet = set(str(mBox.detailedText).replace("*", "").splitlines())
+ sendEvent("QCloseEvent", mBox)
+ if toBeAddedSet.intersection(conflictingSet):
+ test.fatal("At least one of the patterns to be added is already in use "
+ "for another MIME type.",
+ "Conflicting patterns: %s" % str(conflictingSet))
+ if conflictingSet.difference(toBeAddedSet):
+ test.fail("MIME type handling failed. (QTCREATORBUG-12149?)",
+ "Conflicting patterns: %s" % str(conflictingSet))
+ # re-check the patterns
+ result = getOrModifyFilePatternsFor(mimeType)
+ except:
+ result = toSuffixArray(patterns)
+ test.passes("Added suffixes")
+ return result
+ else:
+ result = toSuffixArray(patterns)
+ elif model.rowCount() > 1:
+ test.warning("MIME type '%s' has ambiguous results." % mimeType)
+ else:
+ test.log("MIME type '%s' seems to be unknown to the system." % mimeType)
+ clickButton(":Options.Cancel_QPushButton")
+ return result
+
+def uncheckGenericHighlighterFallback():
+ invokeMenuItem("Tools", "Options...")
+ waitForObjectItem(":Options_QListView", "Text Editor")
+ clickItem(":Options_QListView", "Text Editor", 14, 15, 0, Qt.LeftButton)
+ waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' type='TabItem' "
+ "text='Generic Highlighter'}")
+ clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Generic Highlighter")
+ ensureChecked("{name='useFallbackLocation' text='Use fallback location' type='QCheckBox' "
+ "visible='1'}", False)
+ clickButton(":Options.OK_QPushButton")
+
+def addHighlighterDefinition(language):
+ global tmpSettingsDir
+ test.log("Adding highlighter definitions for '%s'." % language)
+ invokeMenuItem("Tools", "Options...")
+ waitForObjectItem(":Options_QListView", "Text Editor")
+ clickItem(":Options_QListView", "Text Editor", 14, 15, 0, Qt.LeftButton)
+ waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' type='TabItem' "
+ "text='Generic Highlighter'}")
+ clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Generic Highlighter")
+ clickButton("{text='Download Definitions...' type='QPushButton' unnamed='1' visible='1'}")
+ table = waitForObject("{name='definitionsTable' type='QTableWidget' visible='1'}")
+ model = table.model()
+ for row in range(model.rowCount()):
+ if str(model.data(model.index(row, 0)).toString()) == language:
+ clickItem(table, "%d/0" % row, 5, 5, 0, Qt.LeftButton)
+ clickButton("{name='downloadButton' text='Download Selected Definitions' "
+ "type='QPushButton' visible='1'}")
+ # downloading happens asynchronously
+ languageFile = os.path.join(tmpSettingsDir, "QtProject", "qtcreator",
+ "generic-highlighter", "%s.xml" % language.lower())
+ test.verify(waitFor("os.path.exists(languageFile)", 10000),
+ "Verifying whether file has been downloaded and placed to settings.")
+ clickButton("{text='Download Definitions...' type='QPushButton' unnamed='1' "
+ "visible='1'}")
+ table = waitForObject("{name='definitionsTable' type='QTableWidget' visible='1'}")
+ model = table.model()
+ test.verify(str(model.data(model.index(row, 1))) != "",
+ "Verifying a definition has been downloaded.")
+ clickButton("{text='Close' type='QPushButton' unnamed='1' visible='1'}")
+ clickButton(":Options.OK_QPushButton")
+ return True
+ test.fail("Could not find the specified language (%s) to download a highlighter definition"
+ % language)
+ clickButton("{text='Close' type='QPushButton' unnamed='1' visible='1'}")
+ clickButton(":Options.OK_QPushButton")
+ return False
+
+def hasSuffix(fileName, suffixPatterns):
+ for suffix in suffixPatterns:
+ if fileName.endswith(suffix):
+ return True
+ return False
+
+def main():
+ miss = "A highlight definition was not found for this file. Would you like to try to find one?"
+ startApplication("qtcreator" + SettingsPath)
+ if not startedWithoutPluginError():
+ return
+ uncheckGenericHighlighterFallback()
+ patterns = getOrModifyFilePatternsFor("text/x-haskell", "haskell")
+ folder = tempDir()
+ filesToTest = ["Main.lhs", "Main.hs"]
+ code = ['module Main where', '', 'main :: IO ()', '', 'main = putStrLn "Hello World!"']
+
+ for current in filesToTest:
+ createFile(folder, current)
+ editor = getEditorForFileSuffix(current)
+ expectHint = hasSuffix(current, patterns)
+ mssg = "Verifying whether hint for missing highlight definition is present. (expected: %s)"
+ try:
+ waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
+ "window=':Qt Creator_Core::Internal::MainWindow'}" % miss, 2000)
+ test.verify(expectHint, mssg % str(expectHint))
+ except:
+ test.verify(not expectHint, mssg % str(expectHint))
+ # literate haskell: first character must be '>' otherwise it's a comment
+ if current.endswith(".lhs"):
+ typeLines(editor, [">" + line for line in code])
+ else:
+ typeLines(editor, code)
+
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Close All")
+ addedHighlighterDefinition = addHighlighterDefinition("Haskell")
+ patterns = getOrModifyFilePatternsFor('text/x-haskell', 'haskell', ['.lhs', '.hs'])
+
+ home = os.path.expanduser("~")
+ for current in filesToTest:
+ recentFile = os.path.join(folder, current)
+ if recentFile.startswith(home) and platform.system() in ('Linux', 'Darwin'):
+ recentFile = recentFile.replace(home, "~", 1)
+ invokeMenuItem("File", "Recent Files", recentFile)
+ editor = getEditorForFileSuffix(current)
+ try:
+ waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
+ "window=':Qt Creator_Core::Internal::MainWindow'}" % miss, 2000)
+ test.verify(not addedHighlighterDefinition and hasSuffix(current, patterns),
+ "Hint for missing highlight definition was present.")
+ except:
+ test.verify(addedHighlighterDefinition or not hasSuffix(current, patterns),
+ "Hint for missing highlight definition is not shown.")
+ placeCursorToLine(editor, '.*%s' % code[-1], True)
+ for _ in range(23):
+ type(editor, "<Left>")
+ type(editor, "<Return>")
+ if current.endswith(".lhs"):
+ type(editor, ">")
+ type(editor, "<Tab>")
+
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
diff --git a/tests/system/suite_general/tst_save_before_build/test.py b/tests/system/suite_general/tst_save_before_build/test.py
index 71c7839017..91862f590e 100644
--- a/tests/system/suite_general/tst_save_before_build/test.py
+++ b/tests/system/suite_general/tst_save_before_build/test.py
@@ -58,7 +58,7 @@ def main():
test.fatal("Could not open file '%s'" % simpleFileName(file))
continue
test.log("Changing file '%s'" % simpleFileName(file))
- typeLines(getEditorForFileSuffix(file), "")
+ typeLines(getEditorForFileSuffix(file, True), "")
# try to compile
clickButton(waitForObject(":*Qt Creator.Build Project_Core::Internal::FancyToolButton"))
try: