diff options
author | Jan Kerekes <jan.kerekes@ixonos.com> | 2012-04-23 13:17:40 +0200 |
---|---|---|
committer | Robert Löhning <robert.loehning@nokia.com> | 2012-06-19 17:32:39 +0200 |
commit | f22449b94a4c7e82cc96a40b80cd1ea9aad0e5e7 (patch) | |
tree | ff0cd55c0643767c162af05403142d388e985d47 | |
parent | 89aaa9603156e7921e946ef85c101ff8bfc4c797 (diff) | |
download | qt-creator-f22449b94a4c7e82cc96a40b80cd1ea9aad0e5e7.tar.gz |
Squish: Added new test cases(4, 5) to c support suite
initial commit
Change-Id: If2fb169ac66ccbcc463e4cfef491ca4fb3e01c30
Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
-rw-r--r-- | tests/system/shared/editor_utils.py | 49 | ||||
-rwxr-xr-x | tests/system/shared/suites_qtta.py | 1 | ||||
-rw-r--r-- | tests/system/suite_CSUP/objects.map | 9 | ||||
-rw-r--r-- | tests/system/suite_CSUP/suite.conf | 2 | ||||
-rw-r--r-- | tests/system/suite_CSUP/tst_CSUP04/test.py | 60 | ||||
-rw-r--r-- | tests/system/suite_CSUP/tst_CSUP05/test.py | 68 | ||||
-rw-r--r-- | tests/system/suite_qtquick/tst_qml_editor/test.py | 33 |
7 files changed, 188 insertions, 34 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 37a2ae9831..c50f0da6cd 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -239,3 +239,52 @@ def __getFileSuffix__(fileName): return None else: return suffix[1] + +def maskSpecialCharsForSearchResult(filename): + filename = filename.replace("_", "\\_").replace(".","\\.") + return filename + +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.compare(matches, expectedCount, "Verified 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 = getEditorForFileSuffix(itemText) + waitFor("lineUnderCursor(editor) == text", 2000) + test.compare(lineUnderCursor(editor), text) + +# this function invokes context menu and command from it +def invokeContextMenuItem(editorArea, command1, command2 = None): + ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) + activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command1, 1000)) + if command2: + activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command2, 1000)) + +# this function invokes the "Find Usages" item from context menu +# param editor an editor object +# param line a line in editor (content of the line as a string) +# param typeOperation a key to type +# param n how often repeat the type operation? +def invokeFindUsage(editor, line, typeOperation, n=1): + if not placeCursorToLine(editor, line, True): + return False + for i in range(n): + type(editor, typeOperation) + invokeContextMenuItem(editor, "Find Usages") + return True diff --git a/tests/system/shared/suites_qtta.py b/tests/system/shared/suites_qtta.py index 70b4d9a467..13d780c5b0 100755 --- a/tests/system/shared/suites_qtta.py +++ b/tests/system/shared/suites_qtta.py @@ -50,4 +50,3 @@ def changeAutocompleteToManual(): selectFromCombo(":Behavior.completionTrigger_QComboBox", "Manually") verifyEnabled(":Options.OK_QPushButton") clickButton(waitForObject(":Options.OK_QPushButton")) - diff --git a/tests/system/suite_CSUP/objects.map b/tests/system/suite_CSUP/objects.map index d35b66b20a..8fb3140cf1 100644 --- a/tests/system/suite_CSUP/objects.map +++ b/tests/system/suite_CSUP/objects.map @@ -1,3 +1,4 @@ +:*Qt Creator.Find_Find::Internal::FindToolBar {name='Find__Internal__FindWidget' type='Find::Internal::FindToolBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Find'} :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'} @@ -7,9 +8,17 @@ :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.CloseFind_QToolButton {name='close' type='QToolButton' 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.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.Replace All_QToolButton {name='replaceAllButton' text='Replace All' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.Replace_QToolButton {name='replaceButton' text='Replace' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.findEdit_Utils::FilterLineEdit {name='findEdit' type='Utils::FilterLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.replaceEdit_Utils::FilterLineEdit {name='replaceEdit' type='Utils::FilterLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' unnamed='1' visible='1' windowTitle?='*Qt Creator'} :Qt Creator_CppEditor::Internal::CPPEditorWidget {type='CppEditor::Internal::CPPEditorWidget' 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::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :addToVersionControlComboBox_QComboBox {name='addToVersionControlComboBox' type='QComboBox' visible='1'} :m_popupFrame_QListView {container=':m_popupFrame_TextEditor::GenericProposalWidget' type='QListView' unnamed='1' visible='1'} diff --git a/tests/system/suite_CSUP/suite.conf b/tests/system/suite_CSUP/suite.conf index 9f50e3f128..56fb124918 100644 --- a/tests/system/suite_CSUP/suite.conf +++ b/tests/system/suite_CSUP/suite.conf @@ -5,6 +5,6 @@ ENVVARS=envvars HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=0 LANGUAGE=Python -TEST_CASES=tst_CSUP01 tst_CSUP02 +TEST_CASES=tst_CSUP01 tst_CSUP02 tst_CSUP04 tst_CSUP05 VERSION=2 WRAPPERS=Qt diff --git a/tests/system/suite_CSUP/tst_CSUP04/test.py b/tests/system/suite_CSUP/tst_CSUP04/test.py new file mode 100644 index 0000000000..0740842777 --- /dev/null +++ b/tests/system/suite_CSUP/tst_CSUP04/test.py @@ -0,0 +1,60 @@ +source("../../shared/suites_qtta.py") +source("../../shared/qtcreator.py") + +# entry of test +def main(): + global searchFinished + # 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) + installLazySignalHandler("{type='Core::FutureProgress' unnamed='1'}", "finished()", "__handleFutureProgress__") + # wait for parsing to complete + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)") + # open test .pro project. + test.verify(waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation"), + "Verifying if: Project is opened.") + # open .cpp file in editor + doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton) + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Verifying if: .cpp file is opened in Edit mode.") + # place cursor on line "QmlApplicationViewer viewer;" + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + searchFinished = False + # invoke find usages from context menu on word "viewer" + if not invokeFindUsage(editorWidget, "QmlApplicationViewer viewer;", "<Left>", 10): + invokeMenuItem("File", "Exit") + return + # wait until search finished and verify search results + waitFor("searchFinished") + validateSearchResult(17) + result = re.search("QmlApplicationViewer", str(editorWidget.plainText)) + test.verify(result, "Verifying if: The list of all usages of the selected text is displayed in Search Results. " + "File with used text is opened.") + # move cursor to the other word and test Find Usages function by pressing Ctrl+Shift+U. + doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton) + if not placeCursorToLine(editorWidget, "viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);"): + return + for i in range(4): + type(editorWidget, "<Left>") + searchFinished = False + type(editorWidget, "<Ctrl+Shift+U>") + # wait until search finished and verify search results + waitFor("searchFinished") + validateSearchResult(3) + # exit qt creator + invokeMenuItem("File", "Save All") + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished + +def __handleFutureProgress__(obj): + global searchFinished + if className(obj) == "Core::FutureProgress": + searchFinished = True + diff --git a/tests/system/suite_CSUP/tst_CSUP05/test.py b/tests/system/suite_CSUP/tst_CSUP05/test.py new file mode 100644 index 0000000000..035b102111 --- /dev/null +++ b/tests/system/suite_CSUP/tst_CSUP05/test.py @@ -0,0 +1,68 @@ +source("../../shared/suites_qtta.py") +source("../../shared/qtcreator.py") + +# entry of test +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) + # wait for parsing to complete + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)") + test.verify(waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation"), + "Verifying if: Project is opened.") + # open .cpp file in editor + doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "propertyanimation.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton) + test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), + "Verifying if: .cpp file is opened in Edit mode.") + # select some word for example "viewer" and press Ctrl+F. + editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + if not placeCursorToLine(editorWidget, "QmlApplicationViewer viewer;"): + invokeMenuItem("File", "Exit") + return + type(editorWidget, "<Left>") + for i in range(6): + type(editorWidget, "<Shift+Left>") + type(editorWidget, "<Ctrl+F>") + # verify if find toolbar exists and if search text contains selected word + test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"), + "Verifying if: Find/Replace pane is displayed at the bottom of the view.") + test.compare(waitForObject(":Qt Creator.findEdit_Utils::FilterLineEdit").displayText, "viewer", + "Verifying if: Find line edit contains 'viewer' text.") + # insert some word to "Replace with:" field and select "Replace All". + replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "find") + oldCodeText = str(editorWidget.plainText) + clickButton(waitForObject(":Qt Creator.Replace All_QToolButton")) + mouseClick(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), 5, 5, 0, Qt.LeftButton) + newCodeText = str(editorWidget.plainText) + test.compare(newCodeText, oldCodeText.replace("viewer", "find").replace("Viewer", "find"), + "Verifying if: Found text is replaced with new word properly.") + # select some other word in .cpp file and select "Edit" -> "Find/Replace". + clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) + placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);") + for i in range(25): + type(editorWidget, "<Left>") + for i in range(18): + type(editorWidget, "<Shift+Left>") + invokeMenuItem("Edit", "Find/Replace", "Find/Replace") + replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer") + oldCodeText = str(editorWidget.plainText) + clickButton(waitForObject(":Qt Creator.Replace_QToolButton")) + newCodeText = str(editorWidget.plainText) + # "::" is used to replace only one occurrence by python + test.compare(newCodeText, oldCodeText.replace("QmlApplicationfind::", "QmlApplicationViewer::"), + "Verifying if: Only selected word is replaced, the rest of found words are not replaced.") + # close Find/Replace tab. + clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) + test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar", False), + "Verifying if: Find/Replace tab is closed.") + # exit qt creator + invokeMenuItem("File", "Save All") + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished diff --git a/tests/system/suite_qtquick/tst_qml_editor/test.py b/tests/system/suite_qtquick/tst_qml_editor/test.py index 9e4d1d7fb5..13a63d7d64 100644 --- a/tests/system/suite_qtquick/tst_qml_editor/test.py +++ b/tests/system/suite_qtquick/tst_qml_editor/test.py @@ -91,8 +91,7 @@ def __invokeFindUsage__(treeView, filename, line, additionalKeyPresses, expected for ty in additionalKeyPresses: type(editor, ty) searchFinished = False - ctxtMenu = openContextMenuOnTextCursorPosition(editor) - activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Find Usages")) + invokeContextMenuItem(editor, "Find Usages") waitFor("searchFinished") validateSearchResult(expectedCount) @@ -109,32 +108,6 @@ def testFindUsages(): home = "<Ctrl+Left>" __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) - waitFor("lineUnderCursor(editor) == text", 2000) - test.compare(lineUnderCursor(editor), text) - def testHovering(): navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' " "window=':Qt Creator_Core::Internal::MainWindow'}", 20000) @@ -220,10 +193,6 @@ def maskSpecialCharsForProjectTree(filename): filename = filename.replace("/?","\\?").replace("/*","\\*") return filename -def maskSpecialCharsForSearchResult(filename): - filename = filename.replace("_", "\\_").replace(".","\\.") - return filename - def cleanup(): global workingDir, templateDir waitForCleanShutdown() |