aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2022-10-24 23:44:15 +0200
committerRobert Löhning <robert.loehning@qt.io>2023-03-20 16:09:22 +0000
commitb39f19b81bbca68b3ef4e3f63bb8fbf8f5e7c683 (patch)
tree580e5972260f2200b7dd8c01074b62bbf8f1b44e
parentcb31c6c0b45a73a524866c2095ddf11498c1c76a (diff)
Squish: Add test for adding and removing Qt versions
Change-Id: I3ea411149d728338b0e4d875b40fb5a414141523 Reviewed-by: Miguel Costa <miguel.costa@qt.io>
-rw-r--r--Tests/system/Readme.txt3
-rw-r--r--Tests/system/suite_configuration/shared/scripts/config_utils.py24
-rw-r--r--Tests/system/suite_configuration/shared/scripts/names.py19
-rw-r--r--Tests/system/suite_configuration/suite.conf8
-rw-r--r--Tests/system/suite_configuration/tst_add_remove_qt_versions/test.py94
5 files changed, 148 insertions, 0 deletions
diff --git a/Tests/system/Readme.txt b/Tests/system/Readme.txt
index 29f794d6..596d423b 100644
--- a/Tests/system/Readme.txt
+++ b/Tests/system/Readme.txt
@@ -18,3 +18,6 @@ so, you will have to install Qt VS Tools again.
Some tests require the following environment variables to be set to the correct values:
SQUISH_VSTOOLS_VERSION: The expected version of Qt VS Tools
+SQUISH_VSTOOLS_QTDIRS: A list of Qt installations to be used by the tests, i.e. the paths to the
+ parent directories of the respective Qt versions' bin-directories,
+ separated by semicola.
diff --git a/Tests/system/suite_configuration/shared/scripts/config_utils.py b/Tests/system/suite_configuration/shared/scripts/config_utils.py
new file mode 100644
index 00000000..52cdd3b3
--- /dev/null
+++ b/Tests/system/suite_configuration/shared/scripts/config_utils.py
@@ -0,0 +1,24 @@
+####################################################################################################
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+####################################################################################################
+
+# -*- coding: utf-8 -*-
+
+import os
+
+
+def readQtDirs():
+ dirString = os.getenv("SQUISH_VSTOOLS_QTDIRS")
+ if not dirString:
+ return []
+ uniquePaths = set()
+ qtDirs = []
+ for current in dirString.split(";"):
+ loweredPath = current.lower()
+ if loweredPath in uniquePaths:
+ continue
+ uniquePaths.add(loweredPath)
+ qtDirs.append({"path": current,
+ "name": current.rsplit(":")[-1].strip("\\").replace("\\", "_")})
+ return qtDirs
diff --git a/Tests/system/suite_configuration/shared/scripts/names.py b/Tests/system/suite_configuration/shared/scripts/names.py
new file mode 100644
index 00000000..43aa28ba
--- /dev/null
+++ b/Tests/system/suite_configuration/shared/scripts/names.py
@@ -0,0 +1,19 @@
+####################################################################################################
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+####################################################################################################
+
+# encoding: UTF-8
+
+from objectmaphelper import *
+import globalnames
+pART_Popup_Qt_Versions_MenuItem = {"text": "Qt Versions", "type": "MenuItem"}
+options_Dialog = {"text": "Options", "type": "Dialog"}
+options_OK_Button = {"container": options_Dialog, "text": "OK", "type": "Button"}
+options_WPFControl = {"class": "System.Windows.Documents.AdornerDecorator",
+ "container": options_Dialog, "type": "WPFControl"}
+dataGrid_Table = {"container": options_WPFControl, "name": "DataGrid", "type": "Table"}
+options_Cancel_Button = {"container": options_Dialog, "text": "Cancel", "type": "Button"}
+You_must_select_a_Qt_version_Label = {"container": globalnames.microsoft_Visual_Studio_Window,
+ "text": Wildcard("*You must select a Qt version*"),
+ "type": "Label"}
diff --git a/Tests/system/suite_configuration/suite.conf b/Tests/system/suite_configuration/suite.conf
new file mode 100644
index 00000000..118165ef
--- /dev/null
+++ b/Tests/system/suite_configuration/suite.conf
@@ -0,0 +1,8 @@
+AUT=devenv
+ENVVARS=envvars
+IMPLICITAUTSTART=0
+LANGUAGE=Python
+OBJECTMAPSTYLE=script
+TEST_CASES=tst_add_remove_qt_versions
+VERSION=3
+WRAPPERS=Windows
diff --git a/Tests/system/suite_configuration/tst_add_remove_qt_versions/test.py b/Tests/system/suite_configuration/tst_add_remove_qt_versions/test.py
new file mode 100644
index 00000000..0b9cf9db
--- /dev/null
+++ b/Tests/system/suite_configuration/tst_add_remove_qt_versions/test.py
@@ -0,0 +1,94 @@
+####################################################################################################
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+####################################################################################################
+
+# -*- coding: utf-8 -*-
+
+source("../../shared/utils.py")
+source("../shared/scripts/config_utils.py")
+
+import names
+
+
+def main():
+ qtDirs = readQtDirs()
+ if not qtDirs:
+ test.fatal("No Qt versions known", "Did you set SQUISH_VSTOOLS_QTDIRS correctly?")
+ return
+ version = startAppGetVersion()
+ if not version:
+ return
+ test.verify(checkSelectQtLabel(),
+ "Warning about having to select a Qt version is being shown?")
+ # Add the Qt versions
+ openVsToolsMenu(version)
+ mouseClick(waitForObject(names.pART_Popup_Qt_Versions_MenuItem))
+ if not test.compare(waitForObjectExists(names.dataGrid_Table).rowCount, 1,
+ "The table should have exactly one line before adding Qt versions."):
+ test.fatal("Unexpected table shown. Probably there is either an unexpected configuration "
+ "or the UI changed.")
+ clickButton(waitForObject(names.options_Cancel_Button))
+ closeMainWindow()
+ return
+ for i, qtDir in enumerate(qtDirs):
+ mouseClick(waitForObject(tableCell(1, i)))
+ typeToEdit(tableCellEdit(3, i), qtDir["path"])
+ typeToEdit(tableCellEdit(1, i), qtDir["name"])
+ test.compare(waitForObjectExists(names.dataGrid_Table).rowCount, i + 2,
+ "The table should have %d lines after adding %d Qt versions."
+ % (i + 2, i + 1))
+ clickButton(waitForObject(names.options_OK_Button))
+ waitFor("not object.exists(names.options_Dialog)")
+ test.verify(not checkSelectQtLabel(),
+ "Warning about having to select a Qt version disappeared?")
+ # Sort qtDirs by name because that's the order in which they'll be displayed
+ qtDirs.sort(key=lambda dir: dir["name"].lower())
+ # Check and remove the Qt versions, but cancel changes, then repeat and click "OK"
+ for closeButton in [names.options_Cancel_Button, names.options_OK_Button]:
+ openVsToolsMenu(version)
+ mouseClick(waitForObject(names.pART_Popup_Qt_Versions_MenuItem))
+ if test.compare(waitForObjectExists(names.dataGrid_Table).rowCount, len(qtDirs) + 1,
+ "The table should have %d lines after adding Qt versions."
+ % (len(qtDirs) + 1)):
+ for i, qtDir in enumerate(qtDirs):
+ test.compare(waitForObject(tableCellEdit(1, i)).text, qtDir["name"],
+ "Is the Qt version's name shown as entered?")
+ test.compare(waitForObject(tableCellEdit(3, i)).text, qtDir["path"],
+ "Is the Qt version's path shown as entered?")
+ clickButton(waitForObject({"container": tableCell(1, i),
+ "text": "", "type": "Button"}))
+ snooze(1)
+ clickButton(waitForObject(closeButton))
+ waitFor("not object.exists(names.options_Dialog)")
+ # Check that Qt versions were removed
+ openVsToolsMenu(version)
+ mouseClick(waitForObject(names.pART_Popup_Qt_Versions_MenuItem))
+ test.compare(waitForObjectExists(names.dataGrid_Table).rowCount, 1,
+ "The table should have exactly one line after removing all Qt versions.")
+ clickButton(waitForObject(names.options_OK_Button))
+ waitFor("not object.exists(names.options_Dialog)")
+ closeMainWindow()
+
+
+def checkSelectQtLabel():
+ try:
+ waitForObjectExists(names.You_must_select_a_Qt_version_Label, 1000)
+ return True
+ except:
+ return False
+
+
+def tableCell(col, row):
+ return {"column": col, "container": names.dataGrid_Table, "row": row, "type": "TableCell"}
+
+
+def tableCellEdit(col, row):
+ return {"container": tableCell(col, row), "type": "Edit"}
+
+
+def typeToEdit(editId, text):
+ edit = waitForObject(editId)
+ mouseClick(edit)
+ type(edit, text)
+ waitFor("waitForObject(editId).text == text")