Skip to content

test: add tests for deepin-reader batch 1 (7/7 classes) - #411

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:test/pms-batch1-ut
Sep 29, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:test/pms-batch1-ut

Conversation

@add-uos

@add-uos add-uos commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

概述

PMS 补强(qt-autotest-generator Mode 7→Mode 2):基于 git 历史 PMS bug 修复提交挖掘,为 10 个 sev1/2 bug 的 18 个目标函数生成 26 个 BUG 回归用例。

  • 新增用例 26/26 通过,全量测试 1226/1226 通过(无回归破坏)
  • 覆盖率(build-ut-coverage):lines 84.6%(13088/15465)、functions 98.1%(1363/1389),18/18 目标函数 FNDA 全命中

用例分布

测试文件 新增 覆盖 bug
tests/uiframe/ut_docsheet.cpp +5 348017 / 106171 / 164325
tests/sidebar/ut_sidebarimageviewmodel.cpp +9 343541 / 335473
tests/uiframe/ut_central.cpp +2 97761
tests/app/ut_dbusobject.cpp +3 312013
tests/app/ut_utils.cpp +2 218701
tests/document/ut_model.cpp +3 332133 / 304083
tests/document/ut_xpsmodel.cpp +2 343541

用例命名 BUG<id>_<场景>,注释含 PMS 链接与修复 commit sha。

新发现源码缺陷(记录于 tests/.ut-defects.json)

  1. runtime: CentralDocPage::isFullScreen(:897)parentWidget 三级链无空守卫,parent 不足 3 级时空指针解引用
  2. logic: DocumentFactory::getDocument(Model.cpp:160)copy 失败分支 return nullptr 但 *pprocess 未置空
  3. manual: calculateTimeout/getHtmlToPdfPath(Model.cpp:40/60)static 自由函数不可直测(已经 getDocument 管线间接覆盖)

测试方式

cmake -B build-ut -DBUILD_TESTS=ON && cmake --build build-ut -j$(nproc) --target test-deepin-reader
cd build-ut/tests && QT_QPA_PLATFORM=offscreen ./test-deepin-reader

Summary by Sourcery

Strengthen deepin-reader’s regression suite with targeted coverage for historical high-severity bugs across application, document, sidebar, and UI components.

Enhancements:

  • Add regression coverage for seven core classes across document conversion, rendering, sidebar annotations, DBus file handling, UI state, and utility behavior, targeting ten historical severity 1/2 defects.

Tests:

  • Add 26 PMS-linked regression tests covering boundary conditions, failure handling, lifecycle behavior, scaling, batching, and repeated operations without crashes.

Chores:

  • Record three newly identified source-level defects and testing limitations in the test defect inventory.

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 6.6.2
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai

sourcery-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds 26 PMS-linked regression tests across seven reader components, validating GUI state transitions, sidebar batching, document conversion failure paths, DBus handling, rendering guards, and utility behavior through targeted stubs and fixtures; it also records discovered defects and updates package metadata.

Flow diagram for PMS regression test coverage

flowchart TD
    Tests["26 PMS-linked regression tests"] --> GUI["GUI state and rendering guards"]
    Tests --> Sidebar["Sidebar batching and view-model behavior"]
    Tests --> Document["Document conversion and XPS failure paths"]
    Tests --> App["DBus handling and utility behavior"]
    GUI --> Result["26 new tests pass"]
    Sidebar --> Result
    Document --> Result
    App --> Result
    Result --> FullSuite["1226/1226 full test suite passes"]
Loading

File-Level Changes

Change Details Files
Adds PMS regression coverage for seven reader components, using focused unit fixtures, Qt signal/timer assertions, and stubs to isolate external processes and GUI/DBus behavior.
  • Adds DocSheet tests for UUID lifecycle, scale-factor ordering, sidebar visibility transitions, and empty annotation removal.
  • Adds SidebarImageViewModel tests for debounced thumbnail updates, null/boundary annotation handling, and idempotent removals.
  • Adds document conversion tests for dynamic timeout/overflow handling and graceful DOCX pipeline failures.
  • Adds DBus/MainWindow tests for URL-to-local-path conversion, duplicate-open suppression, and repeated shutdown unblocking.
  • Adds utility, XPS rendering, and CentralDocPage tests for null guards, size/scaling behavior, lazy creation, and signal wiring.
tests/uiframe/ut_docsheet.cpp
tests/sidebar/ut_sidebarimageviewmodel.cpp
tests/document/ut_model.cpp
tests/app/ut_dbusobject.cpp
tests/app/ut_utils.cpp
tests/document/ut_xpsmodel.cpp
tests/uiframe/ut_central.cpp
Records newly identified runtime, logic, and testability defects discovered during the regression-test work.
  • Documents missing parent-chain guarding in fullscreen detection.
  • Documents stale process-pointer state on document-copy failure.
  • Records static conversion helper functions as indirectly covered through the public document factory pipeline.
tests/.ut-defects.json
Updates package metadata alongside the test batch.
  • Bumps the Linglong package version from 6.6.1.1 to 6.6.2.1.
  • Adds seven changelog entries.
linglong.yaml
debian/changelog

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/sidebar/ut_sidebarimageviewmodel.cpp" line_range="273" />
<code_context>
+    EXPECT_TRUE(m_tester->m_pendingUpdatePages.contains(1));
+    EXPECT_TRUE(m_tester->m_batchUpdateTimer->isActive());
+
+    QSignalSpy spy(m_tester, &SideBarImageViewModel::dataChanged);
+    QTest::qWait(200);  // timer 100ms 单次触发 onBatchUpdateTimer
+    EXPECT_GE(spy.count(), 1);
+    EXPECT_TRUE(m_tester->m_pendingUpdatePages.isEmpty());
+    EXPECT_FALSE(m_tester->m_batchUpdateTimer->isActive());
</code_context>
<issue_to_address>
**issue (testing):** BUG343541_handleRenderThumbnail_batchDebounce relies on a fixed 200 ms sleep to observe a 100 ms timer. On a busy CI worker, the test thread or event loop can be delayed beyond that interval, causing spy.count() to remain zero and producing a flaky failure unrelated to the batching behavior.

**Triggers:** When the test process is descheduled or the Qt event loop is delayed for more than 200 ms.

**Suggested fix:** Use an event-driven wait such as QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, ...) instead of a fixed qWait.

```suggestion
    QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, 1000);  // timer 100ms 单次触发 onBatchUpdateTimer
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

EXPECT_TRUE(m_tester->m_batchUpdateTimer->isActive());

QSignalSpy spy(m_tester, &SideBarImageViewModel::dataChanged);
QTest::qWait(200); // timer 100ms 单次触发 onBatchUpdateTimer

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): BUG343541_handleRenderThumbnail_batchDebounce relies on a fixed 200 ms sleep to observe a 100 ms timer. On a busy CI worker, the test thread or event loop can be delayed beyond that interval, causing spy.count() to remain zero and producing a flaky failure unrelated to the batching behavior.

Triggers: When the test process is descheduled or the Qt event loop is delayed for more than 200 ms.

Suggested fix: Use an event-driven wait such as QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, ...) instead of a fixed qWait.

Suggested change
QTest::qWait(200); // timer 100ms 单次触发 onBatchUpdateTimer
QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, 1000); // timer 100ms 单次触发 onBatchUpdateTimer

Generated by qt-autotest-generator skill.
Batch 1: DocSheet, SideBarImageViewModel, Central, DBusObject, Utils, Model, ...
Cumulative: 7/7 classes, 18/18 methods tested
Baseline: master @ ad672ce "chore: Update version to 6.6.2" (2026-09-29)

Log: 新增 deepin-reader 单元测试
Influence: 新增 7 个类的单元测试,本批次覆盖率 18/18,累计覆盖率 18/18

PMS 补强(Mode 7→Mode 2):为 10 个 sev1/2 bug 的 18 个目标函数
生成 26 个 BUG<id>_<场景> 回归用例,26/26 通过,全量 1226/1226 通过。

分布:
- tests/uiframe/ut_docsheet.cpp +5(bugs 348017/106171/164325)
- tests/sidebar/ut_sidebarimageviewmodel.cpp +9(bugs 343541/335473)
- tests/uiframe/ut_central.cpp +2(bug 97761)
- tests/app/ut_dbusobject.cpp +3(bug 312013)
- tests/app/ut_utils.cpp +2(bug 218701)
- tests/document/ut_model.cpp +3(bugs 332133/304083)
- tests/document/ut_xpsmodel.cpp +2(bug 343541)

覆盖率(build-ut-coverage):lines 84.6%(13088/15465),
functions 98.1%(1363/1389),18/18 目标函数 FNDA 全命中。

测试过程中新发现源码缺陷 3 个(记录留本地,不入库):
1. runtime: CentralDocPage::isFullScreen(:897)parentWidget 三级链无空守卫
2. logic: DocumentFactory::getDocument(Model.cpp:160)copy 失败分支 *pprocess 未置空
3. manual: calculateTimeout/getHtmlToPdfPath(Model.cpp:40/60)static 自由函数不可直测

注:PMS 工作单与缺陷记录留本地,不入库。
@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 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 4cf24f8 into linuxdeepin:master Sep 29, 2026
9 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