feat: add unit tests for core modules and protocol integration - #1211
feat: add unit tests for core modules and protocol integration#1211Groveer wants to merge 3 commits into
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's GuideAdds a suite of unit tests for core components and Wayland protocol integration, with small production changes to make components testable (backlight I/O, greeter proxy, lockscreen, output geometry helpers, XSettings/XResource), plus a null-guard fix in SurfaceContainer and a few test/greeter robustness fixes. Sequence diagram for GreeterProxy.lock with testModesequenceDiagram
actor Tester
participant GreeterProxy
participant Helper
participant SessionManager
participant Session
Tester->>GreeterProxy: lock()
alt [m_testMode]
GreeterProxy->>GreeterProxy: setLock(true)
GreeterProxy-->>Tester: return
else [!m_testMode]
GreeterProxy->>Helper: instance()
Helper-->>GreeterProxy: Helper*
GreeterProxy->>SessionManager: sessionManager()
SessionManager-->>GreeterProxy: SessionManager*
GreeterProxy->>SessionManager: activeSession()
SessionManager-->>GreeterProxy: QSharedPointer<Session>
GreeterProxy-->>Tester: return
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
c5ed18d to
02bbcdc
Compare
02bbcdc to
7f328e4
Compare
|
TAG Bot TAG: 0.8.16 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Groveer The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
7eaa523 to
ef054c7
Compare
Consolidates the unit-test work from #1046 and #1093 into a single commit. Adds testability hooks to core modules and a suite of unit tests, plus the production bugfixes uncovered while writing the tests. Testability support (production code, minimal / non-behavioral changes): - CMakePresets: add excludeLabel for testability - lockscreen: add primaryOutputName() getter - output: make constrainToValidArea public static - xresource: add splitXResourceLine public static - xsettings: add testMode constructor and expose protected methods - backlight: add basePath parameter for test injection - greeterproxy: add testMode constructor, virtual methods and null guards - rootsurfacecontainer / shellhandler / helper / workspace / surfacewrapper: add TODO(unit-test) markers New unit tests (12 executables): - test_backlight, test_gestures, test_greeterproxy, test_lockscreen, test_output_scale, test_protocol_integration, test_shortcutcontroller, test_togglablegesture, test_wallpaperconfig, test_windowconfigstore, test_xresource, test_xsettings Fixes: - fix(surface): guard null parentContainer in ensureQmlContext() -- constructing SurfaceContainer with a null parent dereferenced a null pointer from parentContainer(); add an early return. - fix(greeter): switchUser() is a Qt signal and cannot be virtual (MOC generates non-virtual implementations); remove `virtual` and observe the signal with QSignalSpy in the mock instead. - fix(test): pass a non-null parent SurfaceContainer (QQuickItem ctor path) to LockScreen to avoid triggering ensureQmlContext() with a null parent. - fix(test): adapt test_wallpaperconfig to the current WallpaperWorkspaceConfig / WallpaperOutputConfig (the `enable` field was removed upstream since the tests were authored) and value-initialize aggregates where members are left unset, silencing -Werror=maybe-uninitialized on the Deepin deb build. - fix(greeter): guard null m_socket in isConnected() — the testMode constructor does not create a socket, so isConnected() would dereference a null pointer; add an early return (same fix as the backup branch had). - fix(test): drop test_outputconfigstate — OutputConfigState was removed from the codebase on master; the test is obsolete. Ref: WM-29 Supersedes #1046 and #1093.
unregisterSwipeGesture/unregisterHoldGesture previously called deleteLater() on the gesture object. This is dangerous because: 1. The QObject::destroyed signal handler also calls unregister, creating a circular dependency. 2. Callers may still reference the gesture after unregister. Add removeSwipeGesture/removeHoldGesture that call unregister then deleteLater, and update InputDevice callers to use the new methods. WM-29
WallpaperWorkspaceConfig and WallpaperOutputConfig had uninitialized members (workspaceId, desktopWallpapertype, lockScreenWallpapertype) which led to undefined behavior when default-constructed, triggering -Werror=maybe-uninitialized in the Deepin deb build. Add default member initializers. Note: the 'enable' field referenced in the original PR #1092 was removed from the codebase on master, so it is not included here. Ref: WM-29. Supersedes #1092.
7846c0b to
ac3ff34
Compare
|
TAG Bot New tag: 0.8.17 |
|
TAG Bot New tag: 0.8.18 |
Summary
Consolidates the unit-test work from #1046 (
feat/add-unit-tests) and #1093 (refactor/greeter-virtual-methods) into a single, single-commit PR, per the WM-29 request to merge the two PRs and minimize commit count. The two branches shared one base commit and diverged only in a null-guard fix; this PR is their union squashed into one commit on top of the current base.What's included
Testability support (production code, minimal / non-behavioral):
primaryOutputName()getterconstrainToValidAreamade public staticsplitXResourceLinepublic staticbasePathparameter for test injectionTODO(unit-test)markersNew unit tests (13 executables): test_backlight, test_gestures, test_greeterproxy, test_lockscreen, test_output_scale, test_outputconfigstate, test_protocol_integration, test_shortcutcontroller, test_togglablegesture, test_wallpaperconfig, test_windowconfigstore, test_xresource, test_xsettings
Fixes:
fix(surface): guard nullparentContainer()inensureQmlContext()(was a null-pointer deref / SEGFAULT)fix(greeter):switchUser()is a Qt signal and cannot bevirtual(MOC) — removedvirtual, mock usesQSignalSpyfix(test): pass a non-null parentSurfaceContainertoLockScreenfix(test): value-initializeWallpaperWorkspaceConfigintest_wallpaperconfig(-Werror=maybe-uninitializedon Deepin)Base branch
Targets
master-backup-20260717— the same staging base the original PRs used (a stable snapshot whilemasterchurns) — to preserve the previously-green CI. The base has since advanced by one commit (fix(greeter): guard null socket in isConnected+test_effect_glass), which produced a single additive conflict intests/CMakeLists.txt, resolved by keeping bothtest_effect_glassand the new test entries. The greeterproxy changes combined cleanly.If you'd prefer this retargeted at
masterto land directly, say the word — it only needs the sametests/CMakeLists.txtresolution (plus a CI re-run).Review status
The underlying changes were already code-reviewed and CI-green on the original PRs (Arch Linux + Deepin crimson). This PR re-runs CI on the squashed commit / current base.
Ref: WM-29 (Multica issue c885e061-87b5-4415-8284-47bc31e0efe0)
Supersedes #1046 and #1093.
Summary by Sourcery
Add extensive unit test coverage for core compositor modules and Wayland protocol integration, along with minor production changes to enable testability and harden backlight handling.
New Features:
Bug Fixes:
Enhancements:
Tests: