[Tests] Name the tab, home and settings widgets the GUI tests address (#7696)

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-11-04 06:23:44 +01:00 • committed by GitHub
parent d2abd645e8
commit 34201122ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 102 additions and 0 deletions

View file

@ -6,6 +6,7 @@ class TabSupervisor;
TabHome::TabHome(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
{
setObjectName("TabHome");
homeWidget = new HomeWidget(this, tabSupervisor);
setCentralWidget(homeWidget);
}

View file

@ -54,6 +54,7 @@
#include <QPainter>
#include <QRect>
#include <QSharedPointer>
#include <QStackedWidget>
#include <QStringLiteral>
#include <QStyle>
#include <QStyleOption>
@ -157,6 +158,15 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *
tabReplays(nullptr), tabAdmin(nullptr), tabCardArtRules(nullptr), tabLog(nullptr), tabReport(nullptr),
tabModeration(nullptr), tabDeveloper(nullptr), isLocalGame(false)
{
setObjectName("tabSupervisor");
// QTabWidget keeps tab pages in an internal stacked widget. Give it a stable
// name so the GUI tests can address the pages by a readable path
// (tabSupervisor/stackedWidget/<TabName>).
if (auto *stackedWidget = findChild<QStackedWidget *>()) {
stackedWidget->setObjectName("stackedWidget");
}
setElideMode(Qt::ElideRight);
setMovable(true);
setIconSize(QSize(15, 15));
@ -462,6 +472,9 @@ void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager
auto closeSide = static_cast<QTabBar::ButtonPosition>(
tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tabBar()));
auto *closeButton = new CloseButton(tab);
// No object name: the tab bar index shifts when tabs move or close, so an
// index-derived name would go stale (or collide). Callers find the button
// through the tab widget instead.
if (manager) {
// If managed, all close requests should go through the menu action
connect(closeButton, &CloseButton::clicked, this, [manager] { checkAndTrigger(manager, false); });