Skip to content

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

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde/launchpad-tests
Oct 23, 2026
Merged

deepin-bot[bot] merged 1 commit 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 Qt unit-test suite and integrate automated coverage reporting for core models and utilities.

Enhancements:

  • Expand Qt unit-test coverage across core model and utility modules, including app arrangement, filtering, sorting, favorites, categories, icons, and BlurHash handling.

Build:

  • Rename the test build option to BUILD_TESTING and register the expanded test suite with the build system.

Tests:

  • Add 14 unit-test targets and extend existing ItemsPage and search/filter tests to cover 15 targets and 185 test cases.
  • Add optional gcov-based coverage instrumentation and a custom target for running tests and generating filtered coverage reports.

Chores:

  • Remove unnecessary test logging and standardize test include paths.

@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没过,
已修改

@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

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.49
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #821

@deepin-bot

deepin-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.50
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #824

@deepin-bot

deepin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.51
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #827

MyLeeJiEun added a commit to MyLeeJiEun/dde-launchpad that referenced this pull request Oct 22, 2026
- Rebase PR linuxdeepin#813 onto current upstream/master
- Keep upstream's Qt DBus component in root CMakeLists.txt
- Align test desktopId assertions with upstream's normalizedDesktopId
  semantics (pages store suffixed ids, AppsModel strips the suffix)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 0a3396f to 15b3e5b Compare October 22, 2026 06:40
MyLeeJiEun added a commit to MyLeeJiEun/dde-launchpad that referenced this pull request Oct 22, 2026
- Rebase PR linuxdeepin#813 onto current upstream/master
- Keep upstream's Qt DBus component in root CMakeLists.txt
- Align test desktopId assertions with upstream's normalizedDesktopId
  semantics (pages store suffixed ids, AppsModel strips the suffix)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 15b3e5b to 3bf6fd4 Compare October 22, 2026 06:54
MyLeeJiEun added a commit to MyLeeJiEun/dde-launchpad that referenced this pull request Oct 22, 2026
- Rebase PR linuxdeepin#813 onto current upstream/master
- Keep upstream's Qt DBus component in root CMakeLists.txt
- Align test desktopId assertions with upstream's normalizedDesktopId
  semantics (pages store suffixed ids, AppsModel strips the suffix)
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 3bf6fd4 to 1599279 Compare October 22, 2026 06:58
MyLeeJiEun added a commit to MyLeeJiEun/dde-launchpad that referenced this pull request Oct 22, 2026
- Rebase PR linuxdeepin#813 onto current upstream/master
- Keep upstream's Qt DBus component in root CMakeLists.txt
- Align test desktopId assertions with upstream's normalizedDesktopId
  semantics (pages store suffixed ids, AppsModel strips the suffix)
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 1599279 to 8135ab3 Compare October 22, 2026 06:59
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, 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

- Rebase PR linuxdeepin#813 onto current upstream/master
- Keep upstream's Qt DBus component in root CMakeLists.txt
- Align test desktopId assertions with upstream's normalizedDesktopId
  semantics (pages store suffixed ids, AppsModel strips the suffix)
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 8135ab3 to 70cffb7 Compare October 23, 2026 08:34
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为 dde-launchpad 项目补充了全面的单元测试,覆盖模型、工具类和页面管理组件。CMake 构建系统修改正确(BUILD_TEST → BUILD_TESTING 对齐 CMake 惯例),新增 OBJECT 库方案设计合理并附详细注释。测试代码语法正确、逻辑清晰、边界条件覆盖充分。无安全漏洞。仅在个别测试文件中存在空 namespace 块和少量代码重复,整体质量优秀。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['无需修改,语法逻辑完全正确']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['删除空 namespace {} 块以保持代码整洁', '可考虑将重复的 SourceRoles 枚举提取到 tests/ 下的公共头文件中,减少维护成本']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['无需修改,性能表现合理']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['无需修改,安全合规']


💡 改进建议代码示例

// 建议删除空 namespace 块,例如在 countlimitproxymodeltest.cpp 中:
// 删除以下空命名空间:
// namespace {
// }
//
// 如果未来 SourceRoles 重复变得难以维护,可创建 tests/common/sourceroles.h:
//
// #pragma once
// #include <QtUserRole>
//
// enum SourceRoles {
//     SrcDesktopIdRole = Qt::UserRole + 1,
//     SrcNameRole,
//     SrcIconNameRole,
//     SrcNoDisplayRole,
//     SrcDDECategoryRole,
//     SrcInstalledTimeRole,
//     SrcLastLaunchedTimeRole,
//     SrcLaunchedTimesRole,
//     SrcAutoStartRole,
//     SrcCategoriesRole,
//     SrcVendorRole,
//     SrcGenericNameRole,
// };

本报告由 AI 代码审查工具自动生成

@MyLeeJiEun

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 2e71bba into linuxdeepin:master Oct 23, 2026
6 checks passed
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