Commit fb21ad4d authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: Added FindUsages test to QML test



Change-Id: I2571bf1e87d34495dc4299f04d310f894d22e38d
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
parent feaf023f
......@@ -23,10 +23,11 @@
:Qt Creator.ReRun_QToolButton {toolTip='Re-run this run-configuration' type='QToolButton' 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.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton {occurrence='3' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' visible='1' windowTitle?='*Qt Creator'}
:Qt Creator_Core::Internal::OutputPaneToggleButton {occurrence='3' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_CppEditor::Internal::CPPEditorWidget {type='CppEditor::Internal::CPPEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_QTableView {type='QTableView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_SearchResult_Core::Internal::OutputPaneToggleButton {occurrence='2' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::IconButton {occurrence='2' type='Utils::IconButton' 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 Gui Application.Form file:_QLabel {name='formLabel' text='Form file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
......
......@@ -9,6 +9,7 @@ def placeCursorToLine(editor,line,isRegex=False):
cursor = editor.textCursor()
oldPosition = 0
cursor.setPosition(oldPosition)
editor.setTextCursor(cursor)
found = False
if isRegex:
regex = re.compile(line)
......
......@@ -277,7 +277,7 @@ def validType(sType, userDef):
return ty != None and not (ty == "user-defined" and (userDef == None or userDef.strip() == ""))
def __closeSubprocessByPushingStop__(sType):
ensureChecked(":Qt Creator_Core::Internal::OutputPaneToggleButton")
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
playButton = verifyEnabled(":Qt Creator.ReRun_QToolButton", False)
stopButton = verifyEnabled(":Qt Creator.Stop_QToolButton")
if stopButton.enabled:
......@@ -293,7 +293,7 @@ def __closeSubprocessByPushingStop__(sType):
def __closeSubprocessByHookingInto__(executable, port, function, sType, userDefType):
global processExited
ensureChecked(":Qt Creator_Core::Internal::OutputPaneToggleButton")
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
output = waitForObject("{type='Core::OutputWindow' visible='1' windowTitle='Application Output Window'}", 20000)
if port == None:
test.warning("I need a port number or attaching might fail.")
......
......@@ -17,7 +17,7 @@ def main():
# wait for parsing to complete
waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
testRenameId()
testFindUsages()
invokeMenuItem("File", "Exit")
def prepareTemplate(sourceExample):
......@@ -78,7 +78,58 @@ def testRenameId():
test.compare(originalText,formerTxt, "Comparing %s" % file.replace("Core.","").replace("\\",""))
invokeMenuItem("File","Save All")
def __invokeFindUsage__(treeView, filename, line, typings, expectedCount):
doubleClickFile(treeView, filename)
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
if not placeCursorToLine(editor, line, True):
test.fatal("File seems to have changed... Canceling current test")
return
for ty in typings:
type(editor, ty)
openContextMenuOnTextCursorPosition(editor)
ctxtMenu = waitForObject("{type='QMenu' visible='1' unnamed='1'}")
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Find Usages"))
validateSearchResult(expectedCount)
def testFindUsages():
test.log("Testing find usage of an ID")
navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
__invokeFindUsage__(navTree, "focus\\.qml", "FocusScope\s*\{", ["<Down>"], 6)
test.log("Testing find usage of a property")
clickButton(waitForObject("{type='QToolButton' text='Clear' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}"))
__invokeFindUsage__(navTree, "focus\\.qml", "id: window", ["<Down>", "<Down>", "<Home>"], 26)
def validateSearchResult(expectedCount):
searchResult = waitForObject(":Qt Creator_SearchResult_Core::Internal::OutputPaneToggleButton")
ensureChecked(searchResult)
resultTreeView = waitForObject("{type='Find::Internal::SearchResultTreeView' unnamed='1' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}")
counterLabel = waitForObject("{type='QLabel' unnamed='1' visible='1' text?='*matches found.' "
"window=':Qt Creator_Core::Internal::MainWindow'}")
matches = cast((str(counterLabel.text)).split(" ", 1)[0], "int")
test.verify(matches==expectedCount, "Verfified match count.")
model = resultTreeView.model()
for row in range(model.rowCount()):
index = model.index(row, 0)
itemText = str(model.data(index).toString())
doubleClickItem(resultTreeView, maskSpecialCharsForSearchResult(itemText), 5, 5, 0, Qt.LeftButton)
test.log("%d occurrences in %s" % (model.rowCount(index), itemText))
for chRow in range(model.rowCount(index)):
chIndex = model.index(chRow, 0, index)
resultTreeView.scrollTo(chIndex)
text = str(chIndex.data())
rect = resultTreeView.visualRect(chIndex)
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)
def doubleClickFile(navTree, file):
global templateDir
treeElement = ("untitled.QML.%s/qml.%s" %
(maskSpecialCharsForProjectTree(templateDir),file))
waitForObjectItem(navTree, treeElement)
......@@ -90,6 +141,10 @@ def maskSpecialCharsForProjectTree(filename):
filename = filename.replace("/?","\\?").replace("/*","\\*")
return filename
def maskSpecialCharsForSearchResult(filename):
filename = filename.replace("_", "\\_").replace(".","\\.")
return filename
def cleanup():
global workingDir, templateDir
waitForCleanShutdown()
......
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