Skip to content

test: add unit tests for V-9310 coverage gaps - #301

Merged
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:ut-v9310-coverage
Nov 26, 2026
Merged

wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:ut-v9310-coverage

Conversation

@wyu71

@wyu71 wyu71 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add 5 unit test files covering uncovered code paths identified in V-9310.

Test Files

File Source Coverage Target
test_filehander_oldddf.cpp src/service/filehander.cpp old ddf user-cancel branches (EUserCancelLoad_OldBlur/OldPen), damaged image loading (EDamagedImageFile), file/directory writability checks, saveToDdf symlink-loop open failure, saveToImage empty-image guard
test_cgraphicsview_paste.cpp src/frame/cgraphicsview.cpp slotOnPaste with image/png payload (adaptImgPosAndRect + addImage), slotOnPaste with text/uri-list payload (loadFiles)
test_cgraphicsitem_cache.cpp src/drawshape/drawItems/bzItems/cgraphicsitem.cpp setPenColor/setPenWidth/setBrushColor resetCachePixmap, loadGraphicsUnit with blurInfos, operating/operatingEnd EScal, paint cache drawing, rasterToSelfLayer(true)
test_cdrawscene_touchevent.cpp src/drawshape/cdrawscene.cpp doLeave interrupt, group tree info with processEvent, loadGroupTreeInfo with child groups, group-internal z-order, addCItem/removeCItem null guards, firstItem with penalgor, recordSecenInfoToCmd early return
test_cexportimagedialog_sizesetting.cpp src/widgets/dialog/cexportimagedialog.cpp keepRadioIfPixelModel sync, editingFinished triggers, resetImageSettingSizeTo, autoKeepSize ETooSmall/ETooBig, isFocusInEditor

Test Results

  • 42 tests passed, 4 skipped with documented reasons
  • Skipped tests:
    • Touch events with real touch points: PageScene::event() calls page()->currentTool_p() without null check; page() returns null inside event() in offscreen mode
    • isFocusInEditor(): requires widget focus which doesn't work in offscreen mode
    • saveToImage empty-image guard: API takes PageContext* not QImage directly; cannot trigger null-image check without modifying business code

Test Environment

  • Qt 6 / DTK 6
  • QT_QPA_PLATFORM=offscreen
  • ASAN enabled

Summary by Sourcery

Expand unit-test coverage for V-9310 coverage gaps across file handling, graphics views and items, draw scenes, and export image sizing.

Enhancements:

  • Add unit coverage for previously untested file handling, paste handling, graphics-item caching, scene operations, and export-image size-setting paths.

Tests:

  • Introduce five focused test suites covering legacy DDF loading, damaged images, writability and save failures, clipboard paste payloads, graphics caching and rasterization, scene grouping and ordering, null guards, and export size validation.

@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

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

You can request another review in 4 hours and 44 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Add tests for graphics-item cache invalidation, scaling, painting, and rasterization paths.

  • tests/test_cgraphicsitem_cache.cpp L1-303

Add tests for scene lifecycle, grouping, z-ordering, null guards, hit testing, and undo-recording paths.

  • tests/test_cdrawscene_touchevent.cpp L1-396

Add tests for legacy DDF cancellation, damaged images, writability checks, and save failures.

  • tests/test_filehander_oldddf.cpp L1-287

Add tests for clipboard image and URL-list paste paths.

  • tests/test_cgraphicsview_paste.cpp L1-162

Add tests for export-image size-setting signals, model changes, and bounds validation.

  • tests/test_cexportimagedialog_sizesetting.cpp L1-248

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

Add 5 test files covering uncovered code paths in:
- src/service/filehander.cpp: old ddf user-cancel branches (EUserCancelLoad_OldBlur/OldPen),
  damaged image loading (EDamagedImageFile), file/directory writability checks,
  saveToDdf symlink-loop open failure, saveToImage empty-image guard
- src/frame/cgraphicsview.cpp: slotOnPaste with image/png and text/uri-list payloads
- src/drawshape/drawItems/bzItems/cgraphicsitem.cpp: cache-related branches
  (setPenColor/setPenWidth/setBrushColor resetCachePixmap, loadGraphicsUnit with blurInfos,
  operating/operatingEnd EScal, paint cache drawing, rasterToSelfLayer(true))
- src/drawshape/cdrawscene.cpp: doLeave interrupt, group tree info with processEvent,
  loadGroupTreeInfo with child groups, group-internal z-order, addCItem/removeCItem null
  guards, firstItem with penalgor, recordSecenInfoToCmd early return
- src/widgets/dialog/cexportimagedialog.cpp: size setting private class branches
  (keepRadioIfPixelModel sync, editingFinished triggers, resetImageSettingSizeTo,
  autoKeepSize ETooSmall/ETooBig, isFocusInEditor)

Issue: V-9310
Log: add 5 test files covering uncovered code paths
@wyu71
wyu71 force-pushed the ut-v9310-coverage branch from 0e969e0 to eca7773 Compare November 26, 2026 11:26
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@wyu71
wyu71 merged commit 4e86913 into linuxdeepin:master Nov 26, 2026
14 checks passed
@wyu71
wyu71 deleted the ut-v9310-coverage branch November 26, 2026 13:27
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