Skip to content

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

Draft
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde/launchpad-tests
Draft

test: 补充 dde-launchpad 单元测试#800
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde/launchpad-tests

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

补充 dde-launchpad 单元测试

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

变更内容

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

测试与覆盖率

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

验证方式

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

Summary by Sourcery

Expand dde-launchpad’s Qt6 unit-test suite and coverage instrumentation across core models and utilities.

Enhancements:

  • Expand unit-test coverage for core dde-launchpad models and utility modules, including sorting, filtering, arrangement, favorites, categories, icons, and blurhash behavior.
  • Configure tested source modules as instrumented test dependencies so coverage data is collected reliably during test execution.

Build:

  • Register 15 Qt6 unit-test targets and add the required Qt and private Qt dependencies for testing.

Tests:

  • Add comprehensive Qt6 tests for model and utility behavior, and extend existing ItemsPage and search/filter proxy model tests.

@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 Aug 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR adds a comprehensive Qt6 unit test suite for dde-launchpad core models and utils, and reworks the tests build to compile target source files as OBJECT libraries for accurate gcov coverage collection.

File-Level Changes

Change Details Files
Rework tests CMake configuration to build core models/utils as OBJECT libraries and link them directly into test executables for gcov coverage.
  • Add Qt6 Gui/Qml/Svg and Qt6CorePrivate dependencies required by the tested source files.
  • Introduce launchpad-test-models OBJECT library including src/models/* core proxy and page models.
  • Introduce launchpad-test-utils OBJECT library including src/utils/* helpers such as blurhash, categoryutils, and iconutils.
  • Update launchpad_add_tests macro to link OBJECT libs, gio-utils, and launchpadcommon to each test target.
  • Register 15 test executables in launchpad_add_tests, covering models and utils modules.
tests/CMakeLists.txt
Add unit tests for utils blurhash and categoryutils to validate encoding/decoding behavior and category mapping logic.
  • Implement blurhashtest with encode/decode path coverage including invalid input, hash length expectations, round-trip color preservation, and bytesPerPixel variations.
  • Implement categoryutilstest to cover DDE and XDG category parsing, bestMatchedCategory heuristics, tie-breaking rules, and mixed known/unknown inputs.
  • Use QLoggingCategory in tests for traceability of individual test scenarios.
tests/blurhashtest.cpp
tests/categoryutilstest.cpp
Add unit tests for proxy models that implement row limiting, favorites, free sort, frequently-used logic, and recently-installed filtering.
  • Test CountLimitProxyModel maxRowCount semantics, signal emission, source row insertion/removal interactions, and source model lifecycle behavior.
  • Exercise FavoritedProxyModel singleton behavior: exists/add/remove/pinToTop, disk-backed favorited.ini cleanup, filtering to favorited apps only, and ordering by favorites list position.
  • Verify FreeSortProxyModel sorting by ItemArrangementProxyModel page/index roles, descending order support, and default handling when roles are missing.
  • Verify FrequentlyUsedProxyModel filtering against a recentlyInstalledModel, multi-criteria lessThan (launchedTimes, lastLaunchedTime, frequently-used list), QML lifecycle hooks, and property-based role configuration.
  • Test RecentlyInstalledProxyModel filtering of never-launched installed apps, ascending/descending order by installed time, and componentComplete default sort.
tests/countlimitproxymodeltest.cpp
tests/favoritedproxymodeltest.cpp
tests/freesortproxymodeltest.cpp
tests/frequentlyusedproxymodeltest.cpp
tests/recentlyinstalledproxymodeltest.cpp
Add tests for item arrangement and paging models, validating ItemsPage, ItemArrangementProxyModel, and ItemsPageModel behavior.
  • Extend itemspagetest to cover item search/containment, naming, item counts, firstNItems/allArrangedItems, removal by membership, empty-page handling, auto page creation, cross-page moves, and insertion with auto-selected page.
  • Add itemarrangementproxymodeltest to validate initial setup from AppsModel, page and folder roles, ItemType and IconsName behavior, allArrangedItems contents, bringToFront semantics, DnD commit edge cases, empty page creation/removal, and disk config cleanup.
  • Add itemspagemodeltest to test sourceModel wiring to ItemArrangementProxyModel, rowCount behavior, response to pageAdded/pageRemoved signals, and null/same source model guard paths.
tests/itemspagetest.cpp
tests/itemarrangementproxymodeltest.cpp
tests/itemspagemodeltest.cpp
Add tests for multipage and categorized sorting behavior over item-arrangement metadata and search categories.
  • Add multipagesortfilterproxymodeltest to verify filtering by folderId and pageId, behavior when no matches exist, filterOnlyMode semantics, and the requirement to invalidate() to see filterOnlyMode-based sort changes.
  • Extend searchfilterproxymodeltest to exercise CategorizedSortProxyModel alphabetarySections, DDECategorySections, categoryType transitions, and sortRoleName mapping for different category types.
tests/multipagesortfilterproxymodeltest.cpp
tests/searchfilterproxymodeltest.cpp
Add a comprehensive test suite for SortProxyModel itself, covering sorting, mapping, dataChanged handling, and edge cases.
  • Implement sortproxymodeltest to validate ascending/descending sort, source/proxy index mappings, case sensitivity, custom sort roles, insertion/removal behavior, model reset, multi-row removal, and properties sortColumn/sortOrder/sortRole/sortCaseSensitivity.
  • Introduce a ControllableStringListModel helper to isolate handleDataChanged behavior for empty roles vs specific roles and confirm reorder triggers only when expected.
  • Add tests for invalid index handling (index/data/mapToSource/mapFromSource) and columnCount with/without source model.
tests/sortproxymodeltest.cpp
Add tests for icon sizing and SVG loading utilities.
  • Implement iconutilstest to cover perfectIconSize and perfectIconSizeReverse behavior (rounding up/down, boundary conditions), folder icon cell calculation for various sizes and counts, and loadSvg behavior for nonexistent files via both QSize and int overloads.
tests/iconutilstest.cpp

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

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 用例
@MyLeeJiEun
MyLeeJiEun force-pushed the agent/dde/launchpad-tests branch from 123ea9c to 8675f8b Compare August 20, 2026 10:18
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.

2 participants