From f521c9f0628fc89ddc41a1584d65369f9c07a2f3 Mon Sep 17 00:00:00 2001
From: Robert Loehning <robert.loehning@nokia.com>
Date: Thu, 5 Apr 2012 14:29:13 +0200
Subject: [PATCH] Squish: Always use the same function for preparing templates

Change-Id: I90dac33dde4c0c3d39c8e8038371dfbb3403dce3
Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
---
 tests/system/shared/project.py                            | 6 ++++++
 tests/system/shared/suites_qtta.py                        | 7 -------
 tests/system/suite_general/tst_create_proj_wizard/test.py | 8 +-------
 tests/system/suite_qtquick/tst_qml_editor/test.py         | 8 +-------
 tests/system/suite_qtquick/tst_qtquick_creation2/test.py  | 8 +-------
 5 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py
index 6228a9b8f24..43f5c34d2b2 100644
--- a/tests/system/shared/project.py
+++ b/tests/system/shared/project.py
@@ -449,3 +449,9 @@ def __getSupportedPlatforms__(text, getAsStrings=False):
     if getAsStrings:
         result = QtQuickConstants.getTargetsAsStrings(result)
     return result, version
+
+# copy example project (sourceExample is path to project) to temporary directory inside repository
+def prepareTemplate(sourceExample):
+    templateDir = os.path.abspath(tempDir() + "/template")
+    shutil.copytree(sourceExample, templateDir)
+    return templateDir
diff --git a/tests/system/shared/suites_qtta.py b/tests/system/shared/suites_qtta.py
index c177e0132ac..d435b154e7d 100755
--- a/tests/system/shared/suites_qtta.py
+++ b/tests/system/shared/suites_qtta.py
@@ -33,10 +33,3 @@ def checkSyntaxError(issuesView, expectedTextsArray, warnIfMoreIssues = True):
                 else:
                     return True
     return False
-
-# copy example project (sourceExample is path to project) to <temp>/template dir
-def prepareTemplate(sourceExample):
-    templateDir = os.path.abspath(tempDir() + "/template")
-    shutil.copytree(sourceExample, templateDir)
-    return templateDir
-
diff --git a/tests/system/suite_general/tst_create_proj_wizard/test.py b/tests/system/suite_general/tst_create_proj_wizard/test.py
index d62442138e5..e600f3e7d48 100644
--- a/tests/system/suite_general/tst_create_proj_wizard/test.py
+++ b/tests/system/suite_general/tst_create_proj_wizard/test.py
@@ -7,7 +7,7 @@ def main():
     sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
     if not neededFilePresent(sourceExample):
         return
-    prepareTemplate(sourceExample)
+    templateDir = prepareTemplate(sourceExample)
     startApplication("qtcreator" + SettingsPath)
     overrideInstallLazySignalHandler()
     installLazySignalHandler(":frame.templateDescription_QTextBrowser",
@@ -102,12 +102,6 @@ def main():
         clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1'}", 20000))
     invokeMenuItem("File", "Exit")
 
-def prepareTemplate(sourceExample):
-    global templateDir
-    templateDir = tempDir()
-    templateDir = os.path.abspath(templateDir + "/template")
-    shutil.copytree(sourceExample, templateDir)
-
 def cleanup():
     global templateDir
     # waiting for a clean exit - for a full-remove of the temp directory
diff --git a/tests/system/suite_qtquick/tst_qml_editor/test.py b/tests/system/suite_qtquick/tst_qml_editor/test.py
index 1b01c3fc00e..38396f7e929 100644
--- a/tests/system/suite_qtquick/tst_qml_editor/test.py
+++ b/tests/system/suite_qtquick/tst_qml_editor/test.py
@@ -14,7 +14,7 @@ def main():
     addHelpDocumentationFromSDK()
     # using a temporary directory won't mess up an eventually exisiting
     workingDir = tempDir()
-    prepareTemplate(sourceExample)
+    templateDir = prepareTemplate(sourceExample)
     prepareForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
     installLazySignalHandler("{type='Core::FutureProgress' unnamed='1''}", "finished()", "__handleFutureProgress__")
     createNewQtQuickApplication(workingDir, "untitled", templateDir + "/qml/focus.qml")
@@ -26,12 +26,6 @@ def main():
     test.log("Test finished")
     invokeMenuItem("File", "Exit")
 
-def prepareTemplate(sourceExample):
-    global templateDir
-    templateDir = tempDir()
-    templateDir = os.path.abspath(templateDir + "/template")
-    shutil.copytree(sourceExample, templateDir)
-
 def testRenameId():
     global searchFinished
     test.log("Testing rename of id")
diff --git a/tests/system/suite_qtquick/tst_qtquick_creation2/test.py b/tests/system/suite_qtquick/tst_qtquick_creation2/test.py
index c87cd78ddb9..e590351fb5d 100644
--- a/tests/system/suite_qtquick/tst_qtquick_creation2/test.py
+++ b/tests/system/suite_qtquick/tst_qtquick_creation2/test.py
@@ -11,7 +11,7 @@ def main():
     startApplication("qtcreator" + SettingsPath)
     # using a temporary directory won't mess up an eventually exisiting
     workingDir = tempDir()
-    prepareTemplate(sourceExample)
+    templateDir = prepareTemplate(sourceExample)
     projectName = createNewQtQuickApplication(workingDir, None, templateDir + "/qml/textselection.qml")
     # wait for parsing to complete
     waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
@@ -50,12 +50,6 @@ def subprocessFunction():
     test.log("Closing QmlApplicationViewer")
     sendEvent("QCloseEvent", "{type='QmlApplicationViewer' unnamed='1' visible='1'}")
 
-def prepareTemplate(sourceExample):
-    global templateDir
-    templateDir = tempDir()
-    templateDir = os.path.abspath(templateDir + "/template")
-    shutil.copytree(sourceExample, templateDir)
-
 def cleanup():
     global workingDir,templateDir
     # waiting for a clean exit - for a full-remove of the temp directory
-- 
GitLab