diff options
author | Robert Löhning <robert.loehning@qt.io> | 2021-04-21 20:43:09 +0200 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2021-04-23 09:45:06 +0000 |
commit | 8d813b88646f257de59a2f6d1ff2ee94eb79a05c (patch) | |
tree | ce9a257b596df5b02a1fa8fff0d3e11c01f71c9f | |
parent | 5bf2bfedb0bf502320306cae2fd66f7d4cbeeeff (diff) | |
download | qt-creator-8d813b88646f257de59a2f6d1ff2ee94eb79a05c.tar.gz |
Squish: Remember where breakpoints are
So we don't have to update the test each time
Creator changes the project templates.
Change-Id: I76f96f719895f2f8cadccaf9c91cc85d1735ce13
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | tests/system/objects.map | 3 | ||||
-rw-r--r-- | tests/system/shared/debugger.py | 22 | ||||
-rw-r--r-- | tests/system/shared/editor_utils.py | 7 | ||||
-rw-r--r-- | tests/system/suite_debugger/tst_simple_debug/test.py | 10 |
4 files changed, 28 insertions, 14 deletions
diff --git a/tests/system/objects.map b/tests/system/objects.map index 817db13c37..0bf27cb455 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -122,6 +122,7 @@ :Qt Creator.Compile Output_Core::OutputWindow {type='Core::OutputWindow' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Compile Output'} :Qt Creator.Configure Project_QPushButton {text='Configure Project' type='QPushButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.DebugModeWidget_QSplitter {name='DebugModeWidget' type='QSplitter' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.DragDoc_QToolButton {toolTip='Drag to drag documents between splits' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.Events_QDockWidget {name='QmlProfiler.Statistics.DockDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator.Events_QTabBar {aboveWidget=':Qt Creator.Events_QDockWidget' type='QTabBar' 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'} @@ -154,7 +155,7 @@ :Qt Creator_DiffEditor::Internal::DescriptionEditorWidget {type='DiffEditor::Internal::DescriptionEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_DiffEditor::SideDiffEditorWidget {type='DiffEditor::Internal::SideDiffEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_DiffEditor::SideDiffEditorWidget2 {occurrence='2' type='DiffEditor::Internal::SideDiffEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} -:Qt Creator_FilenameQComboBox {type='QComboBox' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator_FilenameQComboBox {leftWidget=':Qt Creator.DragDoc_QToolButton' type='QComboBox' unnamed='1' visible='1'} :Qt Creator_Find::Internal::SearchResultTreeView {type='Core::Internal::SearchResultTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_Git::Internal::GitEditor {type='Git::Internal::GitEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_HelpSelector_QComboBox {occurrence='3' type='QComboBox' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py index a52876f34f..4ab2473c44 100644 --- a/tests/system/shared/debugger.py +++ b/tests/system/shared/debugger.py @@ -64,33 +64,40 @@ def takeDebuggerLog(): # function to set breakpoints for the current project # on the given file,line pairs inside the given list of dicts # the lines are treated as regular expression +# returns None on error or a list of dictionaries each containing full path and line number of a +# single breakpoint +# If you passed in the breakpoints in the right order, you can use the return value as input to +# doSimpleDebugging() def setBreakpointsForCurrentProject(filesAndLines): switchViewTo(ViewConstants.DEBUG) removeOldBreakpoints() if not filesAndLines or not isinstance(filesAndLines, (list,tuple)): test.fatal("This function only takes a non-empty list/tuple holding dicts.") - return False + return None waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' " "window=':Qt Creator_Core::Internal::MainWindow'}") + breakPointList = [] for current in filesAndLines: for curFile,curLine in current.iteritems(): if not openDocument(curFile): - return False + return None editor = getEditorForFileSuffix(curFile, True) if not placeCursorToLine(editor, curLine, True): - return False + return None invokeMenuItem("Debug", "Toggle Breakpoint") + filePath = str(waitForObjectExists(":Qt Creator_FilenameQComboBox").toolTip) + breakPointList.append({os.path.normcase(filePath):lineNumberWithCursor(editor)}) test.log('Set breakpoint in %s' % curFile, curLine) try: breakPointTreeView = waitForObject(":Breakpoints_Debugger::Internal::BreakTreeView") waitFor("breakPointTreeView.model().rowCount() == len(filesAndLines)", 2000) except: test.fatal("UI seems to have changed - check manually and fix this script.") - return False + return None test.compare(breakPointTreeView.model().rowCount(), len(filesAndLines), 'Expected %d set break points, found %d listed' % (len(filesAndLines), breakPointTreeView.model().rowCount())) - return True + return breakPointList # helper that removes all breakpoints - assumes that it's getting called # being already on Debug view and Breakpoints widget is not disabled @@ -119,6 +126,8 @@ def removeOldBreakpoints(): # param expectedBPOrder holds a list of dicts where the dicts contain always # only 1 key:value pair - the key is the name of the file, the value is # line number where the debugger should stop +# This can be the return value of setBreakpointsForCurrentProject() if you +# passed the breakpoints into that function in the right order def doSimpleDebugging(currentKit, currentConfigName, expectedBPOrder=[], enableQml=True): expectedLabelTexts = ['Stopped\.', 'Stopped at breakpoint \d+ in thread \d+\.'] if len(expectedBPOrder) == 0: @@ -236,8 +245,7 @@ def verifyBreakPoint(bpToVerify): if editor: test.compare(waitForObject(":DebugModeWidget_QComboBox").toolTip, fileName, "Verify that the right file is opened") - textPos = editor.textCursor().position() - line = str(editor.plainText)[:textPos].count("\n") + 1 + line = lineNumberWithCursor(editor) windowTitle = str(waitForObject(":Qt Creator_Core::Internal::MainWindow").windowTitle) test.verify(windowTitle.startswith(os.path.basename(fileName) + " "), "Verify that Creator's window title changed according to current file") diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index db59353883..9af1302848 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -62,6 +62,13 @@ def placeCursorToLine(editor, line, isRegex=False): type(getEditor(), "<End>") return True +# returns the number of the text line where the cursor is, starting at line 1 +# param editor is the editor the cursor is in +def lineNumberWithCursor(editor): + textPos = editor.textCursor().position() + line = str(editor.plainText)[:textPos].count("\n") + 1 + return line + # this function returns True if a QMenu is # popped up above the given editor # param editor is the editor where the menu should appear diff --git a/tests/system/suite_debugger/tst_simple_debug/test.py b/tests/system/suite_debugger/tst_simple_debug/test.py index 0d6fb8ea72..97f4420cf8 100644 --- a/tests/system/suite_debugger/tst_simple_debug/test.py +++ b/tests/system/suite_debugger/tst_simple_debug/test.py @@ -44,14 +44,12 @@ def main(): 'onTriggered: console.log("Break here")']) invokeMenuItem("File", "Save All") filesAndLines = [ - { "%s.Resources.qml\.qrc./.main\\.qml" % projectName : 'onTriggered.*' }, - { "%s.Sources.main\\.cpp" % projectName : "QQmlApplicationEngine engine;" } + { "%s.Sources.main\\.cpp" % projectName : "QQmlApplicationEngine engine;" }, + { "%s.Resources.qml\.qrc./.main\\.qml" % projectName : 'onTriggered.*' } ] test.log("Setting breakpoints") - result = setBreakpointsForCurrentProject(filesAndLines) - if result: - expectedBreakpointsOrder = [{os.path.join(workingDir, projectName, "main.cpp"):13}, - {os.path.join(workingDir, projectName, "main.qml"):13}] + expectedBreakpointsOrder = setBreakpointsForCurrentProject(filesAndLines) + if expectedBreakpointsOrder: availableConfigs = iterateBuildConfigs("Debug") progressBarWait() if not availableConfigs: |