Skip to content

test: add SecurityDialog/autoCutText and expand ColorWidget/Model cov… - #300

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/improve-coverage-3
Jul 21, 2026
Merged

test: add SecurityDialog/autoCutText and expand ColorWidget/Model cov…#300
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/improve-coverage-3

Conversation

@pengfeixx

Copy link
Copy Markdown
Contributor

…erage

New tests in ut_securitydialog.cpp cover dialog construction, changeEvent (Font/Theme/Other), and the autoCutText free function with empty/null/ short/long text inputs.
Extended ut_colorwidgetaction.cpp covers slotBtnClicked for every valid index, invalid index, default widget population, and separator property. Extended ut_model.cpp adds SearchResult helper coverage: empty/single/ multi-line sectionBoundingRect, setctionsFillText empty/with-content/ empty-callback cases.
Extended ut_thumbnaildelegate.cpp covers drawBookMark with visible=false and a separate drawBookMark-not-visible case.

新增 ut_securitydialog.cpp,覆盖对话框构造、changeEvent
(字体/主题/其他),以及 autoCutText 空串/null 标签/短文本/长文本
场景。
扩充 ut_colorwidgetaction.cpp,新增 slotBtnClicked 全索引遍历、 非法索引、defaultWidget 与 separator 属性验证用例。
扩充 ut_model.cpp,新增 SearchResult 辅助函数 sectionBoundingRect 与 setctionsFillText 的空/单行/多行/空回调场景用例。
扩充 ut_thumbnaildelegate.cpp,补充 drawBookMark(visible=false)。

Log: 补充 SecurityDialog/ColorWidget/Model/ThumbnailDelegate 测试用例
Influence: 单测从 882 增至 888,进一步提升 reader 模块边角函数覆盖率。

@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.

Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

…erage

New tests in ut_securitydialog.cpp cover dialog construction, changeEvent
(Font/Theme/Other), and the autoCutText free function with empty/null/
short/long text inputs.
Extended ut_colorwidgetaction.cpp covers slotBtnClicked for every valid
index, invalid index, default widget population, and separator property.
Extended ut_model.cpp adds SearchResult helper coverage: empty/single/
multi-line sectionBoundingRect, setctionsFillText empty/with-content/
empty-callback cases.
Extended ut_thumbnaildelegate.cpp covers drawBookMark with visible=false
and a separate drawBookMark-not-visible case.

新增 ut_securitydialog.cpp,覆盖对话框构造、changeEvent
(字体/主题/其他),以及 autoCutText 空串/null 标签/短文本/长文本
场景。
扩充 ut_colorwidgetaction.cpp,新增 slotBtnClicked 全索引遍历、
非法索引、defaultWidget 与 separator 属性验证用例。
扩充 ut_model.cpp,新增 SearchResult 辅助函数 sectionBoundingRect
与 setctionsFillText 的空/单行/多行/空回调场景用例。
扩充 ut_thumbnaildelegate.cpp,补充 drawBookMark(visible=false)。

Log: 补充 SecurityDialog/ColorWidget/Model/ThumbnailDelegate 测试用例
Influence: 单测从 882 增至 888,进一步提升 reader 模块边角函数覆盖率。
@pengfeixx
pengfeixx force-pushed the feat/improve-coverage-3 branch from 37bab82 to e427a8e Compare July 21, 2026 09:39
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码实现了对多个核心模块的单元测试增强,覆盖了边界条件和异常输入,测试结构清晰。
逻辑正确且无安全漏洞,但因版权声明年份格式存在明显笔误扣5分。

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

测试用例的语法符合C++和Google Test规范,对 SearchResult::sectionBoundingRectsetctionsFillText 的测试逻辑与 Model.cpp 中的实现完全对应。autoCutTextSecurityDialog 的测试也正确使用了相关类和事件类型。
潜在问题:版权声明 2019-2026 ~ 2020 逻辑混乱,年份范围表达错误;UT_ThumbnailDelegate_drawBookMarkNotVisiblenew QPainter() 未绑定绘制设备,若被测函数内部未做设备检查可能引发警告或异常。
建议:修正版权声明年份格式;确保 drawBookMark 函数能处理无设备绑定的 QPainter,或在测试中提供有效的绘制设备。

  • 2.代码质量(良好)✓

测试命名规范,遵循了 UT_ 前缀和驼峰命名法,测试用例覆盖了空数据、单行、多行、非法索引和空指针等边界场景,具有较高的测试价值。
潜在问题:版权声明字符串修改不当,存在 2019-2026 ~ 2020 这样的错误格式,影响代码规范性。
建议:将版权声明统一修改为 2019-2026 UnionTech Software Technology Co.,Ltd. 或其他符合规范的格式。

  • 3.代码性能(无性能问题)✓

测试代码均为轻量级内存操作和简单的对象构造,无复杂的算法或高频循环,不会对测试套件的执行效率产生负面影响。
潜在问题:无
建议:无需特别优化。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码为纯测试用例增强,不涉及任何外部输入解析、网络通信或敏感数据处理,不存在安全攻击面。

  • 建议:无需修复。

■ 【改进建议代码示例】

diff --git a/tests/widgets/ut_colorwidgetaction.cpp b/tests/widgets/ut_colorwidgetaction.cpp
index 79478a7c..4372264c 100644
--- a/tests/widgets/ut_colorwidgetaction.cpp
+++ b/tests/widgets/ut_colorwidgetaction.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
+// Copyright (C) 2019-2026 UnionTech Software Technology Co.,Ltd.
 // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
 //
 // SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/tests/widgets/ut_securitydialog.cpp b/tests/widgets/ut_securitydialog.cpp
index f4e9804e..4dc428ee 100644
--- a/tests/widgets/ut_securitydialog.cpp
+++ b/tests/widgets/ut_securitydialog.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
+// Copyright (C) 2019-2026 UnionTech Software Technology Co.,Ltd.
 // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
 //
 // SPDX-License-Identifier: GPL-3.0-or-later

@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 f9a4268 into linuxdeepin:master Jul 21, 2026
12 checks passed
@pengfeixx
pengfeixx deleted the feat/improve-coverage-3 branch July 21, 2026 09:44
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