Repository navigation
test: add unit tests for service and main window - #561
Conversation
|
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 45 minutes by commenting |
Reviewer's GuideThis test-only PR adds extensive coverage for the log viewer service and generated configuration object, exercises asynchronous LogCollectorMain behavior through targeted stubs and Qt event processing, and fills timing and widget paint branches in existing unit-test files. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
98a551d to
5ac54a3
Compare
5ac54a3 to
9fda5b0
Compare
9fda5b0 to
244e03f
Compare
1. Add ut_logviewerservice.cpp and ut_org_deepin_log_viewer.cpp 2. Extend ut_logcollectormain.cpp and ut_debugtimemanager.cpp 3. Extend ut_lognormalbutton.cpp including style painting branches Log: No user-facing changes Influence: 1. Run deepin-log-viewer-test with --gtest_filter='*Service*;*Collector*' 2. Verify full suite passes with ASAN_OPTIONS=detect_leaks=0 3. Check lcov function coverage of the new test targets test: 新增服务端与主窗口单元测试 1. 新增 ut_logviewerservice.cpp 与 ut_org_deepin_log_viewer.cpp 2. 扩展 ut_logcollectormain.cpp 和 ut_debugtimemanager.cpp 3. 扩展 ut_lognormalbutton.cpp,含样式绘制分支 Log: 无用户可见变化 Influence: 1. 运行 deepin-log-viewer-test 过滤 Service/Collector 套件 2. 以 ASAN_OPTIONS=detect_leaks=0 验证全量用例通过 3. 用 lcov 检查新增目标的函数覆盖率
244e03f to
9eed581
Compare
|
TAG Bot New tag: 6.5.43 |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['将 ut_logcollectormain.cpp 中重复的 stub 设置提取为公共辅助函数(如 setupCommonStubs(Stub &stub)),减少代码重复', '考虑使用 RAII 类管理 g_ut_clock_fail 标志,确保异常路径下自动重置'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无需修改'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无需修改'] 💡 改进建议代码示例// 建议:将 ut_logcollectormain.cpp 中重复的 stub 设置提取为公共辅助函数 // // 在文件顶部添加: // static void setupLogCollectorCommonStubs(Stub &stub) // { // stub.set(ADDR(DebugTimeManager, beginPointLinux), Log_beginPointLinux); // stub.set(ADDR(LogFileParser, parseByJournal), LogFileParser_parseByJournal); // stub.set(ADDR(LogFileParser, parseByJournalBoot), LogFileParser_parseByJournalBoot); // stub.set(ADDR(LogFileParser, parseByDpkg), LogFileParser_parseByDpkg); // stub.set(ADDR(LogFileParser, parseByXlog), LogFileParser_parseByXlog); // stub.set(ADDR(LogFileParser, parseByBoot), LogFileParser_parseByBoot); // stub.set(ADDR(LogFileParser, parseByKern), LogFileParser_parseByKern); // stub.set(ADDR(LogFileParser, parseByApp), LogFileParser_parseByApp); // stub.set(ADDR(LogFileParser, parseByNormal), LogFileParser_parseByNormal); // stub.set(ADDR(LogFileParser, parseByKwin), LogFileParser_parseByKwin); // stub.set(ADDR(LogApplicationHelper, getCustomLogList), LogApplicationHelper_getCustomLogList); // } // // 然后在每个测试中替换11行 stub.set() 为一行调用: // TEST(LogCollectorMain_initShortCut_UT, LogCollectorMain_initShortCut_UT_003) // { // qApp->setStyle(new DStyle); // Stub stub; // setupLogCollectorCommonStubs(stub); // 替代11行重复代码 // LogCollectorMain *p = new LogCollectorMain(nullptr); // // ... 其余测试逻辑不变 // }本报告由 AI 代码审查工具自动生成 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Part 3/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 (5 files, +1449/-12 lines)
tests/src/ut_logviewerservice.cpp(new)tests/src/ut_org_deepin_log_viewer.cpp(new)tests/src/ut_logcollectormain.cpptests/src/ut_debugtimemanager.cpptests/src/ut_lognormalbutton.cppNotes
tests/src//tests/dbusproxy//tests/ut_logviewerplugin/, globbed automatically bytests/CMakeLists.txt(re-run cmake after pulling).Summary by Sourcery
Increase unit-test coverage across core log viewer services, configuration handling, and main-window UI behavior.
Enhancements:
Tests: