From 64a1ec7448b89dc7ff3b03d777754a69009bd26e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 13 Jun 2025 13:14:03 +0200 Subject: [PATCH] SquishTests: Adapt to ui changes Change-Id: I275d8f6cbb3cb30b716df68120921cbf9192fcfb Reviewed-by: Jukka Nokso Reviewed-by: hjk Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/projectwindow.cpp | 5 ++- tests/system/shared/project_explorer.py | 42 ++++++++++++------- .../suite_general/tst_remove_kits/test.py | 12 +++--- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index c60f192126e..13d964a007e 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -1254,7 +1254,9 @@ public: ProjectWindowTabWidget(QWidget *parent = nullptr) : QTabWidget(parent) { - setTabBar(new QtcTabBar); // Must be the first called setter! + auto tabBar = new QtcTabBar; + setTabBar(tabBar); // Must be the first called setter! + tabBar->setObjectName("ProjectConfigurationTabBar"); // used by Squish setDocumentMode(true); } }; @@ -1409,6 +1411,7 @@ public: m_scrollArea->setWidget(scrolledWidget); m_projectSelection = new QComboBox; + m_projectSelection->setObjectName("ProjectSelection"); // used by Squish m_projectSelection->setModel(&m_projectsModel); connect(m_projectSelection, &QComboBox::activated, this, &ProjectWindowPrivate::projectSelected, Qt::QueuedConnection); diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index f74e3a107e8..8eef13b37ac 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -15,18 +15,33 @@ def __kitIsActivated__(kit): return not ("

Click to activate

" in str(kit.toolTip) or "

Kit is unsuited for project

" in str(kit.toolTip)) + +# helper function - assumes to be already in Projects mode +def kitIndicesFromProjectsMode(): + treeView = waitForObject(":Projects.ProjectNavigationTreeView") + projectCombo = waitForObject(":ProjectSelectionComboBox") + currentProject = str(projectCombo.currentText) + allIndices = dumpIndices(treeView.model()) + projectIndex = None + for idx in allIndices: + if str(idx.data(0)) == currentProject: + projectIndex = idx + break + test.verify(projectIndex is not None, "Found the project index.") + secondLevelIndices = dumpIndices(treeView.model(), projectIndex) + test.compare(3, len(secondLevelIndices), "Verify expected count of secondary level.") + kitIndices = dumpIndices(treeView.model(), secondLevelIndices[0]) + return kitIndices + + # returns a list of the IDs (see class Targets) of all kits # which are currently configured for the active project # Creator must be in projects mode when calling def iterateConfiguredKits(): - treeView = waitForObject(":Projects.ProjectNavigationTreeView") - bAndRIndex = getQModelIndexStr("text='Build & Run'", ":Projects.ProjectNavigationTreeView") - kitIndices = dumpIndices(treeView.model(), waitForObject(bAndRIndex)) + kitIndices = kitIndicesFromProjectsMode() configuredKitNames = map(lambda t: str(t.data(0)), filter(__kitIsActivated__, kitIndices)) - # Remove hide/show entries which are in tree but not kits - configuredKitNames = filter(lambda n: n != "Hide Inactive Kits" and n != "Show All Kits", - configuredKitNames) + return map(Targets.getIdForTargetName, configuredKitNames) @@ -40,15 +55,14 @@ def iterateConfiguredKits(): # ProjectSettings.BUILD or ProjectSettings.RUN) def switchToBuildOrRunSettingsFor(wantedKit, projectSettings): treeView = waitForObject(":Projects.ProjectNavigationTreeView") - bAndRIndex = getQModelIndexStr("text='Build & Run'", ":Projects.ProjectNavigationTreeView") wantedKitName = Targets.getStringForTarget(wantedKit) - wantedKitIndexString = getQModelIndexStr("text='%s'" % wantedKitName, bAndRIndex) + wantedKitIndexString = getQModelIndexStr("text='%s'" % wantedKitName, ":Projects.ProjectNavigationTreeView") if not test.verify(__kitIsActivated__(findObject(wantedKitIndexString)), "Verifying target '%s' is enabled." % wantedKitName): raise Exception("Kit '%s' is not activated in the project." % wantedKitName) index = waitForObject(wantedKitIndexString) - projectAlreadySelected = index.font.bold - if projectAlreadySelected: + kitAlreadySelected = index.font.bold + if kitAlreadySelected: test.log("Kit '%s' is already selected." % wantedKitName) else: test.log("Selecting kit '%s'..." % wantedKitName) @@ -56,14 +70,14 @@ def switchToBuildOrRunSettingsFor(wantedKit, projectSettings): mouseClick(index) if projectSettings == ProjectSettings.BUILD: - settingsIndex = getQModelIndexStr("text='Build'", wantedKitIndexString) + settingsText = "Build Settings" elif projectSettings == ProjectSettings.RUN: - settingsIndex = getQModelIndexStr("text='Run'", wantedKitIndexString) + settingsText = "Run Settings" else: raise Exception("Unexpected projectSettings parameter (%s), needs to be BUILD or RUN." % str(projectSettings)) - mouseClick(waitForObject(settingsIndex)) - return not projectAlreadySelected + clickOnTab(":ProjectConfigurationTabBar", settingsText) + return not kitAlreadySelected # this function switches "Run in terminal" on or off in a project's run settings # param wantedKit specifies the ID of the kit to edit (see class Targets) diff --git a/tests/system/suite_general/tst_remove_kits/test.py b/tests/system/suite_general/tst_remove_kits/test.py index 652390e0107..ec578ca9c4d 100644 --- a/tests/system/suite_general/tst_remove_kits/test.py +++ b/tests/system/suite_general/tst_remove_kits/test.py @@ -4,13 +4,11 @@ source("../../shared/qtcreator.py") def verifyProjectsMode(expectedKits): - treeView = waitForObject(":Projects.ProjectNavigationTreeView") - bAndRIndex = getQModelIndexStr("text='Build & Run'", - ":Projects.ProjectNavigationTreeView") - foundKits = dumpItems(treeView.model(), waitForObject(bAndRIndex)) - # ignore Python kits and non-kit item - excludes = ('Python', 'Hide Inactive Kits', 'Show All Kits') - relevantKits = list(filter(lambda x: all(ex not in x for ex in excludes), foundKits)) + kitIndices = kitIndicesFromProjectsMode() + foundKits = list(map(lambda t: str(t.data(0)), kitIndices)) + + # ignore Python kits + relevantKits = list(filter(lambda x: 'Python' not in x, foundKits)) test.compare(len(relevantKits), len(expectedKits), "Verify number of listed kits.") test.compare(set(relevantKits), set(expectedKits), "Verify if expected kits are listed.") hasKits = len(expectedKits) > 0