Skip to content

Wip tests protocol - #1297

Open
zorowk wants to merge 14 commits into
linuxdeepin:masterfrom
zorowk:wip_tests
Open

Wip tests protocol#1297
zorowk wants to merge 14 commits into
linuxdeepin:masterfrom
zorowk:wip_tests

Conversation

@zorowk

@zorowk zorowk commented Aug 18, 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

Summary by Sourcery

Establish a production-oriented Wayland protocol testing framework and expand coverage across Treeland’s protocol, desktop integration, and rendering paths.

New Features:

  • Add a comprehensive Wayland protocol test suite with pure-C clients, protocol and desktop integration fixtures, rendered-output coverage, and production-state assertions across Treeland modules.
  • Add optional uinput-based input integration testing and reusable xdg-shell, server-callback, headless-output, and pixel-readback test infrastructure.

Bug Fixes:

  • Fix compositor initialization ordering and make plugin loading overridable for isolated protocol test fixtures.
  • Support software-renderer texture readback and correctly handle wallpaper readiness for surfaces that already have committed buffers.
  • Correct Wayland output and Xwayland API handle usage and ensure window picker and shortcut session connections are initialized through the production lifecycle.

Enhancements:

  • Expose reusable surface and window selection entry points and route capture, picker, and QML button behavior through the updated production APIs.
  • Document protocol test architecture, coverage levels, execution guidance, and remaining XML/request/event coverage boundaries.

Build:

  • Register the protocols test suite and generate scanner-based client bindings through shared CMake helpers.
  • Add dependencies and environment setup for headless, desktop, rendered-output, and optional uinput protocol tests.

CI:

  • Install desktop fixture dependencies and create the compositor-owned CI user required by the full integration test path.

Documentation:

  • Add protocol testing architecture, usage, specification, coverage, and fixture documentation.

Tests:

  • Add protocol and desktop integration tests covering personalization, capture, DDE shell, foreign toplevels, virtual outputs, wallpapers, shortcuts, screensaver, window management, Wine integration, app ID resolution, and related modules.

@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 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduce a reusable Treeland initialization helper for both production and protocol tests, add a comprehensive Wayland protocol testing framework with many C-based client tests and desktop/headless fixtures, and make several small runtime fixes around capture, wallpaper, window picking, shortcut/session handling, and texture capture paths.

Sequence diagram for WTextureCapturer::doGrabToImage with QRhiTexture and QSGPlainTexture

sequenceDiagram
    participant Capturer as WTextureCapturer
    participant Provider as WTextureProvider
    participant Texture as QSGTexture
    participant Rhi as QRhi

    Capturer->>Provider: wTextureProvider()
    Provider-->>Capturer: Texture
    alt texture has rhiTexture
        Capturer->>Texture: rhiTexture()
        Texture-->>Capturer: QRhiTexture
        Capturer->>Rhi: beginOffscreenFrame()
        Capturer->>Rhi: nextResourceUpdateBatch()
        Capturer->>Rhi: endOffscreenFrame()
    else texture is QSGPlainTexture
        Capturer->>Texture: image()
        Texture-->>Capturer: QImage
        Capturer-->>Capturer: imgPromise.addResult(copy)
    else invalid texture
        Capturer-->>Capturer: imgPromise.setException()
    end
Loading

File-Level Changes

Change Details Files
Refactor Treeland startup into reusable preInit/postInit helpers and update main entrypoint to use them instead of manual QPA/app setup.
  • Add Treeland::InitOptions, preInit, postInit, and initTestServer to encapsulate QPA initialization, headless backend selection, and wl_compositor setup.
  • Update src/main.cpp to call Treeland::preInit with a platform theme factory and Treeland::postInit, removing direct WServer::initializeQPA/QGuiApplication attribute setup and WRenderHelper::setupRendererBackend call.
  • Adjust protocol test desktop main to reuse Treeland::preInit/postInit for headless compositor startup instead of duplicating initialization logic.
src/main.cpp
src/core/treelandinit.cpp
src/core/treelandinit.h
tests/protocols/framework/protocol-test-desktop-main.cpp
tests/protocols/framework/protocol-test-main.cpp
Improve capture and window picking behavior by reusing selection logic and supporting software-rendered textures.
  • Add CaptureSourceSelector::selectSurface to encapsulate selection of a WSurfaceItemContent and reuse it from mouseReleaseEvent instead of duplicating logic.
  • Add software-backend support in WTextureCapturer by detecting QSGPlainTexture when no QRhiTexture is present and reading its QImage to fulfill capture requests.
  • Expose WindowPicker::selectWindow and use it from mousePressEvent to centralize window selection/pick emission.
src/modules/capture/capture.cpp
src/modules/capture/capture.h
waylib/src/server/qtquick/wtextureproviderprovider.cpp
src/core/windowpicker.cpp
src/core/windowpicker.h
Tighten wallpaper readiness and lockscreen/multitaskview QML behavior.
  • Treat an unmapped wallpaper surface with a non-empty buffer size as ready, and refactor ready signaling into a reusable lambda to avoid duplication.
  • Fix QML button text color bindings by storing textColor as a D.Palette property and binding palette.buttonText instead of a non-existent textColor property in ShutdownButton and multitaskview/workspace selection lists.
  • Ensure treeland wallpaper shell test can detect ready/fail events more reliably through updated readiness semantics.
src/modules/wallpaper/wallpapershellinterfacev1.cpp
src/plugins/lockscreen/qml/ShutdownButton.qml
src/plugins/multitaskview/qml/WindowSelectionGrid.qml
src/plugins/multitaskview/qml/WorkspaceSelectionList.qml
Adjust Helper wiring for DDE shell and shortcut manager to match updated signals and ensure session state is propagated.
  • Update Helper to connect to DDEShellManagerInterfaceV1::PickerCreated instead of requestPickWindow when wiring window picker handling.
  • Call ShortcutManagerV2::onSessionChanged immediately after connecting the SessionChanged signal so the initial session state is applied without waiting for a change event.
src/seat/helper.cpp
Fix low-level waylib protocol integrations by using correct wlroots handles for xdg-output and XWayland workarea APIs and include missing wlroots shm header.
  • Use wlr_output_layout_get with the layout handle and WOutput::handle() instead of nested handle()->handle() pointers in WXdgOutputManager::outputGeometry.
  • Pass WXWayland::handle() directly to wlr_xwayland_set_workareas instead of handle()->handle().
  • Include <wlr/types/wlr_shm.h> in the wlroots umbrella header to support shm-related tests.
waylib/src/server/protocols/wxdgoutput.cpp
waylib/src/server/protocols/wxwayland.cpp
waylib/src/server/kernel/wlr_all.h
Extend CI pipeline to support protocol tests by installing additional runtime dependencies and creating the system 'dde' user in the treeland-deepin build workflow.
  • Install dde-dconfig-daemon, libdtkdata, and required Qt6 QML modules before building in GitHub Actions.
  • Ensure a system 'dde' user with home directory /var/lib/dde exists so the full desktop fixture can follow Treeland's normal global-session path in CI.
.github/workflows/treeland-deepin-build.yml
Introduce a generic Wayland protocol test framework with headless and desktop fixtures, plus extensive C-based clients for treeland-specific protocols.
  • Add protocol-test client/server framework (C and C++) with a headless WServer runner, desktop runner that boots full Treeland headless, registry helpers, xdg-shell support, and utilities for creating outputs and shm buffers.
  • Add ProtocolTest.cmake helpers to define protocol tests and desktop integration tests, wiring in wayland-scanner, test labels, and environment variables for headless wlroots and DConfig data.
  • Implement numerous pure-C protocol tests for treeland-* protocols (personalization, foreign-toplevel, virtual-output, DDE shell, capture, wallpaper manager/shell/color, app-id-resolver, prelaunch-splash, shortcut manager, screensaver, window management, wine window management/state, keyboard-state-notify, input-manager, output-manager, etc.), plus rendered-output and desktop integration fixtures.
  • Integrate tests into the build by adding add_subdirectory(protocols) in tests/CMakeLists.txt and linking libtreeland and appropriate private modules (e.g., capture) into test binaries.
tests/CMakeLists.txt
tests/protocols/CMakeLists.txt
tests/protocols/framework/ProtocolTest.cmake
tests/protocols/framework/protocol-test-main.cpp
tests/protocols/framework/protocol-test-desktop-main.cpp
tests/protocols/framework/protocol-test-client.c
tests/protocols/framework/protocol-test-client.h
tests/protocols/framework/protocol-test-server.cpp
tests/protocols/framework/protocol-test-server.h
tests/protocols/framework/protocol-test-xdg-client.c
tests/protocols/framework/protocol-test-xdg-client.h
tests/protocols/**

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

@Groveer

Groveer commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

commit 信息不符合规范

zorowk added 14 commits August 19, 2026 14:02
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.

PMS: TASK-393829
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.

test(protocols): strengthen DDE and wallpaper shell coverage

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.

PMS: TASK-393829
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.

PMS: TASK-393829
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.

test(protocols): validate personalization desktop effects

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.

test(protocols): add desktop semantic coverage

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.

PMS: TASK-393829
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.

PMS: TASK-393829
Expose selection operations for WindowPicker and CaptureSourceSelector so callers can select a
known surface without synthesizing pointer input.

Connect the DDE shell PickerCreated signal to Helper, recognize wallpaper surfaces with committed
buffers as ready, and update screensaver idle inhibitors through the initialized Helper.

These changes make production state transitions explicit and let protocol fixtures use them
deterministically.

PMS: TASK-393829
Read QSGPlainTexture image data when the software renderer provides no QRhi texture, allowing headless pixman rendering to produce capture pixels. Include the wl_shm API required by the protocol test server.

PMS: TASK-393829
Skip Treeland's automatic plugin discovery when a desktop protocol fixture supplies its build-tree plugin path, so the fixture can load and initialize those plugins explicitly.

PMS: TASK-393829
Set button text colors through each control's palette, matching the Qt Quick Controls API used by the lockscreen and multitask plugins.

PMS: TASK-393829
Exercise private and desktop Wayland protocols through production integration paths instead of only
validating resources and manually emitted events.

Add headless desktop clients and fixtures for app-id resolution, capture, DDE shell flows, input and
keyboard state, personalization, virtual output, wallpaper, Wine windows, and foreign toplevels.
Extend the shared XDG client and desktop runner to wait for production readiness and assert mapped
surfaces, workspace and output state, capture pixels, and protocol events.

Make desktop fixtures self-contained in headless CI by copying DConfig descriptor data and running
disposable D-Bus, Accounts, and DConfig services. Load build-tree plugins explicitly, wait for
output and configuration readiness, and capture QSGPlainTexture pixels when Qt uses its software
backend. Keep unstable timing- and device-dependent scenarios out of the default test path.

PMS: TASK-393829
Pass the native Wayland handles expected by the current wlroots APIs when resolving output layout geometry and setting XWayland workareas.

PMS: TASK-393829
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

PMS: TASK-393829
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

PMS: TASK-393829
Install the DConfig daemon and required QML modules, and create the dde service account required by Treeland's global-session path in the minimal CI image.

PMS: TASK-393829
@zorowk

zorowk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

commit 信息不符合规范
已经修复

Comment thread src/core/treeland.cpp
QDBusConnection::sessionBus().registerService("org.deepin.Compositor1");
QDBusConnection::sessionBus().registerObject("/org/deepin/Compositor1", this);

if (qEnvironmentVariableIsEmpty("TREELAND_TEST_PLUGINS_PATH")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个环境变量有啥用

@zorowk zorowk Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

开始是为了在ci下面测试程序能够加载到插件,后来发现插件会加载两遍就在这里写了个判断。现在不需要了 会回撤这个地方 插件还是统一由treeland核心加载 测试客户端不在参与这个事情

Comment thread src/core/treelandinit.cpp
void preInit(const InitOptions &opts)
{
if (opts.headless) {
const auto testBackends = qgetenv("TREELAND_TEST_WLR_BACKENDS");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个环节变量有啥用呀,如果有需要指定backend,直接用 WLR_BACKENDS 不行吗,这里可以判断没有指定 WLR_BACKENDS时才使用 opts.headless。

Comment thread src/core/treelandinit.h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#pragma once 去哪了

Comment thread src/main.cpp
return static_cast<QPlatformTheme *>(new QDeepinTheme());
Treeland::preInit(Treeland::InitOptions{
.createPlatformTheme = [](const QString &) {
return static_cast<QPlatformTheme *>(new QDeepinTheme());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个为啥不直接在treeland.cpp里创建和设置

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.

4 participants