From 507d260bd45aa9d90025d003569339c5683bcbb7 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 31 Aug 2011 13:51:32 +0200 Subject: [PATCH] Fixes openProject, also tests multiple target selection and building. Change-Id: I4a5aaea2eca940c3ffcf8458b5cc0afce591b63e Reviewed-on: http://codereview.qt.nokia.com/3886 Reviewed-by: Qt Sanity Bot Reviewed-by: Christian Stenger --- tests/system/objects.map | 16 ++++++- tests/system/shared/mainwin.py | 12 ++++- tests/system/shared/utils.py | 4 +- .../tst_basic_cpp_support/test.py | 13 +++-- .../tst_build_speedcrunch/test.py | 48 ++++++++++++++----- .../tst_cmake_speedcrunch/test.py | 13 ++--- .../suite_general/tst_openqt_creator/test.py | 12 ++--- 7 files changed, 82 insertions(+), 36 deletions(-) diff --git a/tests/system/objects.map b/tests/system/objects.map index a512dd9ed13..6e66423f369 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -1,13 +1,27 @@ +:*Qt Creator.Build Project_Core::Internal::FancyToolButton {text='Build Project' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:*Qt Creator.Run_Core::Internal::FancyToolButton {text='Run' type='Core::Internal::FancyToolButton' unnamed='1' 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.qt_tabwidget_stackedwidget_QStackedWidget {name='qt_tabwidget_stackedwidget' type='QStackedWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:*Qt Creator_Core::Internal::FancyToolButton {occurrence='3' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator_Utils::FilterLineEdit {type='Utils::FilterLineEdit' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator_Utils::IconButton {occurrence='4' type='Utils::IconButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Build:_QComboBox {aboveWidget=':Desktop_QLabel' container=':QtCreator.MenuBar_ProjectExplorer::Internal::ProjectListWidget' leftWidget=':Build:_QLabel' type='QComboBox'} +:Build:_QLabel {container=':QtCreator.MenuBar_ProjectExplorer::Internal::ProjectListWidget' name='buildLabel' text='Build:' type='QLabel' visible='1'} :CMake Wizard.Finish_QPushButton {text='Finish' type='QPushButton' unnamed='1' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard.Next_QPushButton {name='__qt__passive_wizardbutton1' text='Next' type='QPushButton' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard.Run CMake_QPushButton {text='Run CMake' type='QPushButton' unnamed='1' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard {type='CMakeProjectManager::Internal::CMakeOpenProjectWizard' unnamed='1' visible='1' windowTitle='CMake Wizard'} -:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' unnamed='1' visible='1' windowTitle?='*Qt Creator'} +:Desktop_QLabel {container=':QtCreator.MenuBar_ProjectExplorer::Internal::ProjectListWidget' name='target' text='Desktop' type='QLabel' visible='1'} +:Project Setup.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1' window=':Project Setup_Qt4ProjectManager::Internal::ProjectLoadWizard'} +:Project Setup_Qt4ProjectManager::Internal::ProjectLoadWizard {type='Qt4ProjectManager::Internal::ProjectLoadWizard' unnamed='1' visible='1' windowTitle='Project Setup'} +: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' 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_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'} +:QtCreator.MenuBar_ProjectExplorer::Internal::MiniProjectTargetSelector {type='ProjectExplorer::Internal::MiniProjectTargetSelector'} +:QtCreator.MenuBar_ProjectExplorer::Internal::ProjectListWidget {type='ProjectExplorer::Internal::ProjectListWidget' window=':QtCreator.MenuBar_ProjectExplorer::Internal::MiniProjectTargetSelector'} :projects.projects.pro_QModelIndex {column='0' container=':projects_QModelIndex' text='projects.pro' type='QModelIndex'} :projects_QModelIndex {column='0' container=':Qt Creator_Utils::NavigationTreeView' text='projects' type='QModelIndex'} +:scrollArea.Create Build Configurations:_QComboBox {container=':Project Setup.scrollArea_QScrollArea' leftWidget=':scrollArea.Create Build Configurations:_QLabel' type='QComboBox' unnamed='1' visible='1'} +:scrollArea.Create Build Configurations:_QLabel {container=':Project Setup.scrollArea_QScrollArea' text='Create Build Configurations:' type='QLabel' unnamed='1' visible='1'} diff --git a/tests/system/shared/mainwin.py b/tests/system/shared/mainwin.py index b08f1854976..f8e637ee013 100644 --- a/tests/system/shared/mainwin.py +++ b/tests/system/shared/mainwin.py @@ -4,10 +4,20 @@ def invokeMenuItem(menu, item): activateItem(menuObject) activateItem(waitForObjectItem(menuObject, item)) -def openProject(projectPath): +def openQmakeProject(projectPath): invokeMenuItem("File", "Open File or Project...") waitForObject("{name='QFileDialog' type='QFileDialog' visible='1' windowTitle='Open File'}") type(findObject("{name='fileNameEdit' type='QLineEdit'}"), projectPath) clickButton(findObject("{text='Open' type='QPushButton'}")) waitForObject("{type='Qt4ProjectManager::Internal::ProjectLoadWizard' visible='1' windowTitle='Project Setup'}") + selectFromCombo(":scrollArea.Create Build Configurations:_QComboBox", "per Qt Version a Debug and Release") clickButton(findObject("{text='Finish' type='QPushButton'}")) + +def openCmakeProject(projectPath): + invokeMenuItem("File", "Open File or Project...") + waitForObject("{name='QFileDialog' type='QFileDialog' visible='1' windowTitle='Open File'}") + type(findObject("{name='fileNameEdit' type='QLineEdit'}"), projectPath) + clickButton(findObject("{text='Open' type='QPushButton'}")) + clickButton(waitForObject(":CMake Wizard.Next_QPushButton", 20000)) + clickButton(waitForObject(":CMake Wizard.Run CMake_QPushButton", 20000)) + clickButton(waitForObject(":CMake Wizard.Finish_QPushButton", 60000)) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index bcd4afeba51..a80c2d16a5c 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -18,8 +18,8 @@ def verifyEnabled(objectName): def selectFromCombo(objectName, itemName): object = verifyEnabled(objectName) - mouseClick(object, 198, 7, 0, Qt.LeftButton) - mouseClick(waitForObjectItem(object, itemName), 84, 5, 0, Qt.LeftButton) + mouseClick(object, 5, 5, 0, Qt.LeftButton) + mouseClick(waitForObjectItem(object, itemName), 5, 5, 0, Qt.LeftButton) def wordUnderCursor(window): cursor = window.textCursor() diff --git a/tests/system/suite_general/tst_basic_cpp_support/test.py b/tests/system/suite_general/tst_basic_cpp_support/test.py index 011764b0dc2..5106ebc0ff5 100644 --- a/tests/system/suite_general/tst_basic_cpp_support/test.py +++ b/tests/system/suite_general/tst_basic_cpp_support/test.py @@ -6,23 +6,26 @@ def handleRefreshFinished(object, fileList): global refreshFinishedCount refreshFinishedCount += 1 - def main(): + test.verify(os.path.exists(SDKPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro")) + startApplication("qtcreator" + SettingsPath) installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") - test.verify(os.path.exists(SDKPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro")) - openProject(SDKPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro") + openQmakeProject(SDKPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro") waitFor("refreshFinishedCount == 1", 20000) test.compare(refreshFinishedCount, 1) - mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 110, 11, 0, Qt.LeftButton) + mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 5, 5, 0, Qt.LeftButton) type(waitForObject(":*Qt Creator_Utils::FilterLineEdit"), "dummy.cpp") # pause to wait for results to populate snooze(1) type(waitForObject(":*Qt Creator_Utils::FilterLineEdit"), "") +## Waiting for a solution from Froglogic to make the below work. +## There is an issue with slots that return a class type that wasn't running previously... + # editorManager = waitForObject("{type='Core::EditorManager'}", 2000) # t2 = editorManager.currentEditor() # t3 = t2.file() @@ -55,7 +58,7 @@ def main(): # Creator should show the definition of this function # - Press Shift+F2 or select from menu: Tools / C++ / Switch Between Method Declaration/Definition again # Creator should show the declaration of the function again. - mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 110, 11, 0, Qt.LeftButton) + mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 5, 5, 0, Qt.LeftButton) clickButton(waitForObject(":Qt Creator_Utils::IconButton")) type(waitForObject(":*Qt Creator_Utils::FilterLineEdit"), "dummy.cpp") # pause to wait for results to populate diff --git a/tests/system/suite_general/tst_build_speedcrunch/test.py b/tests/system/suite_general/tst_build_speedcrunch/test.py index b1a777b69ce..69f9eb026e4 100644 --- a/tests/system/suite_general/tst_build_speedcrunch/test.py +++ b/tests/system/suite_general/tst_build_speedcrunch/test.py @@ -1,19 +1,27 @@ source("../../shared/qtcreator.py") +import re; SpeedCrunchPath = "" buildFinished = False buildSucceeded = False +refreshFinishedCount = 0 def handleBuildFinished(object, success): global buildFinished, buildSucceeded buildFinished = True buildSucceeded = success +def handleRefreshFinished(object, fileList): + global refreshFinishedCount + refreshFinishedCount += 1 + def main(): - startApplication("qtcreator" + SettingsPath) + global buildFinished, buildSucceeded test.verify(os.path.exists(SpeedCrunchPath)) - openProject(SpeedCrunchPath) + + startApplication("qtcreator" + SettingsPath) + openQmakeProject(SpeedCrunchPath) # Test that some of the expected items are in the navigation tree for row, record in enumerate(testData.dataset("speedcrunch_tree.tsv")): @@ -22,14 +30,30 @@ def main(): test.compare(waitForObject(node).text, value) # Invoke a rebuild of the application - invokeMenuItem("Build", "Rebuild All") + installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") - # Wait for, and test if the build succeeded + clickButton(waitForObject(":*Qt Creator_Core::Internal::FancyToolButton")) + buildCombo = waitForObject(":Build:_QComboBox") installLazySignalHandler("{type='ProjectExplorer::BuildManager'}", "buildQueueFinished(bool)", "handleBuildFinished") - waitFor("buildFinished == True", 30000) - test.verify(buildSucceeded == 1) # buildSucceeded is True for me - even on failed builds; remove this check at all? - checkLastBuild() - # Now that this has finished, test adding a new build configuration + sendEvent("QMouseEvent", waitForObject(":QtCreator.MenuBar_ProjectExplorer::Internal::MiniProjectTargetSelector"), QEvent.MouseButtonPress, -5, 5, Qt.LeftButton, 0) + + prog = re.compile("Qt.*Release") + for row in range(buildCombo.count): + if prog.match(str(buildCombo.itemText(row))): + clickButton(waitForObject(":*Qt Creator_Core::Internal::FancyToolButton")) + refreshFinishedCount = 0 + itemText = buildCombo.itemText(row); + test.log("Testing build configuration: "+str(itemText)) + if str(itemText) != str(buildCombo.currentText): + buildCombo.setCurrentIndex(row) + sendEvent("QMouseEvent", waitForObject(":QtCreator.MenuBar_ProjectExplorer::Internal::MiniProjectTargetSelector"), QEvent.MouseButtonPress, -45, 64, Qt.LeftButton, 0) + buildSucceeded = 0 + buildFinished = False + invokeMenuItem("Build", "Rebuild All") + # Wait for, and test if the build succeeded + waitFor("buildFinished == True", 300000) + test.verify(buildSucceeded == 1) # buildSucceeded is True for me - even on failed builds; remove this check at all? + checkLastBuild() # Add a new run configuration @@ -46,7 +70,9 @@ def cleanup(): os.remove(SpeedCrunchPath + ".user") BuildPath = glob.glob(SDKPath + "/creator-test-data/speedcrunch/speedcrunch-build-*") + BuildPath += glob.glob(SDKPath + "/creator-test-data/speedcrunch/qtcreator-build-*") - for dir in BuildPath: - if os.access(dir, os.F_OK): - shutil.rmtree(dir) + if BuildPath: + for dir in BuildPath: + if os.access(dir, os.F_OK): + shutil.rmtree(dir) diff --git a/tests/system/suite_general/tst_cmake_speedcrunch/test.py b/tests/system/suite_general/tst_cmake_speedcrunch/test.py index ebfebf86b07..99ca78942be 100644 --- a/tests/system/suite_general/tst_cmake_speedcrunch/test.py +++ b/tests/system/suite_general/tst_cmake_speedcrunch/test.py @@ -14,18 +14,11 @@ def main(): test.fatal("cmake not found") return + test.verify(os.path.exists(SpeedCrunchPath)) + startApplication("qtcreator" + SettingsPath) - invokeMenuItem("File", "Open File or Project...") - - test.verify(os.path.exists(SpeedCrunchPath)) - waitForObject("{name='QFileDialog' type='QFileDialog' visible='1' windowTitle='Open File'}", 20000) - type(findObject("{name='fileNameEdit' type='QLineEdit'}"), SpeedCrunchPath) - clickButton(findObject("{text='Open' type='QPushButton'}")) - - clickButton(waitForObject(":CMake Wizard.Next_QPushButton", 20000)) - clickButton(waitForObject(":CMake Wizard.Run CMake_QPushButton", 20000)) - clickButton(waitForObject(":CMake Wizard.Finish_QPushButton", 60000)) + openCmakeProject(SpeedCrunchPath) waitFor("object.exists(':speedcrunch_QModelIndex')", 20000) diff --git a/tests/system/suite_general/tst_openqt_creator/test.py b/tests/system/suite_general/tst_openqt_creator/test.py index b78e005f851..5352151cb00 100644 --- a/tests/system/suite_general/tst_openqt_creator/test.py +++ b/tests/system/suite_general/tst_openqt_creator/test.py @@ -7,15 +7,15 @@ def handleRefreshFinished(object, fileList): refreshFinishedCount += 1 def main(): + test.verify(os.path.exists(SDKPath + "/qt/projects.pro")) + test.verify(os.path.exists(SDKPath + "/creator/qtcreator.pro")) + startApplication("qtcreator" + SettingsPath) installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") - test.verify(os.path.exists(SDKPath + "/qt/projects.pro")) - test.verify(os.path.exists(SDKPath + "/creator/qtcreator.pro")) - - openProject(SDKPath + "/qt/projects.pro") - openProject(SDKPath + "/creator/qtcreator.pro") + openQmakeProject(SDKPath + "/qt/projects.pro") + openQmakeProject(SDKPath + "/creator/qtcreator.pro") # Test that some of the expected items are in the navigation tree for row, record in enumerate(testData.dataset("qt_tree.tsv")): @@ -34,7 +34,7 @@ def main(): # Now check some basic lookups in the search box - mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 101, 7, 0, Qt.LeftButton) + mouseClick(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), 5, 5, 0, Qt.LeftButton) type(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), ": Qlist::QList") snooze(1) type(waitForObject(":*Qt Creator_Utils::FilterLineEdit", 20000), "")