Skip to content

Wip protocol tests - #1270

Open
zorowk wants to merge 18 commits into
linuxdeepin:masterfrom
zorowk:wip_protocol_tests
Open

Wip protocol tests#1270
zorowk wants to merge 18 commits into
linuxdeepin:masterfrom
zorowk:wip_protocol_tests

Conversation

@zorowk

@zorowk zorowk commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
  • P:协议/资源级;验证请求、事件和协议错误。

  • I:生产集成级;验证生产模块的状态、回调或生命周期。

  • E:端到端业务级;验证真实生产对象产生了业务结果。

  • V:渲染/像素级;在 E 基础上读取渲染结果或像素。(只有capture, color等在使用)

  • 已注册并有测试目录的 19 个当前协议:XML 共 185 条 request,其中测试客户端直接
    调用了 165 条(89.2%)

  • 去掉 48 条 destroy 生命周期 request 后,剩余 137 条工厂、配置和业务 request 中有
    120 条(87.6%) 被直接调用。

  • 19 个协议中 16 个(84.2%) 至少有一条 E 级生产业务链路;仅 DDM、output-manager
    color-control、wallpaper-color 仍停留在 I/P 层。

详细的基本覆盖情况阅读 tests/protocols/specifications/README.md

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @zorowk, your pull request is larger than the review limit of 150000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zorowk

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

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces a comprehensive protocol test framework plus multiple desktop-level protocol tests, refactors Treeland initialization into reusable helpers, and fixes several input, wallpaper, keyboard, screensaver, shortcut, and capture behaviors to support deterministic testing and production stability.

Sequence diagram for updated wallpaper ready and mapping behavior

sequenceDiagram
    participant Client
    participant WSurface
    participant WallpaperIface as TreelandWallpaperSurfaceInterfaceV1Private

    Client->>WSurface: commit(buffer)
    WSurface->>WallpaperIface: ready(Resource)

    alt WSurface.mapped or bufferSize not empty
        WallpaperIface->>WSurface: map()
        WallpaperIface--)Client: ready()
    else wait for commit
        WSurface->>WallpaperIface: commit(quint32)
        WallpaperIface->>WSurface: map()
        WallpaperIface--)Client: ready()
    end
Loading

File-Level Changes

Change Details Files
Stabilize keyboard state watcher by tracking per-seat keyboard device and reacting to keyboard changes.
  • Use WSeat::keyboard() instead of keyboardGroupKeyboard() when resolving the seat keyboard.
  • Track both the seat and its keyboard device in KeyboardConnection and reconnect modifiers when the keyboard changes.
  • Connect to WSeat::keyboardChanged and disconnect connections on seat destroy.
  • Update seat-added path to use the new keyboard() accessor.
src/modules/keyboard-state-notify/keyboardstatenotifymanagerinterfacev1.cpp
Harden TreelandInputManagerInterfaceV1 and add deterministic DeviceTypes for tests.
  • Guard all uses of wlr_seat_client against null clients in capability send/broadcast paths.
  • Add a std::function-based DeviceTypesProvider for testing to override backend discovery.
  • Short-circuit onInputAdded/onInputRemoved when a testing provider is active.
  • Expose setters/clearers for the testing provider in the public header.
src/modules/input-manager/inputmanagerinterfacev1.cpp
src/modules/input-manager/inputmanagerinterfacev1.h
Refactor Treeland startup into reusable preInit/postInit helpers and simplify main.
  • Introduce Treeland::InitOptions and preInit/postInit functions to encapsulate logging, QPA setup, and renderer initialization.
  • Remove direct qw_log and WRenderHelper calls from main, delegating them to treelandinit.cpp.
  • Keep QGuiApplication creation and application metadata in main while using the new helpers for environment setup.
src/main.cpp
src/core/treelandinit.cpp
src/core/treelandinit.h
src/CMakeLists.txt
Ensure wallpaper shell surfaces map correctly and emit ready semantics based on buffer content.
  • Add a markReady lambda that maps the wallpaper surface once it has a valid buffer size and then emits ready.
  • Treat either an already-mapped surface or a non-empty buffer as sufficient to mark ready immediately.
  • Otherwise connect to WSurface::commit with a single-shot connection to call markReady after the first commit.
src/modules/wallpaper/wallpapershellinterfacev1.cpp
Allow SurfaceWrapper geometry changes to bypass animation when animations are disabled.
  • Check Helper::instance()->noAnimation() at the start of startStateChangeAnimation.
  • If animations are disabled, synchronously resize, reposition (aligned to pixel grid), set the target state, and resize again instead of creating a geometry animation.
src/surface/surfacewrapper.cpp
Fix WSeat destruction ordering for internally created group keyboard device.
  • Detach and safeDelete the groupkeyboardDevice during WSeat::destroy while the seat and QPA registration are still valid.
  • Clear the internal pointer after scheduling deletion so WSeatPrivate destructor does not run against torn-down registration.
waylib/src/server/kernel/wseat.cpp
Expose WindowPicker programmatic selection and wire DDEShell PickerCreated instead of requestPickWindow.
  • Add WindowPicker::selectWindow(WSurfaceItem *) API and implement mousePressEvent via this helper.
  • Make CaptureSourceSelector expose its hovered item and selection region via a friend test-access class.
  • Change Helper to connect to DDEShellManagerInterfaceV1::PickerCreated instead of requestPickWindow and handle window picker creation consistently.
src/core/windowpicker.cpp
src/core/windowpicker.h
src/modules/capture/capture.h
src/seat/helper.cpp
Make screensaver idle-inhibit safe when Helper is not yet constructed.
  • Guard calls to Helper::instance()->updateIdleInhibitor() behind a null check before invoking.
  • Apply the guard in both inhibit and uninhibit paths to avoid crashes during early initialization or teardown.
src/modules/screensaver/screensaverinterfacev1.cpp
Add a rich protocol test framework and many protocol-specific C clients and fixtures.
  • Introduce protocol-test-main and protocol-test-desktop-main runners to host headless WServer and full Treeland desktops for tests.
  • Provide protocol-test-client/server and protocol-test-xdg-client utilities for registry binding, xdg_toplevel management, and server-side callbacks.
  • Add reusable fixtures for desktop integration and rendered output (texture readback).
  • Implement C clients plus C++ setup fixtures for multiple treeland protocols including personalization, foreign-toplevel, virtual-output, dde-shell, keyboard-state-notify, capture, app-id-resolver, shortcut-manager, screensaver, window-management, wallpaper-manager/shell/wallpaper-color, input-manager, ddm, wine-window-management/state, and prelaunch-splash.
  • Wire all tests in tests/CMakeLists.txt and add a ProtocolTest.cmake helper to generate scanner code and targets.
tests/CMakeLists.txt
tests/protocols/framework/protocol-test-main.cpp
tests/protocols/framework/protocol-test-desktop-main.cpp
tests/protocols/framework/protocol-test-client.*
tests/protocols/framework/protocol-test-server.*
tests/protocols/framework/protocol-test-xdg-client.*
tests/protocols/framework/ProtocolTest.cmake
tests/protocols/**

Possibly linked issues

  • #[Bug]: seat_client_from_keyboard_resource: 假设 ‘wl_resource_instance_of(resource, &wl_keyboard_interface, &keyboard_impl)’ 失败。: Crash stems from seat keyboard resource misuse; PR switches modules to WSeat::keyboard(), cleans up groupkeyboardDevice on destroy, and guards null seatClient, directly addressing the failing wl_keyboard assertion.

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

@zorowk
zorowk marked this pull request as draft August 12, 2026 07:30
@zorowk
zorowk force-pushed the wip_protocol_tests branch 8 times, most recently from fcf38f1 to cfc759f Compare August 13, 2026 09:55
@zorowk
zorowk marked this pull request as ready for review August 13, 2026 10:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @zorowk, your pull request is larger than the review limit of 150000 diff characters

@zorowk
zorowk force-pushed the wip_protocol_tests branch 3 times, most recently from fcb8884 to 71260fc Compare August 13, 2026 11:59
zorowk added 13 commits August 13, 2026 20:26
…ramework

shared compositor initialization and the protocol-test framework;

- Move shared QPA and minimal test-server initialization into libtreeland.
- Provide an isolated headless protocol-test fixture with generated C Wayland clients and a DDE
  shell example organized as named cases.

Make future protocol coverage additions consistent while preserving a real C Wayland client
boundary.
Add client-side protocol test coverage for Treeland private Wayland interfaces.

- Register 14 new protocol-test targets in the protocol test build.
- Add C clients, setup fixtures, and test headers for app-id, capture, output, wallpaper,
  window-management, and related private protocols.

Exercise protocol requests, events, and error behavior against the headless server fixture.
Strengthen protocol tests with real output setup and observable server-side effects.

- Create a headless output for DDE overlap checks and assert DDE shell-surface state changes.
- Bind the wallpaper notifier client interface and verify add/remove broadcasts.

Ensure these tests validate protocol behavior instead of treating missing dependencies or manually
omitted interfaces as successful coverage.
Protocol tests need real headless outputs and mapped xdg toplevels for server-side surface
semantics.

- Share headless output and wl_shm fixture support across protocol tests
- Generate scanner-based xdg-shell client helpers on demand
- Require the foreign toplevel test to use a configured, buffer-mapped xdg window

Avoid transport-only coverage where output or window-dependent protocol paths silently no-op.

Only protocol test framework and affected test fixtures; no production protocol behavior.
The working tree contains only the desktop protocol fixture and its consumers.

- add production desktop fixture
- validate foreign handles against SurfaceWrapper
- add DDE SurfaceWrapper propagation test

Protocol tests must observe production business effects.

All current worktree changes are protocol-test framework and test sources.
Desktop protocol tests run against the production Helper and its full registry.

- add a mapped xdg personalization integration test
- make the client registry retain stable names for all production globals
- synchronize desktop clients with a headless output and fix foreign test encapsulation

Verify protocol requests affect real compositor window state without relying on private setters.

Only protocol test framework and protocol test sources are included.
The protocol suite needs observable production outcomes for desktop-dependent private protocols.

- Add desktop tests for screensaver idle inhibition, shortcut activation, and show-desktop
  visibility.
- Generate and link extra upstream client protocols for desktop tests.
- Initialize shortcut state for the already-active global session.

Exercise real mapped windows, input, idle state, and workspace visibility instead of protocol-local
state alone.

Exclude tests/protocols/specifications and do not add rendered capture or wallpaper coverage.
Protocol tests need a reusable production scene with a client buffer whose pixels can be observed.

- Add a desktop rendered-output fixture that maps a solid-colour xdg client buffer.
- Read the production surface texture through WTextureCapturer and assert its pixels.
- Extend the shared xdg test client to map solid ARGB buffers directly after the first configure.

Provide a verified rendering prerequisite for capture and output-facing protocol tests.

Exclude tests/protocols/specifications and do not yet implement capture selector or frame copy
coverage.
Private Wayland protocol tests need to observe production desktop behavior rather than only protocol
resources and manually emitted events.

- add capture, wallpaper, and virtual-output desktop protocol clients
- drive desktop fixture readiness from output and DConfig production state
- map buffered wallpaper surfaces before emitting ready
- expose a test-only capture selector bridge for the production selection path

The tests now exercise mapped surfaces, rendered capture pixels, wallpaper binding, and output
copy/restore semantics through production objects.

Commit only the listed source and test files; exclude tests/protocols/specifications and all other
changes.
Desktop protocol integration coverage now exercises prelaunch splash, app-id resolution, DDE
lockscreen, picker, and multitask flows.

- add production desktop tests for splash, app-id resolver, DDE lockscreen, picker, and multitask
  behavior
- add pending-xdg test client support for resolver sequencing
- fix DDE picker setup to subscribe before the first pick request and centralize window selection

Ensure protocol requests produce observable compositor business results through real desktop
objects.
Adds desktop integration tests for the input manager, keyboard state notification, Wine window
state, and Wine window management private protocols.

- register four private protocol integration test targets
- exercise input manager and Wine window protocol request and event paths
- exercise keyboard state notification with a virtual keyboard and track runtime keyboard changes

Extend protocol coverage beyond resource creation to observable compositor behavior.
扩展输入、桌面、foreign-toplevel 与个性化协议的真实生产链路测试,并补充桌面测试运行环境支持。

- 增加 input-manager 的 settings/apply、capability 与可选 uinput 热插拔测试
- 补充 foreign-toplevel 对真实窗口状态、焦点和图标区域的断言
- 补齐 personalization 配置回读与测试后的状态恢复
- 支持 desktop fixture 的预检、跳过和可覆写 backend,并修复 WSeat 分组键盘销毁顺序

让协议请求覆盖对应可观察的生产状态,同时避免测试遗留配置或依赖不稳定的设备环境。

不包含协议规范目录和生成的构建产物。
Desktop protocol coverage must observe existing compositor lifecycles without introducing
production-only test hooks or changing ownership of keyboard, idle, and wallpaper state.

- remove the input-manager capability provider and reduce the default no-device test to manager
  binding
- restore keyboard-state notification to keyboard-group semantics and remove virtual-keyboard
  coverage from the default target
- run the screensaver protocol fixture under Helper so inhibit requests update the real idle
  notifier
- remove wallpaper-shell mapping from ready while retaining its committed-buffer and next-commit
  readiness timing
- narrow wallpaper desktop assertions to manager, shell surface, output, and workspace association

Keep protocol assertions aligned with real desktop and xdg-shell lifecycles while avoiding
test-driven production behavior.

Amend only the currently staged 16 files; leave all unstaged and untracked changes untouched.
zorowk added 3 commits August 13, 2026 20:26
protocol-tests

- add the protocol-test specification index and per-protocol contracts
- record fixture boundaries, observable production results, and coverage gaps

keep protocol coverage expectations reviewable alongside the test suite
desktop protocol test runner

- load build-tree lockscreen and multitask plugins through CTest-provided fixture configuration
- wait for user configuration before the wallpaper desktop client updates production wallpaper state
- document fixture readiness and plugin-loading boundaries

ensure desktop assertions observe the required production plugin and wallpaper configuration state
protocol test source headers

- add the 2026 UnionTech copyright notice to protocol fixture, framework, and test client sources
- add the same notice to treeland initialization sources

make ownership information consistent across the protocol test implementation
@zorowk
zorowk force-pushed the wip_protocol_tests branch from 71260fc to 834a359 Compare August 13, 2026 12:27
C++ protocol-test sources include wlr_all.h for the required extern C linkage.

- Add wlr/types/wlr_shm.h to the unified wlroots C++ header.

Make wlr_shm_create visible with C linkage to C++ callers using the unified header.
@zorowk
zorowk force-pushed the wip_protocol_tests branch from 834a359 to 8175da9 Compare August 13, 2026 13:06
@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.18
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1286

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants