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>
This commit is contained in:
Robert Löhning
2021-04-21 20:43:09 +02:00
parent 5bf2bfedb0
commit 8d813b8864
4 changed files with 28 additions and 14 deletions

View File

@@ -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.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.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.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_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.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'} :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::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::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_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_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_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'} :Qt Creator_HelpSelector_QComboBox {occurrence='3' type='QComboBox' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}

View File

@@ -64,33 +64,40 @@ def takeDebuggerLog():
# function to set breakpoints for the current project # function to set breakpoints for the current project
# on the given file,line pairs inside the given list of dicts # on the given file,line pairs inside the given list of dicts
# the lines are treated as regular expression # 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): def setBreakpointsForCurrentProject(filesAndLines):
switchViewTo(ViewConstants.DEBUG) switchViewTo(ViewConstants.DEBUG)
removeOldBreakpoints() removeOldBreakpoints()
if not filesAndLines or not isinstance(filesAndLines, (list,tuple)): if not filesAndLines or not isinstance(filesAndLines, (list,tuple)):
test.fatal("This function only takes a non-empty list/tuple holding dicts.") 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' " waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}") "window=':Qt Creator_Core::Internal::MainWindow'}")
breakPointList = []
for current in filesAndLines: for current in filesAndLines:
for curFile,curLine in current.iteritems(): for curFile,curLine in current.iteritems():
if not openDocument(curFile): if not openDocument(curFile):
return False return None
editor = getEditorForFileSuffix(curFile, True) editor = getEditorForFileSuffix(curFile, True)
if not placeCursorToLine(editor, curLine, True): if not placeCursorToLine(editor, curLine, True):
return False return None
invokeMenuItem("Debug", "Toggle Breakpoint") 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) test.log('Set breakpoint in %s' % curFile, curLine)
try: try:
breakPointTreeView = waitForObject(":Breakpoints_Debugger::Internal::BreakTreeView") breakPointTreeView = waitForObject(":Breakpoints_Debugger::Internal::BreakTreeView")
waitFor("breakPointTreeView.model().rowCount() == len(filesAndLines)", 2000) waitFor("breakPointTreeView.model().rowCount() == len(filesAndLines)", 2000)
except: except:
test.fatal("UI seems to have changed - check manually and fix this script.") test.fatal("UI seems to have changed - check manually and fix this script.")
return False return None
test.compare(breakPointTreeView.model().rowCount(), len(filesAndLines), test.compare(breakPointTreeView.model().rowCount(), len(filesAndLines),
'Expected %d set break points, found %d listed' % 'Expected %d set break points, found %d listed' %
(len(filesAndLines), breakPointTreeView.model().rowCount())) (len(filesAndLines), breakPointTreeView.model().rowCount()))
return True return breakPointList
# helper that removes all breakpoints - assumes that it's getting called # helper that removes all breakpoints - assumes that it's getting called
# being already on Debug view and Breakpoints widget is not disabled # 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 # 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 # only 1 key:value pair - the key is the name of the file, the value is
# line number where the debugger should stop # 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): def doSimpleDebugging(currentKit, currentConfigName, expectedBPOrder=[], enableQml=True):
expectedLabelTexts = ['Stopped\.', 'Stopped at breakpoint \d+ in thread \d+\.'] expectedLabelTexts = ['Stopped\.', 'Stopped at breakpoint \d+ in thread \d+\.']
if len(expectedBPOrder) == 0: if len(expectedBPOrder) == 0:
@@ -236,8 +245,7 @@ def verifyBreakPoint(bpToVerify):
if editor: if editor:
test.compare(waitForObject(":DebugModeWidget_QComboBox").toolTip, fileName, test.compare(waitForObject(":DebugModeWidget_QComboBox").toolTip, fileName,
"Verify that the right file is opened") "Verify that the right file is opened")
textPos = editor.textCursor().position() line = lineNumberWithCursor(editor)
line = str(editor.plainText)[:textPos].count("\n") + 1
windowTitle = str(waitForObject(":Qt Creator_Core::Internal::MainWindow").windowTitle) windowTitle = str(waitForObject(":Qt Creator_Core::Internal::MainWindow").windowTitle)
test.verify(windowTitle.startswith(os.path.basename(fileName) + " "), test.verify(windowTitle.startswith(os.path.basename(fileName) + " "),
"Verify that Creator's window title changed according to current file") "Verify that Creator's window title changed according to current file")

View File

@@ -62,6 +62,13 @@ def placeCursorToLine(editor, line, isRegex=False):
type(getEditor(), "<End>") type(getEditor(), "<End>")
return True 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 # this function returns True if a QMenu is
# popped up above the given editor # popped up above the given editor
# param editor is the editor where the menu should appear # param editor is the editor where the menu should appear

View File

@@ -44,14 +44,12 @@ def main():
'onTriggered: console.log("Break here")']) 'onTriggered: console.log("Break here")'])
invokeMenuItem("File", "Save All") invokeMenuItem("File", "Save All")
filesAndLines = [ 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") test.log("Setting breakpoints")
result = setBreakpointsForCurrentProject(filesAndLines) expectedBreakpointsOrder = setBreakpointsForCurrentProject(filesAndLines)
if result: if expectedBreakpointsOrder:
expectedBreakpointsOrder = [{os.path.join(workingDir, projectName, "main.cpp"):13},
{os.path.join(workingDir, projectName, "main.qml"):13}]
availableConfigs = iterateBuildConfigs("Debug") availableConfigs = iterateBuildConfigs("Debug")
progressBarWait() progressBarWait()
if not availableConfigs: if not availableConfigs: