diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2012-05-07 15:18:39 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2012-05-07 15:18:39 +0200 |
commit | 529c0a8fe203ec3288dc9f3053a806f53665d252 (patch) | |
tree | d71f907b13ccdd5a19dd0984986d4a3af1c172ac /tests | |
parent | d7f6bc336982b7175c1651ccc8dfd04dd79ea367 (diff) | |
parent | b63135c067d49a96c56195f75e7a6637c97c0702 (diff) | |
download | qt-creator-529c0a8fe203ec3288dc9f3053a806f53665d252.tar.gz |
Merge remote-tracking branch 'origin/2.5'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/system/shared/debugger.py | 15 | ||||
-rw-r--r-- | tests/system/suite_QMLS/objects.map | 7 | ||||
-rw-r--r-- | tests/system/suite_QMLS/suite.conf | 2 | ||||
-rw-r--r-- | tests/system/suite_QMLS/tst_QMLS03/test.py | 105 | ||||
-rw-r--r-- | tests/system/suite_QMLS/tst_QMLS04/test.py | 59 | ||||
-rw-r--r-- | tests/system/suite_QMLS/tst_QMLS05/test.py | 49 |
6 files changed, 231 insertions, 6 deletions
diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py index 42957d8d24..7ee0db886a 100644 --- a/tests/system/shared/debugger.py +++ b/tests/system/shared/debugger.py @@ -64,9 +64,13 @@ def setBreakpointsForCurrentProject(filesAndLines): return False invokeMenuItem("Debug", "Toggle Breakpoint") test.log('Set breakpoint in %s' % fName, curLine) - breakPointTreeView = waitForObject("{type='Debugger::Internal::BreakWindow' visible='1' " - "windowTitle='Breakpoints' name='Debugger.Docks.Break'}") - waitFor("breakPointTreeView.model().rowCount() == len(filesAndLines)", 2000) + try: + breakPointTreeView = waitForObject("{type='Debugger::Internal::BreakWindow' visible='1' " + "windowTitle='Breakpoints' name='Debugger.Docks.Break'}") + waitFor("breakPointTreeView.model().rowCount() == len(filesAndLines)", 2000) + except: + test.fatal("UI seems to have changed - check manually and fix this script.") + return False test.compare(breakPointTreeView.model().rowCount(), len(filesAndLines), 'Expected %d set break points, found %d listed' % (len(filesAndLines), breakPointTreeView.model().rowCount())) @@ -89,8 +93,9 @@ def removeOldBreakpoints(): rect = breakPointTreeView.visualRect(currentIndex) mouseClick(breakPointTreeView, rect.x+5, rect.y+5, 0, Qt.LeftButton) type(breakPointTreeView, "<Delete>") - except LookupError: - pass + except: + test.fatal("UI seems to have changed - check manually and fix this script.") + return False return test.compare(model.rowCount(), 0, "Check if all breakpoints have been removed.") # function to do simple debugging of the current (configured) project diff --git a/tests/system/suite_QMLS/objects.map b/tests/system/suite_QMLS/objects.map index b3e0ada750..400907ecd5 100644 --- a/tests/system/suite_QMLS/objects.map +++ b/tests/system/suite_QMLS/objects.map @@ -1,6 +1,9 @@ :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'} diff --git a/tests/system/suite_QMLS/suite.conf b/tests/system/suite_QMLS/suite.conf index dbc7c20a6b..73de021e6d 100644 --- a/tests/system/suite_QMLS/suite.conf +++ b/tests/system/suite_QMLS/suite.conf @@ -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 diff --git a/tests/system/suite_QMLS/tst_QMLS03/test.py b/tests/system/suite_QMLS/tst_QMLS03/test.py new file mode 100644 index 0000000000..c492a4d268 --- /dev/null +++ b/tests/system/suite_QMLS/tst_QMLS03/test.py @@ -0,0 +1,105 @@ +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") + diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py new file mode 100644 index 0000000000..3c7f76ffdc --- /dev/null +++ b/tests/system/suite_QMLS/tst_QMLS04/test.py @@ -0,0 +1,59 @@ +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") + diff --git a/tests/system/suite_QMLS/tst_QMLS05/test.py b/tests/system/suite_QMLS/tst_QMLS05/test.py new file mode 100644 index 0000000000..5f018bde2a --- /dev/null +++ b/tests/system/suite_QMLS/tst_QMLS05/test.py @@ -0,0 +1,49 @@ +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") + |