Skip to content

build: enable Qt6 build and raise unit test coverage above 80% - #547

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/qt6-cmake-and-ut-coverage
Jul 6, 2026
Merged

build: enable Qt6 build and raise unit test coverage above 80%#547
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/qt6-cmake-and-ut-coverage

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fix Qt6 detection in CMake on systems with both Qt5 and Qt6 installed, and add test cases for groupconfigoptdlg and titlebar to lift overall unit test coverage from 79% to 80.3%.

修复Qt5/Qt6共存环境下CMake错误选中Qt5的问题,并补充groupconfigoptdlg 与titlebar的单元测试,将整体覆盖率从79%提升至80.3%。

Log: 修复Qt6探测并提升单测覆盖率至80%以上
Influence: 项目可在Qt5/Qt6共存环境下正确构建并链接Qt6,单元测试覆盖率提升至80.3%。

Summary by Sourcery

Improve Qt version detection to prefer Qt6 in mixed Qt5/Qt6 environments and expand unit tests to raise coverage above 80%.

Build:

  • Adjust CMake Qt discovery to prefer Qt6 and fall back to Qt5, ensuring correct linkage in Qt5/Qt6 coexistence setups.

Tests:

  • Add unit tests for TitleBar mouse event handling, including vertical resize-related branches.
  • Introduce new GroupConfigOptDlg unit tests covering add/edit group dialog construction and theme change behavior.
  • Enable GroupConfigOptDlg test compilation via ut_defines flag to contribute to overall coverage above 80%.

Fix Qt6 detection in CMake on systems with both Qt5 and Qt6 installed,
and add test cases for groupconfigoptdlg and titlebar to lift overall
unit test coverage from 79% to 80.3%.

修复Qt5/Qt6共存环境下CMake错误选中Qt5的问题,并补充groupconfigoptdlg
与titlebar的单元测试,将整体覆盖率从79%提升至80.3%。

Log: 修复Qt6探测并提升单测覆盖率至80%以上
Influence: 项目可在Qt5/Qt6共存环境下正确构建并链接Qt6,单元测试覆盖率提升至80.3%。
@sourcery-ai

sourcery-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR fixes Qt version detection in CMake to reliably prefer Qt6 in mixed Qt5/Qt6 environments and adds new unit tests for the TitleBar mouse handling and GroupConfigOptDlg dialog flows to raise overall coverage above 80%.

Flow diagram for updated Qt version detection in CMake

flowchart TD
    A[Start CMake configure] --> B[find_package Qt6 QUIET COMPONENTS Core]
    B --> C{Qt6_FOUND}
    C -->|yes| D[set QT_VERSION_MAJOR 6]
    C -->|no| E[find_package Qt5 REQUIRED COMPONENTS Core]
    E --> F[set QT_VERSION_MAJOR 5]
    D --> G[Configure project with Qt6]
    F --> H[Configure project with Qt5]
Loading

File-Level Changes

Change Details Files
Adjust Qt discovery logic in CMake to explicitly prefer Qt6 and only fall back to Qt5 when Qt6 is not available.
  • Replace generic QT package search with an explicit Qt6-then-Qt5 lookup sequence.
  • Introduce conditional logic based on Qt6_FOUND to set QT_VERSION_MAJOR accordingly.
  • Retain existing messaging and downstream use of QT_VERSION_MAJOR and QT_DESIRED_VERSION.
CMakeLists.txt
Expand TitleBar unit tests to cover mouse interaction branches related to vertical resize behavior.
  • Instantiate a standalone TitleBar, configure size and vertical resize flag, and ensure it is visible.
  • Simulate mouse press events to exercise the mousePressEvent window-related branch.
  • Simulate multiple mouse move scenarios (no button near bottom, left button near bottom, mid-area, and with vertical resize disabled) to cover SizeVerCursor, window resize, ArrowCursor, and disabled paths.
tests/src/views/ut_titlebar_test.cpp
Add unit tests for GroupConfigOptDlg to exercise add/edit dialog construction and theme change handling, and enable them via unit test defines.
  • Enable GroupConfigOptDlg tests by adding the corresponding UT_GROUPCONFIGOPTDLG_TEST macro in the common unit test defines header.
  • Introduce a new gtest fixture for GroupConfigOptDlg with SetUp initializing ServerConfigManager.
  • Add tests that construct dialogs with empty and non-empty group names to cover "Add Group" and "Edit Group" branches.
  • Add a theme-change test that emits DGuiApplicationHelper::themeTypeChanged signals and verifies palette-related handling via QSignalSpy.
tests/src/common/ut_defines.h
tests/src/remotemanage/ut_groupconfigoptdlg_test.h
tests/src/remotemanage/ut_groupconfigoptdlg_test.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

@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 left some high level feedback:

  • The new TitleBar MouseEvents test only asserts widget visibility; consider adding checks on cursor shape or window resizing behavior to verify that the different mouse event branches are not only executed but also behave as expected.
  • In UT_GroupConfigOptDlg_Test::themeChange, QSignalSpy::wait() is unnecessary since you emit themeTypeChanged synchronously; you could drop the wait and instead assert on the dialog’s visual or state changes to better validate the theme handling logic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new TitleBar MouseEvents test only asserts widget visibility; consider adding checks on cursor shape or window resizing behavior to verify that the different mouse event branches are not only executed but also behave as expected.
- In UT_GroupConfigOptDlg_Test::themeChange, QSignalSpy::wait() is unnecessary since you emit themeTypeChanged synchronously; you could drop the wait and instead assert on the dialog’s visual or state changes to better validate the theme handling logic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, pengfeixx

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

@pengfeixx
pengfeixx merged commit 72fbb6e into linuxdeepin:master Jul 6, 2026
16 of 17 checks passed
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