Commit 591754be authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: Fix minor bugs (mostly on Mac)



This avoids some timing issues as well as a problem
I only saw on Mac: Sometimes Squish fails inside
placeCursorToLine() with 'I don't know how to type on
object of type QmlJSEditor::QmlJSTextEditorWidget'.

Change-Id: Ifc192914375fb37362fa31399be4972c9ce50b92
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
Reviewed-by: default avatarBill King <bill.king@nokia.com>
parent e5bdac6e
......@@ -13,14 +13,13 @@ def placeCursorToLine(editor,line,isRegex=False):
found = False
if isRegex:
regex = re.compile(line)
editorRealName = objectMap.realName(editor)
while not found:
currentLine = str(lineUnderCursor(editor)).strip()
if isRegex:
if regex.match(currentLine):
found = True
else:
type(editor, "<Down>")
moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor)
if oldPosition==editor.textCursor().position():
break
oldPosition = editor.textCursor().position()
......@@ -28,7 +27,7 @@ def placeCursorToLine(editor,line,isRegex=False):
if currentLine==line:
found = True
else:
type(editorRealName, "<Down>")
moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor)
if oldPosition==editor.textCursor().position():
break
oldPosition = editor.textCursor().position()
......@@ -40,6 +39,21 @@ def placeCursorToLine(editor,line,isRegex=False):
editor.setTextCursor(cursor)
return True
# this function moves the text cursor of an editor by using Qt internal functions
# this is more reliable (especially on Mac) than the type() approach
# param editor an editor object
# param moveOperation a value of enum MoveOperation (of QTextCursor)
# param moveAnchor a value of enum MoveMode (of QTextCursor)
# param n how often repeat the move operation?
def moveTextCursor(editor, moveOperation, moveAnchor, n=1):
if not editor or isinstance(editor, (str,unicode)):
test.fatal("Either got a NoneType or a string instead of an editor object")
return False
textCursor = editor.textCursor()
result = textCursor.movePosition(moveOperation, moveAnchor, n)
editor.setTextCursor(textCursor)
return result
# this function returns True if a QMenu is
# popped up above the given editor
# param editor is the editor where the menu should appear
......
......@@ -137,8 +137,8 @@ def validateSearchResult(expectedCount):
doubleClick(resultTreeView, rect.x+5, rect.y+5, 0, Qt.LeftButton)
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
line = lineUnderCursor(editor)
test.compare(line, text)
waitFor("lineUnderCursor(editor) == text", 2000)
test.compare(lineUnderCursor(editor), text)
def testHovering():
navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
......@@ -167,7 +167,6 @@ def testHovering():
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
lines = ['focus:\s*true', 'color:\s*"black"', 'states:\s*State\s*\{', 'transitions:\s*Transition\s*\{']
additionalKeyPresses = [home, "<Right>"]
expectedTypes = ["TextTip", "TextTip", "TextTip", "TextTip"]
expectedValues = [
{'text':'<table><tr><td valign=middle>boolean<p>This property indicates whether the item has focus '
......@@ -189,9 +188,9 @@ def testHovering():
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
lines=['color:\s*"black"', 'color:\s*"#3E606F"']
additionalKeyPresses = ["<Left>"]
expectedValues = ["black", "#3E606F"]
expectedTypes = ["ColorTip", "ColorTip"]
additionalKeyPresses = ["<Left>"]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
doubleClickFile(navTree, "Core.ListMenu\\.qml")
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
......@@ -208,6 +207,17 @@ def doubleClickFile(navTree, file):
(maskSpecialCharsForProjectTree(templateDir),file))
waitForObjectItem(navTree, treeElement)
doubleClickItem(navTree, treeElement, 5, 5, 0, Qt.LeftButton)
mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
name = __getUnmaskedFilename__(file)
waitFor("name in str(mainWindow.windowTitle)")
def __getUnmaskedFilename__(maskedFilename):
name = maskedFilename.split("\\.")
path = name[0].rsplit(".", 1)
if len(path) < 2:
return ".".join(name)
else:
return ".".join((path[1], ".".join(name[1:])))
def maskSpecialCharsForProjectTree(filename):
filename = filename.replace("\\", "/").replace("_", "\\_").replace(".","\\.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment