Skip to content

test: extend tests for detail widget and app helper - #564

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

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

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Part 6/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, +1361/-101 lines)

  • tests/src/ut_logdetailinfowidget.cpp
  • tests/src/ut_viewapplication.cpp (new)
  • tests/src/ut_loglistview.cpp
  • tests/src/ut_logapplicationhelper.cpp
  • tests/src/ut_logiconbutton.cpp
  • tests/src/ut_logallexportthread.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

Broaden unit-test coverage for log viewer widgets, helpers, export behavior, and application lifecycle paths.

Enhancements:

  • Expand unit-test coverage across log detail rendering, list-view interactions, application configuration helpers, icon buttons, export-thread execution, and ViewApplication lifecycle and command-handling paths.

Tests:

  • Add comprehensive widget and helper tests covering UI state, log-type branches, process and shared-memory behavior, menu actions, and export paths.
  • Introduce a new ViewApplication test suite covering construction, command modes, signal handling, cleanup, and application-state restoration.

@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 1 hour and 56 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 expands unit coverage across six components by adding focused Qt widget assertions, branch-specific model and callback scenarios, dependency stubs, lifecycle safeguards, and an export-success filesystem path; it also introduces the new ViewApplication test suite.

File-Level Changes

Change Details Files
Broaden detail-widget tests from smoke checks into fixture-based behavioral coverage across UI state, formatting, rendering, and log-source branches.
  • Introduce a reusable test fixture with explicit widget ownership and teardown.
  • Assert initialization, clearing, visibility, text formatting, date splitting, level handling, OOC success/error states, and paint execution.
  • Exercise slot_DetailInfo for the supported table-data categories plus invalid and null-input paths.
tests/src/ut_logdetailinfowidget.cpp
Add comprehensive ViewApplication tests using process, shared-memory, application-state, and exit stubs to isolate constructor and lifecycle behavior.
  • Stub QProcess and QSharedMemory operations and preserve/restore the global Qt application and event-dispatcher state around each instance.
  • Cover command-resolution branches, ready-read and finished callbacks, stop behavior, shared-memory control retrieval, memory release, null guards, and destruction.
tests/src/ut_viewapplication.cpp
Extend LogListView coverage through targeted dependency stubs and UI event/action triggering.
  • Cover log-type retrieval, context-menu selection, delegate focus painting, shortcut activation, application-path lookup, and context-menu actions.
  • Patch DDialog's vtable at runtime so the clear action can be exercised without entering a nested dialog event loop.
tests/src/ut_loglistview.cpp
Add boundary and no-op tests for LogApplicationHelper's previously uncovered configuration, authentication, persistence, and path-validation methods.
  • Exercise configuration loading and lookup for empty, valid, and nonexistent applications.
  • Cover authentication list initialization/refresh, report-time and coredump accessors, JSON/file path validation, and translation-log setup.
tests/src/ut_logapplicationhelper.cpp
Replace LogIconButton smoke tests with assertions for constructor configuration and event/geometry behavior.
  • Verify flat state, focus policy, icon size, text, and size-hint metrics.
  • Exercise mouse, generic/hover events, and resize handling.
tests/src/ut_logiconbutton.cpp
Reach LogAllExportThread's successful export path with filesystem and utility stubs.
  • Create a temporary dummy archive from the export stub so run() enters directory-to-zip handling.
  • Stub permission export and command execution while cleaning up the temporary output.
tests/src/ut_logallexportthread.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-6 branch from c59e4e0 to 972f258 Compare October 27, 2026 11:30
@pengfeixx pengfeixx changed the title feat(test): extend detail widget and app helper unit tests (batch 6/8) test: extend tests for detail widget and app helper Oct 27, 2026
@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-6 branch from 972f258 to e7e81fe Compare October 27, 2026 11:34
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为纯测试代码扩展,commit 目的是为 detail widget 和 app helper 扩展单元测试覆盖。 6 个测试文件变更均围绕 GTest 框架编写,无生产代码改动。四维度分析均未发现实质性问题, 语法逻辑正确,测试结构清晰且注释完善,性能无瓶颈,安全方面无漏洞。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

本次提交无安全漏洞或严重代码问题,无需修复示例代码。 建议保持现有测试代码结构和注释质量。

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

@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-6 branch from e7e81fe to 3d355af Compare October 27, 2026 12:09
1. Add ut_viewapplication.cpp for the logViewerAuth UI layer
2. Extend ut_logdetailinfowidget.cpp and ut_logapplicationhelper.cpp
3. Extend loglistview, logiconbutton and logallexportthread tests

Log: No user-facing changes

Influence:
1. Run deepin-log-viewer-test with --gtest_filter='*View*;*Helper*'
2. Verify full suite passes with ASAN_OPTIONS=detect_leaks=0
3. Check lcov function coverage of viewapplication and helpers

test: 扩展详情控件与应用助手单元测试

1. 新增 ut_viewapplication.cpp 覆盖 logViewerAuth 界面层
2. 扩展 ut_logdetailinfowidget.cpp 与 ut_logapplicationhelper.cpp
3. 扩展列表视图、图标按钮与全量导出线程测试

Log: 无用户可见变化

Influence:
1. 运行 deepin-log-viewer-test 过滤 View/Helper 套件
2. 以 ASAN_OPTIONS=detect_leaks=0 验证全量用例通过
3. 用 lcov 检查 viewapplication 与助手类覆盖率
@pengfeixx
pengfeixx force-pushed the ut-coverage-batch-6 branch from 3d355af to 85936d3 Compare October 27, 2026 12:09
@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "tests/src/ut_logallexportthread.cpp": {
            "b": [
                "// Stub for exportOpsLog: creates a file at the given path and returns true.",
                "bool stub_exportOpsLog(void *unused, const QString &zipFilePath)",
                "// Stub for Utils::exportUserPermissionOpsLogs (static method, no `this` pointer).",
                "void stub_exportUserPermissionOpsLogs(const QString &outDir, const QString &userHomeDir)",
                "// Test: cover the lambda addDirToZip inside run() by making exportOpsLog succeed.",
                "// This lambda is only reached when exportOpsLog returns true and the ops zip file exists.",
                "    QString outFile = QDir::tempPath() + \"/ut_logallexport_test.zip\";",
                "    stub.set(ADDR(DLDBusHandler, exportLog), LogAllExportThread_stub_bool);",
                "    stub.set(ADDR(DLDBusHandler, exportOpsLog), stub_exportOpsLog);",
                "    stub.set(ADDR(Utils, exportUserPermissionOpsLogs), stub_exportUserPermissionOpsLogs);"
            ]
        }
    }
}

@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 53f6085 into linuxdeepin:master Oct 27, 2026
14 of 17 checks passed
@pengfeixx
pengfeixx deleted the ut-coverage-batch-6 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