Skip to content

test: add CMake unit test framework and tests for utils/settings/desktopinfo - #59

Closed
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:ut-framework-utils-settings-desktopinfo
Closed

add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:ut-framework-utils-settings-desktopinfo

Conversation

@add-uos

@add-uos add-uos commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

Introduce a CMake-based unit test framework under autotests/ (enabled via the BUILD_TESTS option) and add the first batch of GoogleTest unit tests for the utility/configuration classes.

This is the first PR of a 3-part series that upstreams unit tests for deepin-picker. The other two PRs only add additional test_*.cpp files, which are automatically picked up by this framework via file(GLOB test_*.cpp) once merged.

Why

deepin-picker currently has no unit tests. This adds a reusable test framework and starts covering the core classes.

Changes

  • CMakeLists.txt: root CMake build with a BUILD_TESTS option that wires in autotests/.
  • autotests/: GoogleTest framework — per-target test discovery, the stub-ext stubbing helper for private/internal APIs, optional gcov coverage, a one-shot runner (run-ut.sh) and a summary generator (gen-ut-summary.py).
  • autotests/src/test_Utils.cpp — 34 cases
  • autotests/src/test_Settings.cpp — 11 cases
  • autotests/src/test_DesktopInfo.cpp — 10 cases

Notes

  • The existing qmake build (deepin-picker.pro) is unaffected; CMake is an opt-in parallel build used only for testing.
  • autotests/src/CMakeLists.txt globs test_*.cpp, so subsequent test-only PRs need no CMake edits.

Verification

Built and run with Qt6 / DTK6:

cmake -B build -DBUILD_TESTS=ON && cmake --build build

All 55 cases pass: test_Utils (34), test_Settings (11), test_DesktopInfo (10).

…topinfo

Introduce a CMake-based unit test framework under autotests/, enabled via
the BUILD_TESTS option (default ON). The framework uses GoogleTest with
per-target test discovery, the stub-ext stubbing helper for private/internal
APIs, optional gcov coverage, a one-shot runner script (run-ut.sh) and a
summary generator (gen-ut-summary.py). The existing qmake build (.pro) is
unaffected; CMake is an opt-in parallel build for testing.

Add the first batch of unit tests for the utility/configuration classes:
- Utils: 34 cases (color format conversion, validation, helpers)
- Settings: 11 cases (config read/write and persistence)
- DesktopInfo: 10 cases (desktop environment detection)

All 55 cases pass with Qt6/DTK6.

@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 @add-uos, your pull request is larger than the review limit of 150,000 diff characters

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export, unset变动
详情
    {
    "export": {
        "autotests/run-ut.sh": {
            "b": [
                "export QT_QPA_PLATFORM=${QT_QPA_PLATFORM:-offscreen}",
                "export ASAN_OPTIONS=${ASAN_OPTIONS:-detect_leaks=1}",
                "export LSAN_OPTIONS=suppressions=\"$SCRIPT_DIR/lsan_suppressions.txt\"",
                "    export projectdir=\"$PROJECT_ROOT\"",
                "    export builddir=\"build-${TEST_DIR}\"",
                "    export reportdir=\"build-${TEST_DIR}\"",
                "    export GTEST_XML_DIR=\"$GTEST_XML_DIR\"",
                "    export COVERAGE_INFO=\"$BUILD_DIR/coverage.info\""
            ]
        }
    },
    "unset": {
        "autotests/src/test_DesktopInfo.cpp": {
            "b": [
                "            qunsetenv(var_.constData());"
            ]
        }
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos add-uos closed this Sep 14, 2026
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.

3 participants