diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-04-30 11:43:33 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-04-30 11:43:33 +0200 |
commit | bedc477943ba94c38db133b8cf6d20132d56a315 (patch) | |
tree | ae64d44a5d12f66e07a0c2d963d885bcf0ceb5db /tests | |
parent | 3aa0e500392192dc6306a29d4a60b4d362a29811 (diff) | |
parent | 71f1919de9a1ce0abc370fb2a1044ad6e85438cf (diff) | |
download | qt-creator-bedc477943ba94c38db133b8cf6d20132d56a315.tar.gz |
Merge remote-tracking branch 'origin/2.7'
Conflicts:
src/plugins/qmldesigner/components/formeditor/abstractcustomtool.cpp
Change-Id: I4e0a85795e7f4bfcdc21d106517517b527f85104
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp | 18 | ||||
-rw-r--r-- | tests/system/objects.map | 3 | ||||
-rw-r--r-- | tests/system/shared/editor_utils.py | 2 | ||||
-rw-r--r-- | tests/system/shared/project.py | 5 | ||||
-rw-r--r-- | tests/system/shared/utils.py | 6 | ||||
-rw-r--r-- | tests/system/shared/workarounds.py | 61 | ||||
-rw-r--r-- | tests/system/suite_debugger/tst_cli_output_console/test.py | 4 | ||||
-rw-r--r-- | tests/system/suite_debugger/tst_simple_analyze/test.py | 5 | ||||
-rw-r--r-- | tests/system/suite_debugger/tst_simple_debug/test.py | 3 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_basic_cpp_support/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_delete_externally/test.py | 8 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_revert_changes/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_select_all/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_general/suite.conf | 2 | ||||
-rw-r--r-- | tests/system/suite_general/tst_rename_file/test.py | 78 | ||||
-rwxr-xr-x | tests/system/tools/findUnusedObjects.py | 30 |
16 files changed, 166 insertions, 65 deletions
diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp index f920da1125..92560c4e44 100644 --- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp +++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp @@ -318,6 +318,7 @@ private: private slots: void va_args(); void named_va_args(); + void extra_va_args(); void defined(); void defined_data(); void empty_macro_args(); @@ -414,6 +415,23 @@ void tst_Preprocessor::named_va_args() QCOMPARE(simplified(preprocessed), QString("int f();int f(int a);int f(int a,int b);")); } +void tst_Preprocessor::extra_va_args() +{ + Client *client = 0; // no client. + Environment env; + + Preprocessor preprocess(client, &env); + QByteArray preprocessed = preprocess.run(QLatin1String("<stdin>"), + "#define foo(ret, ...) ret f(__VA_ARGS__);\n" + "\nfoo(int)\n" + "\nfoo(float,int b)\n" + "\nfoo(long,int b,int c)\n", + true, false); + + preprocessed = preprocessed.simplified(); + QCOMPARE(simplified(preprocessed), QString("int f();float f(int b);long f(int b,int c);")); +} + void tst_Preprocessor::empty_macro_args() { Client *client = 0; // no client. diff --git a/tests/system/objects.map b/tests/system/objects.map index fb324704be..b39ba183f6 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -8,6 +8,7 @@ :*Qt Creator.Interrupt_Core::Internal::FancyToolButton {text='Interrupt' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.JavaScript_QDockWidget {name='QmlProfilerV8ProfileViewDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='JavaScript'} :*Qt Creator.JavaScript_QTabBar {aboveWidget=':*Qt Creator.JavaScript_QDockWidget' type='QTabBar' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:*Qt Creator.Run_Core::Internal::FancyToolButton {text='Run' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.Start Debugging_Core::Internal::FancyToolButton {text='Start Debugging' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.findEdit_Utils::FilterLineEdit {name='findEdit' type='Utils::FilterLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator_Core::Internal::FancyToolButton {occurrence='3' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} @@ -91,6 +92,7 @@ :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' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.Project.Menu.Project_QMenu {name='Project.Menu.Project' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.ReRun_QToolButton {toolTip='Re-run this run-configuration' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} @@ -122,6 +124,7 @@ :Qt Creator_SearchResult_Core::Internal::OutputPaneToggleButton {occurrence='2' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_SystemSettings.Details_Utils::DetailsButton {occurrence='4' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit {container=':Qt Creator_Utils::NavigationTreeView' type='QExpandingLineEdit' unnamed='1' visible='1'} :Qt Gui Application.Form file:_QLabel {name='formLabel' text='Form file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'} :Qt Gui Application.Header file:_QLabel {name='headerLabel' text='Header file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'} :Qt Gui Application.Source file:_QLabel {name='sourceLabel' text='Source file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'} diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 294093314f..ac698353dd 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -64,7 +64,7 @@ def widgetContainsPoint(widget, point): def openContextMenuOnTextCursorPosition(editor): rect = editor.cursorRect(editor.textCursor()) if platform.system() == 'Darwin': - JIRA.performWorkaroundIfStillOpen(8735, JIRA.Bug.CREATOR, editor) + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, editor) openContextMenu(editor, rect.x+rect.width/2, rect.y+rect.height/2, 0) menuInList = [None] waitFor("menuVisibleAtEditor(editor, menuInList)", 5000) diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index f47920ec1e..832a468792 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -304,7 +304,7 @@ def runAndCloseApp(withHookInto=False, executable=None, port=None, function=None overrideInstallLazySignalHandler() installLazySignalHandler("{type='ProjectExplorer::ApplicationLauncher'}", "processStarted()", "__handleProcessStarted__") installLazySignalHandler("{type='ProjectExplorer::ApplicationLauncher'}", "processExited(int)", "__handleProcessExited__") - runButton = waitForObject("{type='Core::Internal::FancyToolButton' text='Run' visible='1'}") + runButton = waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton") clickButton(runButton) if sType != SubprocessType.QT_QUICK_UI: waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) @@ -388,8 +388,7 @@ def __closeSubprocessByHookingInto__(executable, port, function, sType, userDefT switchViewTo(ViewConstants.EDIT) global processStarted processStarted = False - runButton = waitForObject("{type='Core::Internal::FancyToolButton' text='Run' " - "visible='1'}") + runButton = waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton") clickButton(runButton) if not waitFor("processStarted == True", 10000): test.fatal("Something seems to be really wrong.", "Application output:" diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 3af2ffd5ae..4bb0e36ef8 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -612,3 +612,9 @@ def checkIfObjectExists(name, shouldExist = True, timeout = 3000, verboseOnFail def progressBarWait(): checkIfObjectExists("{type='Core::Internal::ProgressBar' unnamed='1'}", True, 2000) checkIfObjectExists("{type='Core::Internal::ProgressBar' unnamed='1'}", False, 60000) + +def readFile(filename): + f = open(filename, "r") + content = f.read() + f.close() + return content diff --git a/tests/system/shared/workarounds.py b/tests/system/shared/workarounds.py index f0ce4c348c..2726b38112 100644 --- a/tests/system/shared/workarounds.py +++ b/tests/system/shared/workarounds.py @@ -22,7 +22,7 @@ class JIRA: else: JIRA.__instance__._bugType = bugType JIRA.__instance__._number = number - JIRA.__instance__.__fetchStatusAndResolutionFromJira__() + JIRA.__instance__.__fetchResolutionFromJira__() # overriden to make it possible to use JIRA just like the # underlying implementation (__impl) @@ -48,22 +48,14 @@ class JIRA: tmpJIRA = JIRA(number, bugType) return tmpJIRA.isOpen() - # function similar to performWorkaroundForBug - but it will execute the - # workaround (function) only if the bug is still open - # returns True if the workaround function has been executed, False otherwise - @staticmethod - def performWorkaroundIfStillOpen(number, bugType=Bug.CREATOR, *args): - if JIRA.isBugStillOpen(number, bugType): - return JIRA.performWorkaroundForBug(number, bugType, *args) - else: - test.warning("Bug is closed... skipping workaround!", - "You should remove potential code inside performWorkaroundForBug()") - return False - # function that performs the workaround (function) for the given bug # if the function needs additional arguments pass them as 3rd parameter @staticmethod def performWorkaroundForBug(number, bugType=Bug.CREATOR, *args): + if not JIRA.isBugStillOpen(number, bugType): + test.warning("Bug %s-%d is closed for version %s." % + (bugType, number, JIRA(number, bugType)._fix), + "You should probably remove potential code inside workarounds.py") functionToCall = JIRA.getInstance().__bugs__.get("%s-%d" % (bugType, number), None) if functionToCall: test.warning("Using workaround for %s-%d" % (bugType, number)) @@ -82,7 +74,7 @@ class JIRA: self._localOnly = os.getenv("SYSTEST_JIRA_NO_LOOKUP")=="1" self.__initBugDict__() self._fetchResults_ = {} - self.__fetchStatusAndResolutionFromJira__() + self.__fetchResolutionFromJira__() # this function checks the resolution of the given bug # and returns True if the bug can still be assumed as 'Open' and False otherwise @@ -96,16 +88,16 @@ class JIRA: return True return self._resolution != 'Done' - # this function tries to fetch the status and resolution from JIRA for the given bug + # this function tries to fetch the resolution from JIRA for the given bug # if this isn't possible or the lookup is disabled it does only check the internal # dict whether a function for the given bug is deposited or not - def __fetchStatusAndResolutionFromJira__(self): + def __fetchResolutionFromJira__(self): global JIRA_URL bug = "%s-%d" % (self._bugType, self._number) if bug in self._fetchResults_: result = self._fetchResults_[bug] self._resolution = result[0] - self._status = result[1] + self._fix = result[1] return data = None proxy = os.getenv("SYSTEST_PROXY", None) @@ -129,7 +121,6 @@ class JIRA: if bug in self.__bugs__: test.warning("Using internal dict - bug status could have changed already", "Please check manually!") - self._status = None self._resolution = None else: test.fatal("No workaround function deposited for %s" % bug) @@ -137,24 +128,25 @@ class JIRA: else: data = data.replace("\r", "").replace("\n", "") resPattern = re.compile('<span\s+id="resolution-val".*?>(?P<resolution>.*?)</span>') - statPattern = re.compile('<span\s+id="status-val".*?>(.*?<img.*?>)?(?P<status>.*?)</span>') - status = statPattern.search(data) resolution = resPattern.search(data) - if status: - self._status = status.group("status").strip() - else: - test.fatal("FATAL: Cannot get status of bugreport %s" % bug, - "Looks like JIRA has changed.... Please verify!") - self._status = None + fixVersion = 'None' + fixPattern = re.compile('<span.*?id="fixfor-val".*?>(?P<fix>.*?)</span>') + fix = fixPattern.search(data) + titlePattern = re.compile('title="(?P<title>.*?)"') + if fix: + fix = titlePattern.search(fix.group('fix').strip()) + if fix: + fixVersion = fix.group('title').strip() + self._fix = fixVersion if resolution: self._resolution = resolution.group("resolution").strip() else: test.fatal("FATAL: Cannot get resolution of bugreport %s" % bug, "Looks like JIRA has changed.... Please verify!") self._resolution = None - if None in (self._status, self._resolution): + if self._resolution == None: self.__cropAndLog__(data) - self._fetchResults_.update({bug:[self._resolution, self._status]}) + self._fetchResults_.update({bug:[self._resolution, self._fix]}) # simple helper function - used as fallback if python has no ssl support # tries to find curl or wget in PATH and fetches data with it instead of @@ -182,18 +174,11 @@ class JIRA: return fetched = " ".join(fetched.split()) resoInd = fetched.find('resolution-val') - statInd = fetched.find('status-val') - if resoInd == statInd == -1: - test.log("Neither resolution nor status found inside fetched data.", + if resoInd == -1: + test.log("Resolution not found inside fetched data.", "%s[...]" % fetched[:200]) else: - if resoInd == -1: - test.log("Fetched and cropped data: [...]%s[...]" % fetched[statInd-20:statInd+800]) - elif statInd == -1: - test.log("Fetched and cropped data: [...]%s[...]" % fetched[resoInd-720:resoInd+100]) - else: - test.log("Fetched and cropped data (status): [...]%s[...]" % fetched[statInd-20:statInd+300], - "Fetched and cropped data (resolution): [...]%s[...]" % fetched[resoInd-20:resoInd+100]) + test.log("Fetched and cropped data: [...]%s[...]" % fetched[resoInd-20:resoInd+100]) # this function initializes the bug dict for localOnly usage and # for later lookup which function to call for which bug diff --git a/tests/system/suite_debugger/tst_cli_output_console/test.py b/tests/system/suite_debugger/tst_cli_output_console/test.py index cabfa2aebb..ffb782d31d 100644 --- a/tests/system/suite_debugger/tst_cli_output_console/test.py +++ b/tests/system/suite_debugger/tst_cli_output_console/test.py @@ -46,7 +46,7 @@ def main(): test.log("Running application") setRunInTerminal(len(checkedTargets), kit, False) runControlFinished = False - clickButton(waitForObject("{type='Core::Internal::FancyToolButton' text='Run' visible='1'}")) + clickButton(waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton")) waitFor("runControlFinished==True", 20000) if not runControlFinished: test.warning("Waiting for runControlFinished timed out") @@ -65,7 +65,7 @@ def main(): isMsvc = isMsvcConfig(len(checkedTargets), kit) runControlFinished = False invokeMenuItem("Debug", "Start Debugging", "Start Debugging") - JIRA.performWorkaroundIfStillOpen(6853, JIRA.Bug.CREATOR, config) + JIRA.performWorkaroundForBug(6853, JIRA.Bug.CREATOR, config) handleDebuggerWarnings(config, isMsvc) waitFor("runControlFinished==True", 20000) if not runControlFinished: diff --git a/tests/system/suite_debugger/tst_simple_analyze/test.py b/tests/system/suite_debugger/tst_simple_analyze/test.py index 56ad572dd7..0fa530df76 100644 --- a/tests/system/suite_debugger/tst_simple_analyze/test.py +++ b/tests/system/suite_debugger/tst_simple_analyze/test.py @@ -1,10 +1,9 @@ source("../../shared/qtcreator.py") -workingDir = None - def main(): - global workingDir startApplication("qtcreator" + SettingsPath) + if not startedWithoutPluginError(): + return # using a temporary directory won't mess up a potentially existing workingDir = tempDir() checkedTargets, projectName = createNewQtQuickApplication(workingDir) diff --git a/tests/system/suite_debugger/tst_simple_debug/test.py b/tests/system/suite_debugger/tst_simple_debug/test.py index b5fd5fdc37..1a966a5172 100644 --- a/tests/system/suite_debugger/tst_simple_debug/test.py +++ b/tests/system/suite_debugger/tst_simple_debug/test.py @@ -1,9 +1,6 @@ source("../../shared/qtcreator.py") -workingDir = None - def main(): - global workingDir startApplication("qtcreator" + SettingsPath) if not startedWithoutPluginError(): return diff --git a/tests/system/suite_editors/tst_basic_cpp_support/test.py b/tests/system/suite_editors/tst_basic_cpp_support/test.py index 8837eca8c4..c48332e0e6 100644 --- a/tests/system/suite_editors/tst_basic_cpp_support/test.py +++ b/tests/system/suite_editors/tst_basic_cpp_support/test.py @@ -39,7 +39,7 @@ def main(): # Creator will show you the declaration of the variable. if platform.system() == "Darwin": - JIRA.performWorkaroundIfStillOpen(8735, JIRA.Bug.CREATOR, cppwindow) + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, cppwindow) type(cppwindow, "<Ctrl+F>") type(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit"), " xi") diff --git a/tests/system/suite_editors/tst_delete_externally/test.py b/tests/system/suite_editors/tst_delete_externally/test.py index 21bfaf3318..0d82dcaa87 100644 --- a/tests/system/suite_editors/tst_delete_externally/test.py +++ b/tests/system/suite_editors/tst_delete_externally/test.py @@ -3,12 +3,6 @@ source("../../shared/suites_qtta.py") global templateDir -def readFile(filename): - f = open(filename, "r") - content = f.read() - f.close() - return content - def copyToTemplateDir(filepath): global templateDir dst = os.path.join(templateDir, os.path.basename(filepath)) @@ -39,7 +33,7 @@ def main(): continue if platform.system() == 'Darwin': - JIRA.performWorkaroundIfStillOpen(8735, JIRA.Bug.CREATOR, editor) + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, editor) contentBefore = readFile(currentFile) popupText = "The file %s was removed. Do you want to save it under a different name, or close the editor?" os.remove(currentFile) diff --git a/tests/system/suite_editors/tst_revert_changes/test.py b/tests/system/suite_editors/tst_revert_changes/test.py index 159396c75c..8656b22416 100644 --- a/tests/system/suite_editors/tst_revert_changes/test.py +++ b/tests/system/suite_editors/tst_revert_changes/test.py @@ -63,7 +63,7 @@ def __modifyProFile__(): def __modifyHeader__(): global cppEditorStr, homeShortCut, endShortCut if platform.system() == "Darwin": - JIRA.performWorkaroundIfStillOpen(8735, JIRA.Bug.CREATOR, waitForObject(cppEditorStr, 1000)) + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, waitForObject(cppEditorStr, 1000)) if placeCursorToLine(cppEditorStr, "class.+", True): type(cppEditorStr, homeShortCut) markText(cppEditorStr, "Down", 5) diff --git a/tests/system/suite_editors/tst_select_all/test.py b/tests/system/suite_editors/tst_select_all/test.py index 9bdf546eeb..81f051a59a 100644 --- a/tests/system/suite_editors/tst_select_all/test.py +++ b/tests/system/suite_editors/tst_select_all/test.py @@ -30,7 +30,7 @@ def main(): "Skipping this file for now.") continue if platform.system() == 'Darwin': - JIRA.performWorkaroundIfStillOpen(8735, JIRA.Bug.CREATOR, editor) + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, editor) for key in ["<Up>", "<Down>", "<Left>", "<Right>"]: test.log("Selecting everything") invokeMenuItem("Edit", "Select All") diff --git a/tests/system/suite_general/suite.conf b/tests/system/suite_general/suite.conf index 19ee1d31df..3a75d120de 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_default_settings 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 tst_rename_file VERSION=2 WRAPPERS=Qt diff --git a/tests/system/suite_general/tst_rename_file/test.py b/tests/system/suite_general/tst_rename_file/test.py new file mode 100644 index 0000000000..fad2c7e78b --- /dev/null +++ b/tests/system/suite_general/tst_rename_file/test.py @@ -0,0 +1,78 @@ +source("../../shared/qtcreator.py") + +def main(): + # prepare example project + projectName = "declarative-music-browser" + sourceExample = os.path.join(sdkPath, "Examples", "QtMobility", projectName) + proFile = projectName + ".pro" + if not neededFilePresent(os.path.join(sourceExample, proFile)): + return + # copy example project to temp directory + templateDir = prepareTemplate(sourceExample) + + startApplication("qtcreator" + SettingsPath) + if not startedWithoutPluginError(): + return + usedProFile = os.path.join(templateDir, proFile) + openQmakeProject(usedProFile) + for filetype, filename in [["Headers", "utility.h"], + ["Sources", "main.cpp"], + ["Sources", "utility.cpp"], + ["Resources", "musicbrowser.qrc"], + ["QML", "musicbrowser.qml"]]: + filenames = ["ABCD" + filename.upper(), "abcd" + filename.lower(), "test", "TEST", filename] + if platform.system() == 'Darwin': + # avoid QTCREATORBUG-9197 + filtered = [filenames[0]] + for i in range(1, len(filenames)): + if filenames[i].lower() != filtered[-1].lower(): + filtered.append(filenames[i]) + filenames = filtered + for i in range(len(filenames)): + tempFiletype = filetype + if filetype == "QML" and filenames[i - 1][-4:] != ".qml": + tempFiletype = "Other files" + # workaround QTCREATORBUG-9191 + if filenames[i - 1][-4:].lower() == ".qml" and platform.system() in ('Windows', + 'Microsoft'): + tempFiletype = "QML" + renameFile(templateDir, usedProFile, projectName + "." + tempFiletype, + filenames[i - 1], filenames[i]) + invokeMenuItem("File", "Exit") + +def renameFile(projectDir, proFile, branch, oldname, newname): + oldFilePath = os.path.join(projectDir, oldname) + newFilePath = os.path.join(projectDir, newname) + oldFileText = readFile(oldFilePath) + itemText = branch + "." + oldname.replace(".", "\\.") + treeview = waitForObject(":Qt Creator_Utils::NavigationTreeView") + if platform.system() == 'Darwin': + JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, treeview) + try: + openItemContextMenu(treeview, itemText, 5, 5, 0) + except: + openItemContextMenu(treeview, addBranchWildcardToRoot(itemText), 5, 5, 0) + activateItem(waitForObjectItem(":Qt Creator.Project.Menu.File_QMenu", "Rename...")) + type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), newname) + type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), "<Return>") + test.verify(waitFor("os.path.exists(newFilePath)", 1000), + "Verify that file with new name exists: %s" % newFilePath) + if not (oldname.lower() == newname.lower() and platform.system() in ('Windows', 'Microsoft')): + test.verify(not os.path.exists(oldFilePath), + "Verify that file with old name does not exist: %s" % oldFilePath) + test.compare(readFile(newFilePath), oldFileText, + "Comparing content of file before and after renaming") + test.verify(waitFor("newname in safeReadFile(proFile)", 2000), + "Verify that new filename '%s' was added to pro-file." % newname) + if not oldname in newname: + test.verify(not oldname in readFile(proFile), + "Verify that old filename '%s' was removed from pro-file." % oldname) + +def safeReadFile(filename): + text = "" + while text == "": + try: + text = readFile(filename) + except: + pass + return text diff --git a/tests/system/tools/findUnusedObjects.py b/tests/system/tools/findUnusedObjects.py index dfa8d28333..811660d526 100755 --- a/tests/system/tools/findUnusedObjects.py +++ b/tests/system/tools/findUnusedObjects.py @@ -8,6 +8,8 @@ from toolfunctions import checkDirectory from toolfunctions import getFileContent objMap = None +lastToken = [None, None] +stopTokens = ('OP', 'NAME', 'NUMBER', 'ENDMARKER') def parseCommandLine(): global directory, onlyRemovable, fileType @@ -44,12 +46,32 @@ def getFileSuffix(): 'Tcl':'.tcl', 'Ruby':'.rb'} return fileSuffixes.get(fileType, None) +def handleStringsWithTrailingBackSlash(origStr): + try: + while True: + index = origStr.index("\\\n") + origStr = origStr[:index] + origStr[index+2:].lstrip() + except: + return origStr + def handle_token(tokenType, token, (startRow, startCol), (endRow, endCol), line): - global useCounts + global useCounts, lastToken, stopTokens + if tokenize.tok_name[tokenType] == 'STRING': - for obj in useCounts: - useCounts[obj] += str(token).count("'%s'" % obj) - useCounts[obj] += str(token).count('"%s"' % obj) + # concatenate strings followed directly by other strings + if lastToken[0] == 'STRING': + token = "'" + lastToken[1][1:-1] + str(token)[1:-1] + "'" + # store the new string as lastToken after removing potential trailing backslashes + # (including their following indentation) + lastToken = ['STRING' , handleStringsWithTrailingBackSlash(str(token))] + # if a stop token occurs check the potential string before it + elif tokenize.tok_name[tokenType] in stopTokens: + if lastToken[0] == 'STRING': + for obj in useCounts: + useCounts[obj] += lastToken[1].count("'%s'" % obj) + useCounts[obj] += lastToken[1].count('"%s"' % obj) + # store the stop token as lastToken + lastToken = [tokenize.tok_name[tokenType], str(token)] def findUsages(): global directory, objMap |