Skip to content

feat(at-spi): 补全 setObjectName() 作为 AT-SPI 测试定位锚点 (DDE-166) - #208

Draft
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/at-spi-objectname-anchor-DDE-166
Draft

feat(at-spi): 补全 setObjectName() 作为 AT-SPI 测试定位锚点 (DDE-166)#208
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/at-spi-objectname-anchor-DDE-166

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Aug 28, 2026

Copy link
Copy Markdown

背景

参考 DDE-198:AT-SPI 测试定位锚点规则变更,从 setAccessibleName() 改为 setObjectName()(C++/DTK)。

Qt 的 AT-SPI bridge 在未显式设置 QAccessible::Identifier 时,会自动沿 objectName 祖先链拼接生成 AccessibleId(定位锚点);setAccessibleName() 仅保留屏幕阅读器语义,不再作为定位锚点。

扫描结论

对仓库全量 C++ 源码扫描 setObjectName此前调用数为 0,9 个交互控件均未设置 objectName

# 控件 类型 旧 setAccessibleName 旧 setObjectName 本仓库可改
1 Cancel 按钮 QPushButton (DDialog) "Cancel"
2 Confirm 按钮 DSuggestButton (DDialog) "Confirm"
3 密码输入框 DPasswordEdit (m_passwordInput) "PasswordInput"
4 管理员下拉框 QComboBox (m_adminsCombo) "AdminUsers"
5 AuthDialog 本身 AuthDialog (DDialog 子类) — (工厂兜底)
6 显隐密码按钮 DSuggestButton (DPasswordEdit 内部) DTK 内置 ❌ DTK 内部
7 内部 LineEdit QLineEdit (DPasswordEdit 内部) — (工厂兜底) ❌ DTK 内部
8 标题/消息标签 QLabel (DDialog 内部) DTK 内置 ❌ DTK 内部
9 内容容器 QWidget (DDialog 内部) — (工厂兜底) ❌ DTK 内部

改动

对前 5 个本仓库可改控件补全 setObjectName()(PascalCase、项目级去重),setAccessibleName() 保留不删除:

setObjectName("AuthDialog");                          // AuthDialog 本身
getButton(cancelId)->setObjectName("CancelButton");   // Cancel 按钮
getButton(confirmId)->setObjectName("ConfirmButton"); // Confirm 按钮
m_passwordInput->setObjectName("PasswordInput");      // 密码输入框
m_adminsCombo->setObjectName("AdminUsers");           // 管理员下拉框

后 4 个(#6#9)为 DDialog/DPasswordEdit 内部子控件,由 DTK 创建,其 objectName/AccessibleId 属 DTK 职责,本仓库 PR 不涉及;accessibleFactory 仍为其提供 Name 兜底。

accessibleFactory 兼容性

accessibledefine.h 中的 getAccessibleName() 无需调整

  • 该函数仅生成屏幕阅读器 NameQAccessible::Name),与定位锚点 AccessibleId独立通道——AccessibleId 由 Qt bridge 从 objectName 链生成,工厂不参与。
  • 工厂类继承 QAccessibleWidget 且未覆写 text(QAccessible::Identifier),故 Identifier 走 Qt 默认(空 → 回退 objectName 链),新增 setObjectName() 即可生效。
  • 现有三级优先级(accessibleName → objectName → 兜底名)对 Name 语义仍然正确:setAccessibleName 优先用于读屏,符合新规则「Name 仅供读屏语义」。

许可协议

仅修改 AuthDialog.cpp,其文件头为 SPDX-FileCopyrightText: 2017 - 2026,年份已含 2026,无需更新。

Closes DDE-166

Summary by Sourcery

为认证对话框控件补全 objectName,以支持基于 AT-SPI 的稳定测试定位。

New Features:

  • 为认证对话框及其可定位的交互控件补充 AT-SPI 测试所需的对象名称锚点。

Enhancements:

  • 保留现有无障碍名称设置,同时为对话框、取消/确认按钮、密码输入框和管理员下拉框设置唯一的 objectName。

…ontrols

Per DDE-198 rule change, the AT-SPI test locator anchor switches from
setAccessibleName() to setObjectName() (C++/DTK). Qt's AT-SPI bridge
auto-generates AccessibleId from the objectName ancestor chain;
setAccessibleName() is retained only for screen-reader semantics.

Previously all 9 interactive controls lacked setObjectName(): 4 had only
setAccessibleName() (Cancel/Confirm buttons, PasswordInput, AdminUsers
combo) and 5 relied on accessibleFactory fallback. Add setObjectName()
to the 5 controls created in this repo:

- AuthDialog            -> AuthDialog
- Cancel button         -> CancelButton
- Confirm button        -> ConfirmButton
- m_passwordInput       -> PasswordInput
- m_adminsCombo         -> AdminUsers

setAccessibleName() calls are kept (not removed). The remaining 4
controls are DDialog/DPasswordEdit internal sub-controls created by DTK;
their objectName/AccessibleId is DTK's responsibility, while
accessibleFactory still covers the Name channel.

accessibleFactory (accessibledefine.h) needs no adjustment: its
getAccessibleName() only produces the screen-reader Name (separate from
the AccessibleId locator channel), and the existing three-level priority
(accessibleName -> objectName -> fallback) remains valid for Name.

Closes DDE-166
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MyLeeJiEun

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR. 😃

@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

在 AuthDialog 初始化阶段为窗口及四个应用侧交互控件补全 setObjectName(),使 Qt AT-SPI bridge 能从 objectName 祖先链生成 AccessibleId;同时保留 setAccessibleName() 作为屏幕阅读器 Name,并明确 DTK 内部子控件和 accessibleFactory 不在本次改动范围内。

Sequence diagram for AT-SPI anchor initialization

sequenceDiagram
    participant AuthDialog
    participant CancelButton
    participant ConfirmButton
    participant PasswordInput
    participant AdminUsers
    participant QtATSPI as QtATSPI_Bridge

    AuthDialog->>AuthDialog: initUI()
    AuthDialog->>AuthDialog: setObjectName(AuthDialog)
    AuthDialog->>CancelButton: setAccessibleName(Cancel)
    AuthDialog->>CancelButton: setObjectName(CancelButton)
    AuthDialog->>ConfirmButton: setAccessibleName(Confirm)
    AuthDialog->>ConfirmButton: setObjectName(ConfirmButton)
    AuthDialog->>PasswordInput: setAccessibleName(PasswordInput)
    AuthDialog->>PasswordInput: setObjectName(PasswordInput)
    AuthDialog->>AdminUsers: setAccessibleName(AdminUsers)
    AuthDialog->>AdminUsers: setObjectName(AdminUsers)
    QtATSPI->>AuthDialog: derive AccessibleId from objectName ancestor chain
Loading

File-Level Changes

Change Details Files
为应用可控的 AT-SPI 交互控件补充基于 objectName 的定位锚点,同时保留原有屏幕阅读器名称语义。
  • 为 AuthDialog 设置对象名,作为祖先链锚点。
  • 为取消按钮、确认按钮、密码输入框和管理员下拉框设置唯一的 PascalCase objectName。
  • 保留现有 setAccessibleName() 调用,不修改 accessibleFactory 或 DTK 内部控件。
AuthDialog.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants