Commit 9186d1ac authored by Jan Kerekes's avatar Jan Kerekes Committed by Robert Löhning
Browse files

Added new test cases (QMLS03, QMLS04, QMLS05) for QMLS suite



initial commit

Change-Id: I955f7ca471541d4fb9c8505eb041b433cbff8b84
Reviewed-by: default avatarChristian Stenger <christian.stenger@nokia.com>
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
parent 02e08c61
:Behavior.Autocomplete common prefix_QCheckBox {container=':CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox' name='partiallyComplete' text='Autocomplete common prefix' type='QCheckBox' visible='1'}
:Behavior.completionTrigger_QComboBox {container=':CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox' name='completionTrigger' type='QComboBox' visible='1'}
:CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox {container=':qt_tabwidget_stackedwidget.CppTools__Internal__CompletionSettingsPage_QWidget' name='groupBox' title='Behavior' type='QGroupBox' visible='1'}
:Dialog.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Dialog_QmlJSEditor::Internal::ComponentNameDialog'}
:Dialog.componentNameEdit_QLineEdit {name='componentNameEdit' type='QLineEdit' visible='1' window=':Dialog_QmlJSEditor::Internal::ComponentNameDialog'}
:Dialog_QmlJSEditor::Internal::ComponentNameDialog {name='QmlJSEditor__Internal__ComponentNameDialog' type='QmlJSEditor::Internal::ComponentNameDialog' visible='1' windowTitle='Dialog'}
:New Qt Quick Application.Add to version control:_QLabel {name='addToVersionControlLabel' text='Add to version control:' type='QLabel' visible='1'}
:Next_QPushButton {name='__qt__passive_wizardbutton1' text~='(Next.*|Continue)' type='QPushButton' visible='1'}
:Options.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Options_Core::Internal::SettingsDialog'}
......@@ -8,9 +11,13 @@
:Options.qt_tabwidget_tabbar_QTabBar {name='qt_tabwidget_tabbar' type='QTabBar' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Options_Core::Internal::SettingsDialog {type='Core::Internal::SettingsDialog' unnamed='1' visible='1' windowTitle~='(Options|Preferences)'}
:Options_QListView {type='QListView' unnamed='1' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Qt Creator.Clear_QToolButton {text='Clear' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Create Build Configurations:_QComboBox {leftWidget=':Qt Creator.Create Build Configurations:_QLabel' type='QComboBox' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Create Build Configurations:_QLabel {text='Create build configurations:' type='QLabel' 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.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' unnamed='1' visible='1'}
:Qt Creator_Find::Internal::SearchResultTreeView {type='Find::Internal::SearchResultTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_QmlJSEditor::QmlJSTextEditorWidget {type='QmlJSEditor::QmlJSTextEditorWidget' 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'}
:addToVersionControlComboBox_QComboBox {buddy=':New Qt Quick Application.Add to version control:_QLabel' name='addToVersionControlComboBox' type='QComboBox' visible='1'}
......
......@@ -5,6 +5,6 @@ ENVVARS=envvars
HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
TEST_CASES=tst_QMLS01 tst_QMLS02
TEST_CASES=tst_QMLS01 tst_QMLS02 tst_QMLS03 tst_QMLS04 tst_QMLS05
VERSION=2
WRAPPERS=Qt
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
class ExpectedResult:
def __init__(self, file, lineNumber, lineContent):
self.file = file
self.lineNumber = lineNumber
self.lineContent = lineContent
# check if usage in code (expectedText) is found in resultsView
def checkUsages(resultsView, expectedResults):
# wait for results
resultsModel = resultsView.model()
waitFor("resultsModel.rowCount() > 0", 5000)
expectedResultIndex = 0
for row in range(resultsModel.rowCount()):
# enum Roles { ResultItemRole = Qt::UserRole, ResultLineRole, ResultLineNumberRole, ResultIconRole,
# SearchTermStartRole, SearchTermLengthRole, IsGeneratedRole };
index = resultsModel.index(row, 0)
# get only filename not full path
resultFile = str(index.data(Qt.UserRole + 1).toString()).replace("\\", "/").split('/')[-1]
for chRow in range(resultsModel.rowCount(index)):
chIndex = resultsModel.index(chRow, 0, index)
resultLine = str(chIndex.data(Qt.UserRole + 1).toString()).strip()
resultLineNumber = chIndex.data(Qt.UserRole + 2).toInt()
# verify if we don't get more results
if expectedResultIndex >= len(expectedResults):
test.log("More results than expected")
return False
# check expected text
if (not test.compare(expectedResults[expectedResultIndex].file, resultFile, "Result file comparison") or
not test.compare(expectedResults[expectedResultIndex].lineNumber, resultLineNumber, "Result line number comparison") or
not test.compare(expectedResults[expectedResultIndex].lineContent, resultLine, "Result line content comparison")):
return False
expectedResultIndex += 1
# verify if we get all results
if expectedResultIndex < len(expectedResults):
test.log("Less results than expected")
return False
return True
def main():
# prepare example project
sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/animation/basics/property-animation")
if not neededFilePresent(sourceExample):
return
# copy example project to temp directory
templateDir = prepareTemplate(sourceExample)
examplePath = templateDir + "/propertyanimation.pro"
startApplication("qtcreator" + SettingsPath)
# open example project
openQmakeProject(examplePath)
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation.QML.qml.color-animation\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# 1. check usages using context menu
# place cursor to component
if not placeCursorToLine(editorArea, "Rectangle {"):
invokeMenuItem("File", "Exit")
return
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Find Usages"))
# check if usage was properly found
expectedResults = [ExpectedResult("color-animation.qml", 49, "Rectangle {"),
ExpectedResult("color-animation.qml", 96, "Rectangle {"),
ExpectedResult("property-animation.qml", 48, "Rectangle {"),
ExpectedResult("property-animation.qml", 57, "Rectangle {")]
resultsView = waitForObject(":Qt Creator_Find::Internal::SearchResultTreeView")
test.verify(checkUsages(resultsView, expectedResults), "Verifying if usages were properly found using context menu.")
# clear previous results & prepare for next search
clickButton(waitForObject(":Qt Creator.Clear_QToolButton"))
mouseClick(editorArea, 5, 5, 0, Qt.LeftButton)
# 2. check usages using menu
# place cursor to component
if not placeCursorToLine(editorArea, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"):
invokeMenuItem("File", "Exit")
return
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 87)
invokeMenuItem("Tools", "QML/JS", "Find Usages")
# check if usage was properly found
expectedResults = [ExpectedResult("color-animation.qml", 50, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"),
ExpectedResult("color-animation.qml", 97, "anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }"),
ExpectedResult("property-animation.qml", 49, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"),
ExpectedResult("property-animation.qml", 58, "anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }")]
resultsView = waitForObject(":Qt Creator_Find::Internal::SearchResultTreeView")
test.verify(checkUsages(resultsView, expectedResults), "Verifying if usages were properly found using main menu.")
# clear previous results & prepare for next search
clickButton(waitForObject(":Qt Creator.Clear_QToolButton"))
mouseClick(editorArea, 5, 5, 0, Qt.LeftButton)
# 3. check usages using keyboard shortcut
# place cursor to component
if not placeCursorToLine(editorArea, "SequentialAnimation on opacity {"):
invokeMenuItem("File", "Exit")
return
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
type(editorArea, "<Ctrl+Shift+U>")
# check if usage was properly found
expectedResults = [ExpectedResult("color-animation.qml", 87, "SequentialAnimation on opacity {")]
resultsView = waitForObject(":Qt Creator_Find::Internal::SearchResultTreeView")
test.verify(checkUsages(resultsView, expectedResults), "Verifying if usages were properly found using shortcut.")
#save and exit
invokeMenuItem("File", "Exit")
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
projectDir = tempDir()
createNewQtQuickApplication(projectDir, "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# place cursor to component
if not placeCursorToLine(editorArea, "Text {"):
invokeMenuItem("File", "Exit")
return
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
# invoke Refactoring - Move Component into separate file
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Move Component into separate file"))
# give component name and proceed
replaceEditorContent(waitForObject(":Dialog.componentNameEdit_QLineEdit"), "MyComponent")
clickButton(waitForObject(":Dialog.OK_QPushButton"))
# verify if refactoring is done correctly
waitFor("'MyComponent' in str(editorArea.plainText)", 2000)
codeText = str(editorArea.plainText)
patternCodeToAdd = "MyComponent\s+\{\s*\}"
patternCodeToMove = "Text\s+\{.*\}"
# there should be empty MyComponent item instead of Text item
if re.search(patternCodeToAdd, codeText, re.DOTALL) and not re.search(patternCodeToMove, codeText, re.DOTALL):
test.passes("Refactoring was properly applied in source file")
else:
test.fail("Refactoring of Text to MyComponent failed in source file. Content of editor:\n%s" % codeText)
# there should be new QML file generated with name "MyComponent.qml"
try:
waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.MyComponent\\.qml", 3000)
test.passes("Refactoring - file MyComponent.qml was generated properly in project explorer")
except:
test.fail("Refactoring failed - file MyComponent.qml was not generated properly in project explorer")
#save and exit
invokeMenuItem("File", "Save All")
invokeMenuItem("File", "Exit")
# select MyComponent.qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.MyComponent\\.qml", 5, 5, 0, Qt.LeftButton)
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
codeText = str(editorArea.plainText)
# there should be Text item in new file
if re.search(patternCodeToMove, codeText, re.DOTALL):
test.passes("Refactoring was properly applied to destination file")
else:
test.fail("Refactoring failed in destination file. Content of editor:\n%s" % codeText)
#save and exit
invokeMenuItem("File", "Save All")
# check if new file was created in file system
test.verify(os.path.exists(projectDir + "/SampleApp/qml/SampleApp/MyComponent.qml"),
"Verifying if MyComponent.qml exists in file system after save")
invokeMenuItem("File", "Exit")
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def verifyCurrentLine(editorArea, currentLineExpectedText):
verifyMessage = "Verifying split initializer functionality at element line."
currentLineText = str(lineUnderCursor(editorArea)).strip();
return test.compare(currentLineText, currentLineExpectedText, verifyMessage)
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
createNewQtQuickApplication(tempDir(), "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# prepare code for test - type one-line element
if not placeCursorToLine(editorArea, "Text {"):
invokeMenuItem("File", "Exit")
return
moveTextCursor(editorArea, QTextCursor.StartOfLine, QTextCursor.MoveAnchor)
type(editorArea, "<Return>")
moveTextCursor(editorArea, QTextCursor.Up, QTextCursor.MoveAnchor)
type(editorArea, "<Tab>")
type(editorArea, "Item { x: 10; y: 20; width: 10 }")
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 30)
invokeMenuItem("File", "Save All")
# activate menu and apply 'Refactoring - Split initializer'
numLinesExpected = len(str(editorArea.plainText).splitlines()) + 4
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Split initializer"))
# wait until refactoring ended
waitFor("len(str(editorArea.plainText).splitlines()) == numLinesExpected", 5000)
# verify if refactoring was properly applied - each part on separate line
verifyCurrentLine(editorArea, "Item {")
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "x: 10;")
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "y: 20;")
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "width: 10")
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "}")
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
#save and exit
invokeMenuItem("File", "Save All")
invokeMenuItem("File", "Exit")
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