From 20c0dcfe1deec7a9ed771462fd6f61ad0eddb0d4 Mon Sep 17 00:00:00 2001
From: Robert Loehning <robert.loehning@digia.com>
Date: Thu, 15 May 2014 13:43:57 +0200
Subject: [PATCH] Squish: Simplify __createProjectHandleQtQuickSelection__()

Change-Id: I02f76a90aa6a464f36d84dcc70698639a74d7f86
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
---
 tests/system/shared/classes.py                |  5 +++-
 tests/system/shared/project.py                | 30 +++++++------------
 .../tst_create_proj_wizard/test.py            |  4 +--
 3 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/tests/system/shared/classes.py b/tests/system/shared/classes.py
index e892d469811..35061df5c06 100644
--- a/tests/system/shared/classes.py
+++ b/tests/system/shared/classes.py
@@ -144,7 +144,10 @@ class SubprocessType:
         if subprocessType == SubprocessType.QT_WIDGET:
             return "QMainWindow"
         if subprocessType == SubprocessType.QT_QUICK_APPLICATION:
-            return "QtQuick%sApplicationViewer" % qtQuickVersion[0]
+            qqv = "2"
+            if qtQuickVersion[0] == "1":
+                qqv = "1"
+            return "QtQuick%sApplicationViewer" % qqv
         if subprocessType == SubprocessType.QT_QUICK_UI:
             if qtQuickVersion == "1.1":
                 return "QDeclarativeViewer"
diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py
index 8c11cd00241..835cc2ddbfb 100644
--- a/tests/system/shared/project.py
+++ b/tests/system/shared/project.py
@@ -133,25 +133,15 @@ def __createProjectSetNameAndPath__(path, projectName = None, checks = True, lib
     clickButton(waitForObject(":Next_QPushButton"))
     return str(projectName)
 
-def __createProjectHandleQtQuickSelection__(qtQuickVersion, controlsVersion):
+def __createProjectHandleQtQuickSelection__(qtQuickOrControlsVersion):
     comboBox = waitForObject("{type='QComboBox' unnamed='1' visible='1' "
                              "leftWidget={text='Qt Quick component set:' type='QLabel' unnamed='1' "
                              "visible='1'}}")
-    if qtQuickVersion == "1.1":
-        selectFromCombo(comboBox, "Qt Quick 1.1")
-        if controlsVersion:
-            test.warning("Controls are not available for Quick 1.")
-    elif qtQuickVersion[:2] == "2.":
-        if controlsVersion:
-            if controlsVersion in ("1.0", "1.1"):
-                selectFromCombo(comboBox, "Qt Quick Controls %s" % controlsVersion)
-            else:
-                test.fatal("Got unknown Qt Quick Controls version: %s - trying to continue."
-                           % str(controlsVersion))
-        else:
-            selectFromCombo(comboBox, "Qt Quick %s" % qtQuickVersion)
-    else:
-        test.fatal("Got unknown Qt Quick version: %s - trying to continue." % str(qtQuickVersion))
+    try:
+        selectFromCombo(comboBox, "Qt Quick %s" % qtQuickOrControlsVersion)
+    except:
+        t,v = sys.exc_info()[:2]
+        test.fatal("Exception while trying to select Qt Quick version", "%s (%s)" % (str(t), str(v)))
     label = waitForObject("{type='QLabel' unnamed='1' visible='1' text?='Creates a *' }")
     requires = re.match(".*Requires Qt (\d\.\d).*", str(label.text))
     if requires:
@@ -285,10 +275,10 @@ def createProject_Qt_Console(path, projectName, checks = True):
 
 def createNewQtQuickApplication(workingDir, projectName = None,
                                 targets=Targets.desktopTargetClasses(), qtQuickVersion="1.1",
-                                fromWelcome=False, controlsVersion=None):
+                                fromWelcome=False):
     available = __createProjectOrFileSelectType__("  Applications", "Qt Quick Application", fromWelcome)
     projectName = __createProjectSetNameAndPath__(workingDir, projectName)
-    requiredQt = __createProjectHandleQtQuickSelection__(qtQuickVersion, controlsVersion)
+    requiredQt = __createProjectHandleQtQuickSelection__(qtQuickVersion)
     __modifyAvailableTargets__(available, requiredQt)
     checkedTargets = __chooseTargets__(targets, available)
     snooze(1)
@@ -298,12 +288,12 @@ def createNewQtQuickApplication(workingDir, projectName = None,
     progressBarWait(10000)
     return checkedTargets, projectName
 
-def createNewQtQuickUI(workingDir, qtQuickVersion="1.1", controlsVersion=None):
+def createNewQtQuickUI(workingDir, qtQuickVersion="1.1"):
     __createProjectOrFileSelectType__("  Applications", "Qt Quick UI")
     if workingDir == None:
         workingDir = tempDir()
     projectName = __createProjectSetNameAndPath__(workingDir)
-    __createProjectHandleQtQuickSelection__(qtQuickVersion, controlsVersion)
+    __createProjectHandleQtQuickSelection__(qtQuickVersion)
     __createProjectHandleLastPage__()
     return projectName
 
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 d3782bcd8b0..73e70c5a4d1 100644
--- a/tests/system/suite_general/tst_create_proj_wizard/test.py
+++ b/tests/system/suite_general/tst_create_proj_wizard/test.py
@@ -33,7 +33,7 @@ import re
 
 def main():
     global tmpSettingsDir
-    quickCombinations = [["1.1",None], ["2.1",None], ["2.2",None], ["2.1","1.0"], ["2.2","1.1"]]
+    quickCombinations = ["1.1", "2.1", "2.2", "Controls 1.0", "Controls 1.1"]
     startApplication("qtcreator" + SettingsPath)
     if not startedWithoutPluginError():
         return
@@ -73,7 +73,7 @@ def main():
         displayedPlatforms = __createProject__(category, template)
         if template == "Qt Quick Application":
             for counter, qComb in enumerate(quickCombinations):
-                requiredQtVersion = __createProjectHandleQtQuickSelection__(qComb[0], qComb[1])
+                requiredQtVersion = __createProjectHandleQtQuickSelection__(qComb)
                 __modifyAvailableTargets__(displayedPlatforms, requiredQtVersion, True)
                 verifyKitCheckboxes(kits, displayedPlatforms)
                 # FIXME: if QTBUG-35203 is fixed replace by triggering the shortcut for Back
-- 
GitLab