Skip to content

test: 补充 dde-launchpad 单元测试 - #813

Open
MyLeeJiEun wants to merge 2 commits into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde/launchpad-tests
Open

MyLeeJiEun wants to merge 2 commits into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde/launchpad-tests

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

补充 dde-launchpad 单元测试

关联 Multica 任务: DDE-109 (补充 dde-launchpad 项目测试代码)

变更内容

  • 新增 14 个 Qt6 单元测试文件,覆盖 src/models 和 src/utils 核心模块
  • 扩展已有的 itemspage 和 searchfilter 代理模型测试
  • 更新 tests/CMakeLists.txt,注册全部 15 个测试 target 并启用 gcov 覆盖率编译选项
  • 共 15 个文件变更,2903 行新增

测试与覆盖率

  • 15 个测试 target 全部编译通过,185 条用例全部通过(0 失败)
  • 覆盖率(过滤生成代码后):行 72.6% / 函数 88.7%(达标),分支 41.7%(参考项)
  • 覆盖率报告详见 Multica DDE-109 附件

验证方式

cmake -B build -DBUILD_TESTING=ON
cmake --build build
ctest --test-dir build --output-on-failure

Summary by Sourcery

Expand dde-launchpad’s automated Qt6 test coverage and provide an integrated CTest coverage workflow for its core models and utilities.

Enhancements:

  • Expand Qt6 unit-test coverage across core model and utility modules, including app arrangement, filtering, sorting, favorites, categories, icons, and blurhash handling.
  • Extend existing ItemsPage and search/filter proxy model tests with broader behavior and edge-case coverage.

Build:

  • Rename the test build option to BUILD_TESTING and register 15 test targets through the updated test configuration.
  • Add optional test coverage instrumentation and a coverage-report target for models, utilities, and GIO utilities.

Tests:

  • Add 14 new Qt6 unit-test suites covering core src/models and src/utils functionality.
  • Configure all tests to run through CTest with coverage data collection and filtered HTML report generation.

@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.

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.

@sourcery-ai

sourcery-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR substantially expands dde-launchpad’s Qt6 unit-test coverage across core models and utilities, integrates 15 CTest targets through the BUILD_TESTING option, and instruments test-linked object libraries to support an aggregate lcov coverage workflow.

Flow diagram for Qt6 test and coverage execution

flowchart LR
    Configure["cmake -B build -DBUILD_TESTING=ON"] --> Build["cmake --build build"]
    Build --> CTest["ctest --test-dir build --output-on-failure"]
    CTest --> Coverage["lcov filtered coverage report"]
Loading

File-Level Changes

Change Details Files
Expanded the Qt6 unit-test suite to cover core models and utilities, while extending existing proxy-model tests.
  • Added focused tests for sorting/filtering proxies, pagination and arrangement, favorites and usage ordering, category mapping, blurhash encoding/decoding, and icon utilities.
  • Extended ItemsPage, ItemsPage-related, and categorized search-filter coverage with edge cases, signal behavior, ordering, and state transitions.
  • Used controlled Qt models, singleton setup/cleanup, temporary application data cleanup, and role/property configuration to exercise production behavior in isolation.
tests/blurhashtest.cpp
tests/categoryutilstest.cpp
tests/countlimitproxymodeltest.cpp
tests/favoritedproxymodeltest.cpp
tests/freesortproxymodeltest.cpp
tests/frequentlyusedproxymodeltest.cpp
tests/iconutilstest.cpp
tests/itemarrangementproxymodeltest.cpp
tests/itemspagemodeltest.cpp
tests/itemspagetest.cpp
tests/multipagesortfilterproxymodeltest.cpp
tests/recentlyinstalledproxymodeltest.cpp
tests/searchfilterproxymodeltest.cpp
tests/sortproxymodeltest.cpp
Reworked test build integration and coverage instrumentation around directly linked tested-source object libraries.
  • Renamed the test option from BUILD_TEST to BUILD_TESTING.
  • Compiled models, utilities, and gio utilities as test OBJECT libraries and linked them into every test executable alongside launchpadcommon and required Qt/DTK dependencies.
  • Registered 15 test targets with CTest and enabled gcov instrumentation by default for test-directory targets.
CMakeLists.txt
tests/CMakeLists.txt
Added an aggregate coverage workflow for executing the suite and producing filtered lcov HTML reports.
  • Added a coverage custom target that builds dependencies, runs all CTest tests, captures gcov data, filters reports to project model/utility sources, and generates branch-aware HTML output when lcov/genhtml are available.
tests/CMakeLists.txt

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

@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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="CMakeLists.txt" line_range="9" />
<code_context>
 project(dde-launchpad VERSION 0.7.0)

-option(BUILD_TEST "Whether or not to build the tests" OFF)
+option(BUILD_TESTING "Whether or not to build the tests" OFF)
 option(CMAKE_EXPORT_COMPILE_COMMANDS "clangd support" ON)

</code_context>
<issue_to_address>
**issue (broader_impact):** Existing invocations that configure the project with `-DBUILD_TEST=ON` no longer build or register any tests because the old option is silently ignored and the new condition checks only `BUILD_TESTING`. This contradicts the documented verification command in the change description and breaks downstream CI or packaging scripts that still use the old option.

**Triggers:** When a caller continues to pass the previous `BUILD_TEST` option.

**Suggested fix:** Preserve a compatibility alias from `BUILD_TEST` to `BUILD_TESTING`, or update every supported build invocation and fail clearly when the deprecated option is used.

```suggestion
option(BUILD_TESTING "Whether or not to build the tests" OFF)
option(BUILD_TEST "Deprecated alias for BUILD_TESTING" OFF)
if(BUILD_TEST)
    set(BUILD_TESTING ON)
endif()
```
</issue_to_address>

### Comment 2
<location path="tests/CMakeLists.txt" line_range="123-143" />
<code_context>
+find_program(GENHTML_BIN genhtml)
+set(_run_test_coverage "")
+if(LCOV_BIN AND GENHTML_BIN)
+    set(_run_test_coverage
+        COMMAND ${LCOV_BIN} --capture --directory ${CMAKE_BINARY_DIR}
+                --rc lcov_branch_coverage=1 --output-file ${CMAKE_BINARY_DIR}/coverage.info
+        COMMAND ${LCOV_BIN} --extract ${CMAKE_BINARY_DIR}/coverage.info
+                --rc lcov_branch_coverage=1
+                "${CMAKE_SOURCE_DIR}/src/models/*"
+                "${CMAKE_SOURCE_DIR}/src/utils/*"
+                "${CMAKE_SOURCE_DIR}/src/gioutils/*"
+                --output-file ${CMAKE_BINARY_DIR}/coverage_filtered.info
+        COMMAND ${GENHTML_BIN} ${CMAKE_BINARY_DIR}/coverage_filtered.info
+                --branch-coverage --output-directory ${CMAKE_BINARY_DIR}/coverage_report
+    )
+endif()
+add_custom_target(coverage
</code_context>
<issue_to_address>
**issue (bug_risk):** The `coverage` target succeeds after running the tests without generating any report when either `lcov` or `genhtml` is unavailable, because `_run_test_coverage` is left empty and no failure or warning is emitted. Consumers therefore receive a green coverage build with the promised `coverage_report/index.html` missing.

**Triggers:** When lcov or genhtml is not installed on the build host.

**Suggested fix:** Make the coverage target fail with a clear dependency error, or explicitly report that coverage generation was skipped instead of presenting the target as successful.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread CMakeLists.txt
Comment thread tests/CMakeLists.txt
Comment on lines +123 to 143
set(_run_test_coverage
COMMAND ${LCOV_BIN} --capture --directory ${CMAKE_BINARY_DIR}
--rc lcov_branch_coverage=1 --output-file ${CMAKE_BINARY_DIR}/coverage.info
COMMAND ${LCOV_BIN} --extract ${CMAKE_BINARY_DIR}/coverage.info
--rc lcov_branch_coverage=1
"${CMAKE_SOURCE_DIR}/src/models/*"
"${CMAKE_SOURCE_DIR}/src/utils/*"
"${CMAKE_SOURCE_DIR}/src/gioutils/*"
--output-file ${CMAKE_BINARY_DIR}/coverage_filtered.info
COMMAND ${GENHTML_BIN} ${CMAKE_BINARY_DIR}/coverage_filtered.info
--branch-coverage --output-directory ${CMAKE_BINARY_DIR}/coverage_report
)
endif()
add_custom_target(coverage
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
${_run_test_coverage}
DEPENDS ${LAUNCHPAD_TEST_TARGETS}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Run all tests and generate coverage report"
VERBATIM
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The coverage target succeeds after running the tests without generating any report when either lcov or genhtml is unavailable, because _run_test_coverage is left empty and no failure or warning is emitted. Consumers therefore receive a green coverage build with the promised coverage_report/index.html missing.

Triggers: When lcov or genhtml is not installed on the build host.

Suggested fix: Make the coverage target fail with a clear dependency error, or explicitly report that coverage generation was skipped instead of presenting the target as successful.

@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from ddcced3 to 43f1b2a Compare September 15, 2026 08:14
Comment thread tests/categoryutilstest.cpp Outdated
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 43f1b2a to 738b51c Compare September 17, 2026 03:43
@MyLeeJiEun
MyLeeJiEun requested a review from BLumia September 17, 2026 03:49
Comment thread tests/blurhashtest.cpp Outdated
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 738b51c to 9f56913 Compare September 17, 2026 05:24
@18202781743

Copy link
Copy Markdown
Contributor

ci没过,

@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 9f56913 to 14f5896 Compare September 17, 2026 07:00
@MyLeeJiEun

Copy link
Copy Markdown
Contributor Author

ci没过,
已修改

1. Add 14 Qt6 unit test files covering models and utils modules
2. Expand existing itemspage and searchfilter proxy model tests
3. Update CMakeLists.txt to register new targets with gcov coverage
4. Achieve 72.0% filtered line coverage and 86.1% function coverage

Influence:
1. Build with cmake -DBUILD_TEST=ON and run all 15 test targets
2. Verify 185 test cases pass with zero failures
3. Check gcov coverage report for src/models and src/utils
4. Validate test isolation with no false-green cases

test: 补充 dde-launchpad 单元测试 185 用例

1. 新增 14 个 Qt6 单元测试文件覆盖 models 和 utils 模块
2. 扩展已有的 itemspage 和 searchfilter 代理模型测试
3. 更新 CMakeLists.txt 注册新测试 target 并启用 gcov 覆盖率
4. 达到 72.0% 过滤后行覆盖率和 86.1% 函数覆盖率

Influence:
1. 使用 cmake -DBUILD_TEST=ON 编译并运行全部 15 个测试 target
2. 验证 185 条用例全部通过零失败
3. 检查 src/models 和 src/utils 模块的 gcov 覆盖率报告
4. 验证测试隔离性无 false-green 用例
1. Rename the test gate option from BUILD_TEST to BUILD_TESTING
2. Enable coverage instrumentation for test targets by default
3. Add coverage target that runs ctest and generates the lcov report

Log: Unify the test gate to BUILD_TESTING and add a coverage target

test: 统一测试门控为 BUILD_TESTING 并新增 coverage 目标

1. 将测试门控选项由 BUILD_TEST 重命名为 BUILD_TESTING
2. 默认开启测试目标的覆盖率插桩
3. 新增 coverage 目标,执行 ctest 并生成 lcov 报告

Log: 统一测试门控为 BUILD_TESTING,并新增 coverage 目标
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 14f5896 to 0a3396f Compare September 21, 2026 02:16
@deepin-bot

deepin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.48
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #816

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.

4 participants