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

Improved testing of id renaming.

Change-Id: If1312fdbd9f8c934b8412289ede457032131fc42
Reviewed-on: http://codereview.qt-project.org/5533

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
parent 84a535ba
......@@ -20,7 +20,7 @@ def prepareTemplate():
global templateDir
templateDir = tempDir()
templateDir = os.path.abspath(templateDir + "/template")
sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/keyinteraction/focus")
shutil.copytree(sourceExample, templateDir)
def createNewQtQuickApplication():
......@@ -49,7 +49,7 @@ def createNewQtQuickApplication():
chooseComponents(QtQuickConstants.Components.EXISTING_QML)
# define the existing qml file to import
baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
type(baseLineEd, templateDir+"/qml/textselection.qml")
type(baseLineEd, templateDir+"/qml/focus.qml")
clickButton(nextButton)
chooseDestination()
snooze(1)
......@@ -61,14 +61,16 @@ def testRenameId():
navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
model = navTree.model()
treeElement = ("untitled.QML.%s/qml.textselection\\.qml" %
templateDir.replace("\\", "/").replace("_", "\\_"))
waitForObjectItem(navTree, treeElement)
doubleClickItem(navTree, treeElement, 5, 5, 0, Qt.LeftButton)
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
originalText = "%s" % editor.plainText
line = "TextEdit\s*\{"
files = ["Core.ContextMenu\\.qml", "Core.GridMenu\\.qml", "Core.ListMenu\\.qml", "focus\\.qml"]
originalTexts = {}
for file in files:
doubleClickFile(navTree, file)
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
originalTexts.setdefault(file, "%s" % editor.plainText)
test.log("stored %s's content" % file.replace("Core.","").replace("\\",""))
# last opened file is the main file focus.qml
line = "FocusScope\s*\{"
if not placeCursorToLine(editor, line, True):
test.fatal("File seems to have changed... Canceling current test")
return False
......@@ -77,14 +79,23 @@ def testRenameId():
activateItem(waitForObjectItem("{type='QMenu' visible='1' unnamed='1'}", "Rename Symbol Under Cursor"))
type(waitForObject("{leftWidget={text='Replace with:' type='QLabel' unnamed='1' visible='1'} "
"type='Find::Internal::WideEnoughLineEdit' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}"), "halloballo")
"window=':Qt Creator_Core::Internal::MainWindow'}"), "renamedView")
clickButton(waitForObject("{text='Replace' type='QToolButton' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}"))
modifiedText = "%s" % editor.plainText
originalText = "%s" % (originalText.replace("editor", "__EDITOR__").replace("edit", "halloballo")
.replace("__EDITOR__", "editor"))
test.compare(originalText,modifiedText)
type(editor, "<Ctrl+S>")
for file in files:
doubleClickFile(navTree, file)
editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
modifiedText = "%s" % editor.plainText
originalText = originalTexts.get(file).replace("mainView", "renamedView")
test.compare(originalText,modifiedText)
type(editor, "<Ctrl+S>")
def doubleClickFile(navTree, file):
treeElement = ("untitled.QML.%s/qml.%s" %
(templateDir.replace("\\", "/").replace("_", "\\_"),file))
waitForObjectItem(navTree, treeElement)
doubleClickItem(navTree, treeElement, 5, 5, 0, Qt.LeftButton)
def cleanup():
global workingDir, templateDir
......
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