fix(tests): 修复 Qt6 下 12 个失败用例 - #297
Conversation
Reviewer's GuideThis PR updates several unit tests to be compatible with Qt6 and with recent behavior changes in the application, mainly by adjusting assertions, working around limitations in stubbing QList methods, and aligning theme/scale expectations with actual implementation. 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 left some high level feedback:
- The global variable name
g_dAnnotlsitappears to be misspelled; consider renaming it tog_dAnnotListfor clarity and consistency. - The Qt version conditionals around stubbing
QList::contains/DPdfPage::annotsare duplicated across multiple tests; consider extracting a small helper or macro to reduce repetition and make the Qt5/Qt6 behavior easier to follow. - In the
SheetBrowser::deformtests, the expectations onm_lastScaleFactornow mixEXPECT_GTandEXPECT_GE; it may be clearer to standardize on a single invariant (e.g., strictly positive or non-negative) across all related test cases.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The global variable name `g_dAnnotlsit` appears to be misspelled; consider renaming it to `g_dAnnotList` for clarity and consistency.
- The Qt version conditionals around stubbing `QList::contains`/`DPdfPage::annots` are duplicated across multiple tests; consider extracting a small helper or macro to reduce repetition and make the Qt5/Qt6 behavior easier to follow.
- In the `SheetBrowser::deform` tests, the expectations on `m_lastScaleFactor` now mix `EXPECT_GT` and `EXPECT_GE`; it may be clearer to standardize on a single invariant (e.g., strictly positive or non-negative) across all related test cases.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
4a3ba49 to
2f66a74
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // tests/document/ut_pdfmodel.cpp
// 修正全局变量命名,并确保异常安全清理
static QList<DPdfAnnot *> g_dAnnotList; // 修正拼写
QList<DPdfAnnot *> annots_stub()
{
if (!g_dAnnotList.isEmpty())
return g_dAnnotList;
QList<DPdfAnnot *> dannots;
g_textAnnots = new DPdfTextAnnot();
dannots.append(g_textAnnots);
// ...
return dannots;
}
TEST_F(TestPDFPage, UT_PDFPage_updateAnnotation_001)
{
// ...
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
g_dAnnotList.append(dAnnot);
s.set(ADDR(DPdfPage, annots), annots_stub);
#endif
EXPECT_TRUE(m_tester->updateAnnotation(annotation, text, color));
EXPECT_TRUE(g_funcName == "updateTextAnnot_stub");
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
g_dAnnotList.removeAll(dAnnot);
#endif
// ...
} |
SheetBrowser::deform (testdeform001-007): source added safeMaxWidth/safeMaxHeight anti-div-by-zero guard, scaleFactor no longer equals 1.0; relaxed strict-equal asserts to EXPECT_GT/GE. PDFPage::updateAnnotation: QList::contains cannot be stubbed on Qt6, so stub DPdfPage::annots() with a global g_dAnnotlsit list instead. PDFDocument::saveFilter: source value changed from "Portable document format (*.pdf)" to "Pdf Files (*.pdf)". BaseWidget/TipsWidget theme: source sets DPalette::Window only. ScaleMenu::onScaleFactor: indexOf stub fails on Qt6, emit triggered() on the first action to drive the real signal chain. SheetBrowser::deform 用例(testdeform001-007):源码引入 safeMaxWidth/safeMaxHeight 防除零保护后 scaleFactor 不再恒为 1.0,将严格相等断言改为 EXPECT_GT/GE。 PDFPage::updateAnnotation 用例:Qt6 下 QList::contains 无法 stub, 改为 stub DPdfPage::annots() 配合全局 g_dAnnotlsit 命中。 PDFDocument::saveFilter 用例:源码返回值由 "Portable document format (*.pdf)" 改为 "Pdf Files (*.pdf)"。 BaseWidget/TipsWidget 主题色用例:源码只设置 DPalette::Window。 ScaleMenu::onScaleFactor 用例:Qt6 下 indexOf stub 失效,改用 emit triggered() 触发真实信号链让 sender() 返回有效 QAction。 Log: 修复 Qt6 下 12 个失败用例 Influence: 单测全量通过,CI 不再误报这 12 项用例失败。
2f66a74 to
f17e43b
Compare
|
[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 |
SheetBrowser::deform 用例 (testdeform001-007)
PDFPage::updateAnnotation 用例
PDFDocument::saveFilter 用例
BaseWidget/TipsWidget 主题色用例
ScaleMenu::onScaleFactor 用例
Summary by Sourcery
Adjust tests to pass under Qt6 by updating Qt version-specific stubs and expectations.
Bug Fixes: