test: 新增 SheetRenderer/Logger 用例并扩充 DocTabBar/ThreadPool 测试 - #296
Conversation
Reviewer's GuideAdds new unit tests for SheetRenderer and MLogger and expands existing DocTabBar and ReaderImageThreadPoolManager tests to cover drag-and-drop, tab lifecycle, thread-pool behavior, and various edge cases (null/invalid inputs, empty documents), including cleanup of internal state to avoid dangling tasks and crashes. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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/ut_logger.cpp" line_range="60-37" />
<code_context>
+ EXPECT_TRUE(m_tester->rules().isEmpty());
+}
+
+TEST_F(UT_MLogger, testDestruction)
+{
+ MLogger *logger = new MLogger;
+ logger->setRules(QString("test.category=true"));
+ delete logger;
+ SUCCEED();
+}
</code_context>
<issue_to_address>
**issue (testing):** Logger tests don't cover appendRules or the DConfig-related destruction branch mentioned in the PR description.
The tests currently only cover `setRules` and a basic destruction path. To match the PR’s stated coverage, please: (1) add tests for `appendRules` that start with existing rules, append new ones, and assert the resulting rules are merged/overwritten as intended; and (2) add a test that forces the DConfig-specific destruction branch (using configuration stubs or a controlled environment) and verifies it completes without errors and performs the expected cleanup.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| // Just verify we can call rules() without crashing. | ||
| QString r = m_tester->rules(); | ||
| Q_UNUSED(r); | ||
| SUCCEED(); |
There was a problem hiding this comment.
issue (testing): Logger tests don't cover appendRules or the DConfig-related destruction branch mentioned in the PR description.
The tests currently only cover setRules and a basic destruction path. To match the PR’s stated coverage, please: (1) add tests for appendRules that start with existing rules, append new ones, and assert the resulting rules are merged/overwritten as intended; and (2) add a test that forces the DConfig-specific destruction branch (using configuration stubs or a controlled environment) and verifies it completes without errors and performs the expected cleanup.
352dafc to
d7e7dde
Compare
|
/retest |
4 similar comments
|
/retest |
|
/retest |
|
/retest |
|
/retest |
d7e7dde to
69f947a
Compare
New tests/uiframe/ut_sheetrenderer.cpp covers SheetRenderer public APIs under empty-document/invalid-index scenarios and handleOpened paths for getPageCount/getImage/pageHasLable. New tests/ut_logger.cpp covers MLogger setRules/appendRules merging and safe destruction (including the DConfig branch). Extended tests/uiframe/ut_doctabbar.cpp adds MIME data, tab close/ change/release/drop, throttle, and resizeEvent coverage. Extended tests/sidebar/ut_readerimagethreadpoolmanager.cpp adds ReadImageTask::run null-sheet path and singleton/slot coverage. 新增 ut_sheetrenderer.cpp,覆盖 SheetRenderer 公共接口在空文档与 无效索引下的行为,以及 handleOpened 后的页面查询路径。 新增 ut_logger.cpp,覆盖 MLogger setRules/appendRules 规则合并与 析构(含 DConfig 分支)安全退出。 扩充 ut_doctabbar.cpp,补充 createMimeDataFromTab、 insertFromMimeData*、onTabChanged、onTabCloseRequested 节流、 onTabReleased/onTabDroped 与 resizeEvent 等用例。 扩充 ut_readerimagethreadpoolmanager.cpp,补充 ReadImageTask::run 无 sheet 时的安全路径以及单例与槽函数用例。 Log: 新增 SheetRenderer/Logger 用例并扩充 DocTabBar/ThreadPool 测试 Influence: 单测从 812 增至 869,函数覆盖率从 77.8% 提升至 80.3%。
69f947a to
3a38bde
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 修复 ut_readerimagethreadpoolmanager.cpp 版权声明
-// Copyright (C) 2019-2026 ~ 2020 Uniontech Software Technology Co.,Ltd.
+// Copyright (C) 2019-2020 Uniontech Software Technology Co.,Ltd.
// 优化 ut_logger.cpp 中的断言逻辑
TEST_F(UT_MLogger, testSetRulesReplacesSemicolon)
{
m_tester->setRules(QString("a.b=true;c.d=false"));
- EXPECT_TRUE(m_tester->rules().contains(QString("a.b=true\n c.d=false")) ||
- m_tester->rules().contains(QString("a.b=true\nc.d=false")) ||
- m_tester->rules().contains(QString("a.b=true")));
+ // 假设 setRules 会将 ';' 替换为 '\n'
+ EXPECT_TRUE(m_tester->rules().contains(QString("a.b=true\nc.d=false")));
} |
|
[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 |
|
/merge |
新增 tests/uiframe/ut_sheetrenderer.cpp
新增 tests/ut_logger.cpp
扩充 tests/uiframe/ut_doctabbar.cpp
扩充 tests/sidebar/ut_readerimagethreadpoolmanager.cpp
测试总数从 812 提升到 869,全部通过;
reader 模块函数覆盖率从 77.8% 提升到 80.3%。
Summary by Sourcery
Add new unit tests for SheetRenderer and MLogger and expand existing DocTabBar and ReaderImageThreadPoolManager coverage to validate edge cases and safe behavior in empty, invalid, and throttled scenarios.
Tests: