Repository navigation
test: add unit tests for PageDriverManager, PageDriverControl and PageDriverTableView - #912
Conversation
- Rewrite hollow-assertion cases: ctor/dtor, initWidgets layout, resizeEvent, installDriverLogical, closeEvent, slotClose, isRunning, slotBtnNext and more (26 cases) - Stub all external deps (DBus/network/dialogs), no real device needed - Normalize copyright header to the unified single form
- 63 cases in 4 files covering ctor/updateListView/addDriverInfo/ isFirstScan/index ops/installNextDriver/backupNextDriver/ slotScanFinished/slotBackupFinished/slotUndoInstall/ slotDownloadProgressChanged/getDebBackupInfo/getDownloadInfo/ scanDriverInfo/scanDevices/networkIsOnline - Replace mock thread swap with QThread::start count stubs; virtual dialog exec via MockFailedDialog subclass (ut_mock_thread.h) - Stub DetectedStatusWidget head-widget UI to avoid layout accumulation crash under offscreen
- 14 cases covering ctor/initWidgets/resizeEvent/resizeColumnWidth - Drive resizeEvent via setGeometry + QApplication::sendEvent since hidden top-level widgets skip resize dispatch - Build model columns before setColumnWidth (no-op without columns)
Reviewer's GuideRewrites the Page-module unit tests into 104 deterministic, assertion-driven Google Test cases for PageDriverManager, PageDriverControl, and PageDriverTableView, using extensive dependency stubbing and Qt offscreen fixtures to cover normal, boundary, error, UI, signal, and asynchronous-operation paths without changing production code. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
- ut_pagedrivermanager.cpp: 2019-2026 (base header year 2019) - misc/slot/slot2/tableview: 2026 (single year for this-year files) - Matches zccrs/github-actions-spdx-checker expectations on CI
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改,语法逻辑正确。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议将 makeInfo 抽取到共享头文件(如 ut_driverinfo_helper.h)中,供所有 PageDriverManager 测试文件复用,减少维护成本'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无需修改,性能表现合理。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无需修改,无安全风险。'] 💡 改进建议代码示例// 建议将重复的 makeInfo 抽取为共享工具函数 // 文件: tests/src/Page/ut_driverinfo_helper.h // // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later // #ifndef UT_DRIVERINFO_HELPER_H #define UT_DRIVERINFO_HELPER_H #include "DriverInfo.h" static DriverInfo *ut_makeInfo(const QString &name, const QString &packages,
const QString &debVersion, const QString &version,
Status status)
{
DriverInfo *info = new DriverInfo();
info->m_Name = name;
info->m_Packages = packages;
info->m_DebVersion = debVersion;
info->m_Version = version;
info->m_Size = "23.2";
info->m_Byte = 1048576;
info->m_Status = status;
return info;
} #endif // UT_DRIVERINFO_HELPER_H本报告由 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 Google Test unit tests for three Page-module classes, per function-importance inventory (82 methods) with a W(write) → R(review) → B(defect report) closed loop.
QT_QPA_PLATFORM=offscreen).Coverage (target files only, lcov)
Inventory-weighted: line 76.4% / function 95.1% over 82 testable methods.
Suspected source defects found while testing (reported, not fixed)
7 items (5 high / 2 mid), including:
networkIsOnline()Qt6 branch inverted condition (PageDriverManager.cpp:1071),removeAt(indexOf(...))without -1 guard (PageDriverManager.cpp:371), null-pointer deref ofmp_HeaderCb(drivertableview.cpp:518), 1000s blocking DBussetTimeout(DBusDriverInterface.cpp:37/71/101), layout use-after-free risk in~DetectedStatusWidget, re-entrantrefreshInfoon close, and a dead objectName check inisRunning. Details tracked in the task issue attachments.Test plan
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COVERAGE_ARG=CMAKE_COVERAGE_ARG_ON -DQT_VERSION_MAJOR=6 -DDTK_VERSION_MAJOR=6QT_QPA_PLATFORM=offscreen ctest/gtest binary, filterUT_PageDriverManager*:UT_PageDriverControl*:UT_PageDriverTableView*→ 104 passed, 0 failedSummary by Sourcery
Strengthen Page-module regression coverage with deterministic unit tests for driver management workflows, control dialogs, and table-view behavior.
Enhancements:
Tests: