Skip to content

test: add unit tests for editor core, areas and wrapper - #563

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ut-editor-core-areas-wrapper
Sep 4, 2026
Merged

test: add unit tests for editor core, areas and wrapper#563
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ut-editor-core-areas-wrapper

Conversation

@pengfeixx

Copy link
Copy Markdown
Contributor

内容

新增编辑器核心区域与封装层的 GTest 单元测试:DTextEdit 光标/编辑/事件/查找/标记逻辑、行号区、代码折叠区、书签组件、EditWrapper,共 18 个文件。

说明

  • 基于 master 独立拉出,可独立评审与合并
  • 仅新增单元测试代码,不改动编辑器本体功能

@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, your pull request is larger than the review limit of 150,000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码质量优秀。本次提交新增 18 个单元测试文件,覆盖 DTextEdit 光标/编辑/事件/查找/标记逻辑、行号区、代码折叠区、书签组件及 EditWrapper 的 GTest 单元测试。测试代码结构清晰、注释完整、边界覆盖充分,符合新增测试代码的目的。仅存在轻微的代码风格建议,不影响代码质量。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码使用 GTest 框架,语法正确,逻辑清晰。采用一致的 Arrange-Act-Assert 模式,边界条件覆盖完善(空输入、null 指针、边界值等)。SetUp/TearDown 正确管理资源生命周期。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码质量优秀:每个文件头部都有详细的方法覆盖矩阵、分支清单和用例映射;SPDX 许可证头齐全;共享夹具 editor_core_fixture.h 有效提取公共设置;辅助函数(setDocText/makeCursor/sendKey 等)复用性好;命名规范一致;无残留调试代码。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 测试使用 QT_QPA_PLATFORM=offscreen 无头模式,资源隔离完善。共享静态库方案避免重复编译。stub/mock 模式正确隔离依赖。DBus 使用伪连接、文件操作使用 QTemporaryDir、XDG 路径重定向到临时目录,避免环境污染。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 测试代码无安全漏洞:无硬编码凭证、无注入风险、无敏感信息泄露。DBus 连接使用伪总线隔离,文件操作使用 QTemporaryDir 临时目录,XDG_CONFIG_HOME 重定向到临时目录避免污染用户配置。QMenu::exec 被 stub 拦截防止模态阻塞。


💡 改进建议代码示例

// 暂无代码示例

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

@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

Add GTest suites for DTextEdit cursor/edit/event/find/mark logic,
line number and code fold areas, bookmark widget and EditWrapper.

新增 DTextEdit 光标/编辑/事件/查找/标记逻辑、行号区、代码折叠区、
书签组件及 EditWrapper 的 GTest 单元测试。

Log: 新增编辑器核心、绘制区域及封装层单元测试
Influence: 仅新增单元测试代码,不影响编辑器本体功能。
@pengfeixx
pengfeixx force-pushed the test/ut-editor-core-areas-wrapper branch from c973a39 to 6385c5b Compare September 4, 2026 09:02
@pengfeixx
pengfeixx merged commit 120f183 into linuxdeepin:master Sep 4, 2026
12 of 14 checks passed
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
  • 检测到敏感词unset变动
详情
    {
    "unset": {
        "tests/editor_core/editor_core_fixture.h": {
            "b": [
                "        qunsetenv(\"XDG_CONFIG_HOME\");",
                "        qunsetenv(\"QT_QPA_PLATFORM\");"
            ]
        },
        "tests/editor_wrapper/test_editwrapper.cpp": {
            "b": [
                "//   TearDownTestSuite qunsetenv \u914d\u5e73\uff09\uff0cSettings/\u8349\u7a3f\u76ee\u5f55/\u5907\u4efd\u76ee\u5f55\u5168\u90e8\u843d\u5728\u4e34\u65f6\u533a",
                "        // \u73af\u5883\u9694\u79bb\uff1aXDG \u91cd\u5b9a\u5411\u5230\u4e34\u65f6\u76ee\u5f55\uff08TearDownTestSuite qunsetenv \u914d\u5e73\uff09",
                "        qunsetenv(\"XDG_CONFIG_HOME\");",
                "        qunsetenv(\"XDG_DATA_HOME\");"
            ]
        }
    }
}

@pengfeixx
pengfeixx deleted the test/ut-editor-core-areas-wrapper branch September 4, 2026 09:02
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