From 1139006b3fb4fe229ca08947bbaa634c6342f4fe Mon Sep 17 00:00:00 2001
From: Robert Loehning <robert.loehning@nokia.com>
Date: Fri, 14 Oct 2011 16:29:46 +0200
Subject: [PATCH] Squish: Let one function handle last page of all project
 wizards

Change-Id: I74e2c2f0c50a3131ad66fbde5e4a7fe004b7ebff
Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
---
 tests/system/objects.map                      |  3 +-
 tests/system/shared/project.py                | 39 ++++++++-----------
 .../tst_build_new_project/test.py             |  2 +-
 3 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/tests/system/objects.map b/tests/system/objects.map
index 523991e592a..467640fa8b0 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -21,14 +21,13 @@
 :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.ReRun_QToolButton	{toolTip='Re-run this run-configuration' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :Qt Creator.Stop_QToolButton	{text='Stop' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :Qt Creator_Core::Internal::MainWindow	{type='Core::Internal::MainWindow' visible='1' windowTitle?='*Qt Creator'}
 :Qt Creator_Core::Internal::OutputPaneToggleButton	{occurrence='3' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :Qt Creator_CppEditor::Internal::CPPEditorWidget	{type='CppEditor::Internal::CPPEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:Qt Creator.ReRun_QToolButton	{toolTip='Re-run this run-configuration' type='QToolButton' 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'}
-:Qt Gui Application.Finish_QPushButton	{text~='(Finish|Done)' type='QPushButton' unnamed='1' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
 :Qt Gui Application.Form file:_QLabel	{name='formLabel' text='Form file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
 :Qt Gui Application.Header file:_QLabel	{name='headerLabel' text='Header file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
 :Qt Gui Application.Next_QPushButton	{name='__qt__passive_wizardbutton1' text~='(Next.*|Continue)' type='QPushButton' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py
index 7d557360331..387f775ca0f 100644
--- a/tests/system/shared/project.py
+++ b/tests/system/shared/project.py
@@ -53,6 +53,17 @@ def shadowBuildDir(path, project, qtVersion, debugVersion):
     else:
         return buildDir + "_Release"
 
+def createProjectHandleLastPage(expectedFiles = None):
+    if expectedFiles != None:
+        summary = str(waitForObject(":scrollArea.Files to be added").text)
+        lastIndex = 0
+        for filename in expectedFiles:
+            index = summary.find(filename)
+            test.verify(index > lastIndex, "'" + filename + "' found at index " + str(index))
+            lastIndex = index
+    selectFromCombo(":addToVersionControlComboBox_QComboBox", "<None>")
+    clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
+
 def createProject_Qt_GUI(path, projectName, qtVersion, checks):
     invokeMenuItem("File", "New File or Project...")
     waitForObjectItem(":New.templateCategoryView_QTreeView", "Projects.Qt Widget Project")
@@ -97,23 +108,10 @@ def createProject_Qt_GUI(path, projectName, qtVersion, checks):
 
     clickButton(verifyEnabled(":Qt Gui Application.Next_QPushButton"))
 
+    expectedFiles = None
     if checks:
-        summary = str(waitForObject(":scrollArea.Files to be added").text)
-
-        path_found = summary.find(os.path.join(path, projectName))
-        cpp_found = summary.find(cpp_file)
-        h_found = summary.find(h_file)
-        ui_found = summary.find(ui_file)
-        pro_found = summary.find(pro_file)
-
-        test.verify(path_found > 0, "'" + path + "' found at index " + str(path_found))
-        test.verify(cpp_found > path_found, "'" + cpp_file + "' found at index " + str(cpp_found))
-        test.verify(h_found > cpp_found, "'" + h_file + "' found at index " + str(h_found))
-        test.verify(ui_found > cpp_found, "'" + ui_file + "' found at index " + str(ui_found))
-        test.verify(pro_found > ui_found, "'" + pro_file + "' found at index " + str(pro_found))
-
-    selectFromCombo(":addToVersionControlComboBox_QComboBox", "<None>")
-    clickButton(waitForObject(":Qt Gui Application.Finish_QPushButton"))
+        expectedFiles = [os.path.join(path, projectName), cpp_file, h_file, ui_file, pro_file]
+    createProjectHandleLastPage(expectedFiles)
 
     if checks:
         waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 20000)
@@ -160,8 +158,7 @@ def createNewQtQuickApplication(workingDir, projectName = None, templateFile = N
     chooseTargets(targets)
     snooze(1)
     clickButton(nextButton)
-    selectFromCombo(":addToVersionControlComboBox_QComboBox", "<None>")
-    clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
+    createProjectHandleLastPage()
 
 def createNewQtQuickUI(workingDir):
     invokeMenuItem("File", "New File or Project...")
@@ -181,8 +178,7 @@ def createNewQtQuickUI(workingDir):
         clickButton(cbDefaultLocation)
     # now there's the 'untitled' project inside a temporary directory - step forward...!
     clickButton(waitForObject("{text~='(Next.*|Continue)' type='QPushButton' visible='1'}", 20000))
-    selectFromCombo(":addToVersionControlComboBox_QComboBox", "<None>")
-    clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
+    createProjectHandleLastPage()
 
 def createNewQmlExtension(workingDir):
     invokeMenuItem("File", "New File or Project...")
@@ -212,5 +208,4 @@ def createNewQmlExtension(workingDir):
                               "type='QLineEdit' unnamed='1' visible='1'}", 20000)
     replaceEditorContent(uriLineEd, "com.nokia.test.qmlcomponents")
     clickButton(nextButton)
-    selectFromCombo(":addToVersionControlComboBox_QComboBox", "<None>")
-    clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
+    createProjectHandleLastPage()
diff --git a/tests/system/suite_debugger/tst_build_new_project/test.py b/tests/system/suite_debugger/tst_build_new_project/test.py
index 2799e91a8b1..2da3f55574a 100644
--- a/tests/system/suite_debugger/tst_build_new_project/test.py
+++ b/tests/system/suite_debugger/tst_build_new_project/test.py
@@ -5,7 +5,7 @@ project = "SquishProject"
 
 def main():
     startApplication("qtcreator" + SettingsPath)
-    createProject_Qt_GUI(projectsPath, project, defaultQtVersion, 1)
+    createProject_Qt_GUI(projectsPath, project, defaultQtVersion, True)
     clickButton(verifyEnabled(":*Qt Creator.Run_Core::Internal::FancyToolButton"))
     waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
     playButton = verifyEnabled(":Qt Creator.ReRun_QToolButton", False)
-- 
GitLab