Skip to content

test: extend dbus tests and add plugin/delegate tests - #563

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:ut-coverage-batch-5
Oct 27, 2026
Merged

pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:ut-coverage-batch-5

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Part 5/8 of the deepin-log-viewer unit-test coverage series (single-commit PR; all 8 PRs touch disjoint file sets and are mutually independent).

Files in this PR (6 files, +1344/-118 lines)

  • tests/dbusproxy/ut_dldbushandler.cpp
  • tests/src/ut_logviewitemdelegate.cpp
  • tests/ut_logviewerplugin/ut_logViewerPlugin.cpp
  • tests/src/ut_logdetailedit.cpp
  • tests/src/ut_logviewer_truncate_main.cpp (new)
  • tests/src/ut_sharedmemorymanager.cpp

Notes

  • Test-only change: no production source code is modified.
  • New test files live in tests/src/ / tests/dbusproxy/ / tests/ut_logviewerplugin/, globbed automatically by tests/CMakeLists.txt (re-run cmake after pulling).
  • Each file was compiled and executed individually (GTest + lcov) in its generating task; whole-branch build verification recommended in CI.
  • Series goal: function coverage toward 100% (baseline: 690 passing cases, 68.2% function / 58.5% line coverage).

Summary by Sourcery

Increase unit-test coverage across core log viewer components and command-line behavior.

Enhancements:

  • Expand unit-test coverage across D-Bus log handling, log detail gestures, item delegate rendering, shared-memory management, plugin behavior, and the log truncation entry point.

Tests:

  • Add comprehensive tests for DLDBusHandler file access, streaming, metadata, exporting, caching, and command execution paths.
  • Add UI and interaction tests for log detail editing, delegate painting and sizing, and shared-memory singleton lifecycle behavior.
  • Add plugin tests covering filtering, data management, application export flows, signal emissions, and export format combinations.
  • Add isolated tests for logViewerTruncate command-line handling and process output paths.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 45 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

This test-only PR substantially increases unit-test and function coverage by adding isolated filesystem, Qt event, rendering, process, singleton, and plugin-export scenarios across six test targets, with stubs and temporary resources used to drive success and failure branches.

File-Level Changes

Change Details Files
Expand DLDBusHandler coverage across path routing, file operations, streaming, exporting, command execution, cache management, and singleton behavior.
  • Add fixture-based tests using temporary home directories and controlled Utils::homePath routing.
  • Exercise local and non-local branches, error paths, export filename parsing, cleanup, and invokable methods.
  • Verify file contents, sizes, line counts, whitelist behavior, singleton identity, and cache-file lifecycle.
tests/dbusproxy/ut_dldbushandler.cpp
Add UI gesture, scrolling, animation, and event-handler unit tests for log detail editing.
  • Cover selection clearing, FlashTween timer execution and destruction, gesture states, event dispatch, synthesized mouse releases, and fast-scroll handling.
  • Use Qt event processing and Stub hooks to drive otherwise difficult gesture and event branches.
tests/src/ut_logdetailedit.cpp
Introduce tests for the log truncation utility's command-line entry point.
  • Include the production main with a renamed symbol and execute it in forked child processes.
  • Stub command-line parsing and QProcess behavior to cover no-argument, dmesg, and file-truncation flows.
tests/src/ut_logviewer_truncate_main.cpp
Build out LogViewItemDelegate rendering and style-option coverage.
  • Test construction, style initialization with and without roles, alternating rows, display data, size hints, invalid indexes, and multiple item positions.
  • Render selected, disabled, icon-bearing, and default-position items to an offscreen image with DStyle stubs.
tests/src/ut_logviewitemdelegate.cpp
Extend SharedMemoryManager tests for singleton access and memory-release branches.
  • Verify getInstance/instance identity and reuse.
  • Exercise release with attached and null shared-memory objects using private-field access.
tests/src/ut_sharedmemorymanager.cpp
Expand LogViewerPlugin tests across filtering, data clearing, callbacks, application naming, and export workflows.
  • Parameterize application generation across button IDs.
  • Validate filter and list-clearing behavior, guarded and successful signal emissions, application export edge cases, and export format/flag combinations.
  • Stub thread and export operations to test asynchronous paths without real worker execution.
tests/ut_logviewerplugin/ut_logViewerPlugin.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

@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-5 branch from 7aaef58 to d36ba59 Compare October 27, 2026 11:29
@pengfeixx pengfeixx changed the title feat(test): extend dbus handler tests and add plugin/delegate UTs (batch 5/8) test: extend dbus tests and add plugin/delegate tests Oct 27, 2026
@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-5 branch from d36ba59 to a019121 Compare October 27, 2026 11:34
1. Extend ut_dldbushandler.cpp to cover all 22 public methods
2. Add ut_logviewer_truncate_main.cpp for the truncate tool entry
3. Extend plugin, delegate, detailedit and sharedmemory tests

Log: No user-facing changes

Influence:
1. Run deepin-log-viewer-test with --gtest_filter='*DLDBus*;*Plugin*'
2. Run deepin-log-viewer-plugin-test for the plugin suite
3. Check lcov function coverage of dldbushandler.cpp

test: 扩展DBus测试并新增插件与委托测试

1. 扩展 ut_dldbushandler.cpp,覆盖全部 22 个公开方法
2. 新增 ut_logviewer_truncate_main.cpp 裁剪工具入口测试
3. 扩展插件、委托、详情编辑与共享内存测试

Log: 无用户可见变化

Influence:
1. 运行 deepin-log-viewer-test 过滤 DLDBus/Plugin 套件
2. 运行 deepin-log-viewer-plugin-test 插件测试
3. 用 lcov 检查 dldbushandler.cpp 函数覆盖率
@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-5 branch from a019121 to 7aea34e Compare October 27, 2026 12:09
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为 deepin-log-viewer 项目的单元测试大幅增强,涵盖 6 个测试文件,新增大量测试用例以提升代码覆盖率。语法逻辑正确,无编译错误或逻辑缺陷;代码质量良好,结构清晰注释完整,仅有一处恒真断言需改进;性能方面无问题;安全方面未引入任何漏洞。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: ['无语法逻辑问题,建议保持当前测试规范。']


2. 代码质量 ✅

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

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

建议: ['将 getOtherFileInfo_home_branch 的恒真断言替换为有意义的验证,如 EXPECT_TRUE(result.isEmpty()) 或对结果内容的具体检查', '考虑在 UT_DLDBusHandler::SetUp 中设置 Utils::homePath = m_homeDir.path(),减少各测试用例中的重复代码']


3. 代码性能 ✅

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

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

建议: ['无性能问题。']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: ['无安全问题,测试代码安全合规。']


💡 改进建议代码示例

// 建议:将 getOtherFileInfo_home_branch 中的恒真断言替换为有意义的验证
TEST_F(UT_DLDBusHandler, getOtherFileInfo_home_branch)
{
    Utils::homePath = m_homeDir.path();
    QStringList result = m_handler->getOtherFileInfo(Utils::homePath, false);
    // 替换恒真断言为具体验证
    EXPECT_TRUE(result.isEmpty());
}

// 建议:在 SetUp 中统一设置 Utils::homePath,减少重复
void SetUp() override
{
    m_oldHome = Utils::homePath;
    Utils::homePath = m_homeDir.path();  // 统一设置默认 home 路径
    m_handler = new DLDBusHandler();
    ASSERT_NE(m_handler, nullptr);
}

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

@deepin-bot

deepin-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.5.43
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #567

@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 5f69e4b into linuxdeepin:master Oct 27, 2026
14 of 15 checks passed
@pengfeixx
pengfeixx deleted the ut-coverage-batch-5 branch October 27, 2026 12:39
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