Repository navigation
test(Widget): rewrite unit tests for 5 Widget table/delegate classes (108 cases) - #911
Conversation
Generated by qt-autotest-generator skill. Task 19 batch 1/5: TableWidget. Rewrite ut_tablewidget_extra.cpp (6 hollow NO_FATAL cases -> 27): slotShowMenu white-box branch map B1-B12 covering all menu-state combinations (row selection, device enabled, driver flags), menu item add/remove and enable/disable assertions; network wakeup 3-state (none/open/close) via TEST_P with real temp-file /proc/acpi/wakeup sources; slotAction* verified with QSignalSpy signal and argument assertions. Strengthen ut_tablewidget.cpp (6 cases): data methods setHeaderLabels/setItem/clear/updateCurItemEnable assert real table state instead of smoke checks. Normalize the copyright header to the standard 2019-2026 UnionTech form. 33 cases total (6 + 27), all passing under QT_QPA_PLATFORM= offscreen. Baseline: upstream/master @ f2d46ee, rebased onto f4d271c; TableWidget.cpp unchanged since baseline. Log: rewrite TableWidget unit tests, task 19 batch 1/5 Influence: test code only, no production code change
Generated by qt-autotest-generator skill. Task 19 batch 2/5: RichTextDelegate. Rewrite ut_richtextdelegate.cpp (5 -> 16 cases): paint branch map P1-P6 (invalid index falls back to base painter, palette group, alternate row, first/middle/bottom row rounded-rect corner fill, multi-line text via getDocFromLst + setRowHeight counter stub) rendered to QImage with non-white-pixel assertions; sizeHint minimum height 40 / width 150 branches; addRow recursive "a/b/c" segment split; getDocFromLst invalid-pair early return; QDomDocument table structure assertions. Normalize the copyright header to the standard 2019-2026 UnionTech form. 16 cases, all passing. Baseline: upstream/master @ f2d46ee, rebased onto f4d271c; RichTextDelegate.cpp unchanged. Log: strengthen RichTextDelegate unit tests, task 19 batch 2/5 Influence: test code only, no production code change
Generated by qt-autotest-generator skill. Task 19 batch 3/5: DetailViewDelegate. Append 12 cases to ut_detailviewdelegate.cpp (6 -> 18): paint branches for first/middle/last visual rows, more-button row (index.row()==rowCount()-1 gated by hasExpendInfo stub), device status text 3-branch matrix (enabled/unavailable/disabled) with #FF5736 red-pixel scan for disabled devices, sizeHint branches with/without index data, createEditor returning nullptr. Normalize the copyright header to the standard 2019-2026 UnionTech form. 18 cases, all passing. Baseline: upstream/master @ f2d46ee, rebased onto f4d271c; DetailViewDelegate.cpp unchanged. Log: strengthen DetailViewDelegate unit tests, task 19 batch 3/5 Influence: test code only, no production code change
Generated by qt-autotest-generator skill. Task 19 batch 4/5: DriverScanWidget. Rewrite ut_driverscanwidget.cpp (6 hollow NO_FATAL cases -> 11): constructor scrollbar policy and objectName state, setScanningUI progress value and label updates, setScanFailedUI/setNetworkErr control visibility, setProgressFinish clamps to 100, RefreshProgress delta semantics, hideAll hides every control, slotFeedBack stubbed CommonTools::feedback counter, slotReDetected re-enters scan UI and emits redetected() (QSignalSpy) plus progress reset, paintEvent, resizeEvent hides scrollbar. 11 cases, all passing. Baseline: upstream/master @ f2d46ee, rebased onto f4d271c; DriverScanWidget.cpp unchanged. Log: rewrite DriverScanWidget unit tests, task 19 batch 4/5 Influence: test code only, no production code change
Generated by qt-autotest-generator skill. Task 19 batch 5/5: driveritem family. Mode 6 review kept the existing 30 cases across DriverCheckItem, DriverNameItem, DriverLabelItem, DriverOperationItem and DriverStatusItem (checked/isEnabled/setName/setStatus assertions are real state checks, not hollow). Fix the single tautology EXPECT_EQ(rect().width(), rect().width()) in the DriverCheckItem paintEvent case, replaced with grab() render validity plus rect validity assertions. Normalize the copyright header to the standard 2019-2026 UnionTech form. 30 cases, all passing. Baseline: upstream/master @ f2d46ee, rebased onto f4d271c; driveritem.cpp unchanged. Log: fix tautological assertion in driveritem tests, batch 5/5 Influence: test code only, no production code change
|
Warning
详情 {
"export": {
"deepin-devicemanager/tests/src/Widget/ut_tablewidget.cpp": {
"b": [
" QSignalSpy spyExport(m_tableWidget, &TableWidget::exportInfo);"
]
},
"deepin-devicemanager/tests/src/Widget/ut_tablewidget_extra.cpp": {
"b": [
" QSignalSpy spy(t, &TableWidget::exportInfo);"
]
}
}
} |
Reviewer's GuideThe PR rewrites six Widget test sources from largely non-fatal smoke checks into 108 focused, dependency-isolated GTest cases covering state transitions, signals, rendering paths, data transformations, and white-box branches across five Widget table/delegate classes; it changes no production code. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改,语法逻辑完全正确。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议在 ut_detailviewdelegate.cpp 中抽取类似 preparePaintDelegate(columnCount, items) 的辅助方法,减少 paint 测试中的重复 setup 代码。', 'slotShowMenu 用例可统一在辅助方法中返回 Stub 指针,减少 Q_UNUSED 样板。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无需修改,性能表现良好。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无需修改,安全合规。'] 💡 改进建议代码示例// 建议优化:ut_detailviewdelegate.cpp 抽取 paint 测试 setup 辅助方法
// 减少重复样板代码
void preparePaintDelegate(int columnCount, const QStringList &items)
{
m_stub.set(ADDR(DApplication, style), DetailViewDelegate_UT_style_fun);
m_treeView->setColumnCount(columnCount);
m_treeView->insertRow(0);
for (int col = 0; col < items.size() && col < columnCount; ++col) {
m_treeView->setItem(0, col, new QTableWidgetItem(items[col]));
}
}
// 使用示例:
// TEST_F(UT_DetailViewDelegate, Paint_FirstRowColumn0_CornerFill)
// {
// preparePaintDelegate(2, {"key", ""});
// QImage img = ut_detailRender(this, m_treeView->model()->index(0, 0), QRect(0, 0, 220, 50));
// EXPECT_GT(ut_nonWhitePixels(img), 0);
// }本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Summary
Rewrite/strengthen the unit tests for the 5
src/Widget/classes selected byfunction-importance analysis (task 19: Widget tables & delegates), replacing
hollow NO_FATAL smoke cases with 108 focused GTest cases:
ut_tablewidget+ut_tablewidget_extraut_richtextdelegateut_detailviewdelegateut_driverscanwidgetut_driveritem(5 fixtures)What's included
tests/src/Widget/(test code only, one commit perclass batch); no production code, no scripts, no framework tooling.
// Copyright (C) 2019-2026 UnionTech Software Technology Co.,Ltdform(follow-up to f4d271c, which missed these files).
Testing
CommonTools::feedback, DetailTreeView state) are stubbed; the suite runs
offscreen with zero hardware dependency.
f4d271cb; the full test target builds and afiltered run of the touched suites passes 108/108 with exit code 0.
(high 95.5% / mid 97.1% / low 98.8%).
Note for reviewers
Two suspected source defects were found during test design and reported
separately (not fixed in this PR):
RichTextDelegate::paint(src/Widget/RichTextDelegate.cpp:165): uncheckeddynamic_cast<PageSingleInfo*>(parent())on the multi-line branch - nullptrderef when the delegate's parent is PageTableWidget.
DriverScanWidget::hideAll(src/Widget/DriverScanWidget.cpp:305): rebuilds6 layout members without deleting the old ones - leak on repeated
scan/failed/network-error state switches.
Summary by Sourcery
Rewrite the Widget table and delegate unit tests to provide comprehensive, dependency-isolated behavioral coverage.
Enhancements:
Tests:
Chores: