From 106473c4b5da0dfef3f79b8fa4b50e89b2c07cb4 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 21 Sep 2011 13:55:23 +0200 Subject: [PATCH] Cleanup to use new waitForSignal function. Change-Id: Id47c81fc3c2d4448f26dd2432b73286501be1e26 Reviewed-on: http://codereview.qt-project.org/5297 Reviewed-by: Qt Sanity Bot Reviewed-by: Christian Stenger --- tests/system/objects.map | 2 ++ tests/system/shared/build_utils.py | 23 ------------------ tests/system/shared/qtquick.py | 7 +++--- .../tst_basic_cpp_support/test.py | 1 + .../tst_build_speedcrunch/test.py | 24 ++++++------------- .../tst_cmake_speedcrunch/test.py | 6 +++-- .../tst_qtquick_creation/test.py | 14 ++++------- .../tst_qtquick_creation2/test.py | 14 ++++------- .../tst_qtquick_creation3/test.py | 7 +----- .../tst_qtquick_creation4/test.py | 16 ++++--------- 10 files changed, 34 insertions(+), 80 deletions(-) diff --git a/tests/system/objects.map b/tests/system/objects.map index 6e66423f369..ebee8e3f950 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -8,10 +8,12 @@ :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.Generator:_QLabel {text='Generator:' type='QLabel' 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'} :Desktop_QLabel {container=':QtCreator.MenuBar_ProjectExplorer::Internal::ProjectListWidget' name='target' text='Desktop' type='QLabel' visible='1'} +:Generator:_QComboBox {buddy=':CMake Wizard.Generator:_QLabel' type='QComboBox' unnamed='1' 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'} diff --git a/tests/system/shared/build_utils.py b/tests/system/shared/build_utils.py index 8b39a858ee2..1b394e80189 100644 --- a/tests/system/shared/build_utils.py +++ b/tests/system/shared/build_utils.py @@ -2,10 +2,6 @@ installedSignalHandlers = {} # flag to indicate whether overrideInstallLazySignalHandler() has been called already overridenInstallLazySignalHandlers = False -# flag to indicate a finished build (has to be resetted before doing another build) -buildFinished = False -# flag to indicate a successful build -buildSucceeded = False # flag to indicate whether a tasks file should be created when building ends with errors createTasksFileOnError = True # currently used directory for tasks files @@ -88,18 +84,6 @@ def checkLastBuild(expectedToFail=False): createTasksFile(list) return not gotErrors -# helper function used as handler for signal buildQueueFinished(bool) - see below -def handleBuildFinished(object, success): - global buildFinished, buildSucceeded - buildFinished = True - if success: - buildSucceeded = checkLastBuild() - else: - test.fatal("Build failed") - buildSucceeded = success - checkCompile() - checkLastBuild() - # helper function to check the compilation when build wasn't successful def checkCompile(): toggleCompOutput = waitForObject("{type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' " @@ -114,13 +98,6 @@ def checkCompile(): else: test.fatal("Compile Output:\n%s" % output.plainText) -# after starting to build an application this function can be used to synchronize the following tests -# make sure to set global variable buildFinished to False before starting to build -def waitForBuildFinished(timeOutMSeconds=30000): - overrideInstallLazySignalHandler() - installLazySignalHandler("{type='ProjectExplorer::BuildManager'}", "buildQueueFinished(bool)", "handleBuildFinished") - waitFor("buildFinished == True", timeOutMSeconds) - # helper method that parses the Build Issues output and writes a tasks file def createTasksFile(list): global tasksFileDir, tasksFileCount diff --git a/tests/system/shared/qtquick.py b/tests/system/shared/qtquick.py index cfd8ee2f285..c0d2e5ef1d8 100644 --- a/tests/system/shared/qtquick.py +++ b/tests/system/shared/qtquick.py @@ -85,13 +85,14 @@ def chooseDestination(destination=QtQuickConstants.Destinations.DESKTOP): test.fail("Failed to check destination '%s'" % QtQuickConstants.getStringForDestination(current)) def runAndCloseApp(): - global buildSucceeded, buildFinished, processStarted, processExited - buildSucceeded = buildFinished = processStarted = processExited = False + global processStarted, processExited + processStarted = processExited = False installLazySignalHandler("{type='ProjectExplorer::ApplicationLaucher'}", "processStarted()", "handleProcessStarted") installLazySignalHandler("{type='ProjectExplorer::ApplicationLaucher'}", "processExited(int)", "handleProcessExited") runButton = waitForObject("{type='Core::Internal::FancyToolButton' text='Run' visible='1'}", 20000) clickButton(runButton) - waitForBuildFinished() + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + buildSucceeded = checkLastBuild() waitFor("processStarted==True", 10000) if not buildSucceeded: test.log("Build inside run wasn't successful - leaving test") 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 5106ebc0ff5..63cb6dd1ed4 100644 --- a/tests/system/suite_general/tst_basic_cpp_support/test.py +++ b/tests/system/suite_general/tst_basic_cpp_support/test.py @@ -11,6 +11,7 @@ def main(): startApplication("qtcreator" + SettingsPath) + ## leave this one like this, it's too fast for delayed installation of signal handler installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") openQmakeProject(SDKPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro") diff --git a/tests/system/suite_general/tst_build_speedcrunch/test.py b/tests/system/suite_general/tst_build_speedcrunch/test.py index 12de7accc92..b8036f1ef7c 100644 --- a/tests/system/suite_general/tst_build_speedcrunch/test.py +++ b/tests/system/suite_general/tst_build_speedcrunch/test.py @@ -2,21 +2,12 @@ source("../../shared/qtcreator.py") import re; SpeedCrunchPath = "" -buildSucceeded = 0 -buildFinished = False -refreshFinishedCount = 0 - -def handleRefreshFinished(object, fileList): - global refreshFinishedCount - refreshFinishedCount += 1 def main(): - global buildSucceeded, buildFinished, refreshFinishedCount test.verify(os.path.exists(SpeedCrunchPath)) startApplication("qtcreator" + SettingsPath) - installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") openQmakeProject(SpeedCrunchPath) - waitFor("refreshFinishedCount == 1", 300000) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) # Test that some of the expected items are in the navigation tree for row, record in enumerate(testData.dataset("speedcrunch_tree.tsv")): @@ -24,8 +15,6 @@ def main(): value = testData.field(record, "value") test.compare(waitForObject(node).text, value) - installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") - clickButton(waitForObject(":*Qt Creator_Core::Internal::FancyToolButton")) buildCombo = waitForObject(":Build:_QComboBox") sendEvent("QMouseEvent", waitForObject(":QtCreator.MenuBar_ProjectExplorer::Internal::MiniProjectTargetSelector"), QEvent.MouseButtonPress, -5, 5, Qt.LeftButton, 0) @@ -33,18 +22,19 @@ def main(): prog = re.compile("Qt.*Release") for row in range(buildCombo.count): if prog.match(str(buildCombo.itemText(row))): - refreshFinishedCount = 0; clickButton(waitForObject(":*Qt Creator_Core::Internal::FancyToolButton")) 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) - waitFor("refreshFinishedCount == 1", 300000) - buildSucceeded = 0 - buildFinished = False + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) + invokeMenuItem("Build", "Run qmake") + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) invokeMenuItem("Build", "Rebuild All") - waitForBuildFinished(300000) + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + checkCompile() + checkLastBuild() # Add a new run configuration diff --git a/tests/system/suite_general/tst_cmake_speedcrunch/test.py b/tests/system/suite_general/tst_cmake_speedcrunch/test.py index 3d7f09c3815..0d0bd693226 100644 --- a/tests/system/suite_general/tst_cmake_speedcrunch/test.py +++ b/tests/system/suite_general/tst_cmake_speedcrunch/test.py @@ -13,7 +13,7 @@ def main(): openCmakeProject(SpeedCrunchPath) - waitFor("object.exists(':speedcrunch_QModelIndex')", 20000) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) # Test that some of the expected items are in the navigation tree for row, record in enumerate(testData.dataset("speedcrunch_tree.tsv")): @@ -25,7 +25,9 @@ def main(): invokeMenuItem("Build", "Rebuild All") # Wait for, and test if the build succeeded - waitForBuildFinished(300000) + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + checkCompile() + checkLastBuild() invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_qtquick/tst_qtquick_creation/test.py b/tests/system/suite_qtquick/tst_qtquick_creation/test.py index 73a4074a121..95da6301661 100644 --- a/tests/system/suite_qtquick/tst_qtquick_creation/test.py +++ b/tests/system/suite_qtquick/tst_qtquick_creation/test.py @@ -1,24 +1,20 @@ source("../../shared/qtcreator.py") -refreshFinishedCount = 0 workingDir = None -def handleRefreshFinished(object, fileList): - global refreshFinishedCount - refreshFinishedCount += 1 - def main(): - global workingDir,buildFinished,buildSucceeded + global workingDir startApplication("qtcreator" + SettingsPath) - installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") # using a temporary directory won't mess up an eventually exisiting workingDir = tempDir() createNewQtQuickApplication() # wait for parsing to complete - waitFor("refreshFinishedCount == 1", 10000) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) test.log("Building project") invokeMenuItem("Build","Build All") - waitForBuildFinished() + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + checkCompile() + checkLastBuild() test.log("Running project (includes build)") if runAndCloseApp(): logApplicationOutput() diff --git a/tests/system/suite_qtquick/tst_qtquick_creation2/test.py b/tests/system/suite_qtquick/tst_qtquick_creation2/test.py index a4ee377d915..418ca6c1e4b 100644 --- a/tests/system/suite_qtquick/tst_qtquick_creation2/test.py +++ b/tests/system/suite_qtquick/tst_qtquick_creation2/test.py @@ -1,26 +1,22 @@ source("../../shared/qtcreator.py") -refreshFinishedCount = 0 workingDir = None templateDir = None -def handleRefreshFinished(object, fileList): - global refreshFinishedCount - refreshFinishedCount += 1 - def main(): - global workingDir,templateDir,buildFinished,buildSucceeded + global workingDir,templateDir startApplication("qtcreator" + SettingsPath) - installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") # using a temporary directory won't mess up an eventually exisiting workingDir = tempDir() prepareTemplate() createNewQtQuickApplication() # wait for parsing to complete - waitFor("refreshFinishedCount == 1", 10000) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) test.log("Building project") invokeMenuItem("Build","Build All") - waitForBuildFinished() + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + checkCompile() + checkLastBuild() test.log("Running project (includes build)") if runAndCloseApp(): logApplicationOutput() diff --git a/tests/system/suite_qtquick/tst_qtquick_creation3/test.py b/tests/system/suite_qtquick/tst_qtquick_creation3/test.py index d8153063492..1025f00949c 100644 --- a/tests/system/suite_qtquick/tst_qtquick_creation3/test.py +++ b/tests/system/suite_qtquick/tst_qtquick_creation3/test.py @@ -1,14 +1,9 @@ source("../../shared/qtcreator.py") -refreshFinishedCount = 0 workingDir = None -def handleRefreshFinished(object, fileList): - global refreshFinishedCount - refreshFinishedCount += 1 - def main(): - global workingDir,buildFinished,buildSucceeded + global workingDir startApplication("qtcreator" + SettingsPath) # using a temporary directory won't mess up an eventually exisiting workingDir = tempDir() diff --git a/tests/system/suite_qtquick/tst_qtquick_creation4/test.py b/tests/system/suite_qtquick/tst_qtquick_creation4/test.py index 8d450558b44..72336be4359 100644 --- a/tests/system/suite_qtquick/tst_qtquick_creation4/test.py +++ b/tests/system/suite_qtquick/tst_qtquick_creation4/test.py @@ -1,26 +1,20 @@ source("../../shared/qtcreator.py") -refreshFinishedCount = 0 workingDir = None -def handleRefreshFinished(object, fileList): - global refreshFinishedCount - refreshFinishedCount += 1 - def main(): - global workingDir,buildFinished,buildSucceeded + global workingDir startApplication("qtcreator" + SettingsPath) - installLazySignalHandler("{type='CppTools::Internal::CppModelManager'}", "sourceFilesRefreshed(QStringList)", "handleRefreshFinished") # using a temporary directory won't mess up an eventually exisiting workingDir = tempDir() createNewQmlExtension() # wait for parsing to complete - waitFor("refreshFinishedCount == 1", 10000) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000) test.log("Building project") invokeMenuItem("Build","Build All") - waitForBuildFinished() - if buildSucceeded: - checkCompile() + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000) + checkCompile() + checkLastBuild() invokeMenuItem("File", "Exit") def createNewQmlExtension():