From 8ca5b55a0bafd744cf62c20de379a7738cb76138 Mon Sep 17 00:00:00 2001
From: Christian Stenger <christian.stenger@digia.com>
Date: Tue, 7 May 2013 11:08:40 +0200
Subject: [PATCH] Squish: Prepare re-usage of batch editing...

...of the environment variables for the next run.

Change-Id: Iaf383dfa361971c75be0e180d72ab95c5df83ebe
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
---
 tests/system/objects.map          |  2 ++
 tests/system/shared/hook_utils.py | 26 +++++++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/tests/system/objects.map b/tests/system/objects.map
index b39ba183f66..abc6939063f 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -137,6 +137,8 @@
 :Restart required_QMessageBox	{text='The language change will take effect after a restart of Qt Creator.' type='QMessageBox' unnamed='1' visible='1'}
 :Revert to Saved.Proceed_QPushButton	{text='Proceed' type='QPushButton' unnamed='1' visible='1' window=':Revert to Saved_QMessageBox'}
 :Revert to Saved_QMessageBox	{text?='You will lose your current changes if you proceed reverting*' type='QMessageBox' unnamed='1' visible='1'}
+:RunSettingsEnvironmentDetails_Utils::DetailsButton	{leftWidget=':RunSettingsUseBuildEnvironment_QLabel' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:RunSettingsUseBuildEnvironment_QLabel	{text~='Us(e|ing) <b>Build Environment</b>' type='QLabel' unnamed='1' visible='1'}
 :Startup.contextHelpComboBox_QComboBox	{container=':Form.Startup_QGroupBox' name='contextHelpComboBox' type='QComboBox' visible='1'}
 :Symbol Server_Utils::CheckableMessageBox	{type='Utils::CheckableMessageBox' unnamed='1' visible='1' windowTitle='Symbol Server'}
 :User Interface.languageBox_QComboBox	{container=':Core__Internal__GeneralSettings.User Interface_QGroupBox' name='languageBox' type='QComboBox' visible='1'}
diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py
index fca63726a19..1683a1dc3e6 100644
--- a/tests/system/shared/hook_utils.py
+++ b/tests/system/shared/hook_utils.py
@@ -17,9 +17,7 @@ def modifyRunSettingsForHookInto(projectName, kitCount, port):
     switchToBuildOrRunSettingsFor(kitCount, 0, ProjectSettings.RUN)
     result = __configureCustomExecutable__(projectName, port, mkspec, qtVersion)
     if result:
-        clickButton(waitForObject("{window=':Qt Creator_Core::Internal::MainWindow' text='Details' "
-                                  "type='Utils::DetailsButton' unnamed='1' visible='1' "
-                                  "leftWidget={type='QLabel' text~='Us(e|ing) <b>Build Environment</b>' unnamed='1' visible='1'}}"))
+        ensureChecked(":RunSettingsEnvironmentDetails_Utils::DetailsButton")
         envVarsTableView = waitForObject("{type='QTableView' visible='1' unnamed='1'}")
         model = envVarsTableView.model()
         changingVars = []
@@ -41,17 +39,23 @@ def modifyRunSettingsForHookInto(projectName, kitCount, port):
                     changingVars.append("SQUISH_LIBQTDIR=%s" % replacement)
                 else:
                     changingVars.append(varName)
-                    #test.log("Unsetting %s for run" % varName)
-        clickButton(waitForObject("{text='Batch Edit...' type='QPushButton' unnamed='1' visible='1' "
-                                  "window=':Qt Creator_Core::Internal::MainWindow'}"))
-        editor = waitForObject("{type='TextEditor::SnippetEditorWidget' unnamed='1' visible='1' "
-                               "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}")
-        typeLines(editor, changingVars)
-        clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' "
-                                  "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}"))
+        batchEditRunEnvironment(kitCount, 0, changingVars, True)
     switchViewTo(ViewConstants.EDIT)
     return result
 
+def batchEditRunEnvironment(kitCount, currentTarget, modifications, alreadyOnRunSettings=False):
+    if not alreadyOnRunSettings:
+        switchViewTo(ViewConstants.PROJECTS)
+        switchToBuildOrRunSettingsFor(kitCount, currentTarget, ProjectSettings.RUN)
+    ensureChecked(":RunSettingsEnvironmentDetails_Utils::DetailsButton")
+    clickButton(waitForObject("{text='Batch Edit...' type='QPushButton' unnamed='1' visible='1' "
+                              "window=':Qt Creator_Core::Internal::MainWindow'}"))
+    editor = waitForObject("{type='TextEditor::SnippetEditorWidget' unnamed='1' visible='1' "
+                           "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}")
+    typeLines(editor, modifications)
+    clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' "
+                              "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}"))
+
 def modifyRunSettingsForHookIntoQtQuickUI(kitCount, workingDir, projectName, port):
     switchViewTo(ViewConstants.PROJECTS)
     switchToBuildOrRunSettingsFor(kitCount, 0, ProjectSettings.RUN, True)
-- 
GitLab