test(editor,widgets): extend TextEdit and Window tests, fix crashes - #500
Conversation
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
3365311 to
6c8213a
Compare
Reviewer's GuideExtends TextEdit, Window, BottomBar, DDropdownMenu, ColorSelectWdg, and EditorApplication tests to cover previously-uncovered functions and UI-connected lambdas, adds undo/redo stubs to many TextEdit tests to avoid crashes, removes obsolete/commented tests, and introduces targeted stubs and event filters to prevent SEGVs and flaky behaviour during bulk test runs. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
e6758e8 to
dfe267c
Compare
Add stub for slotCanRedoChanged to 134 test locations preventing SEGV. Remove QTest::qWait calls that process stale queued events. Log: 扩充TextEdit和Window测试,修复批量测试崩溃 Influence: 提升函数覆盖率至98.7%,消除全量测试SEGV崩溃
dfe267c to
cd244be
Compare
deepin pr auto review★ 总体评分:40分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // tests/src/editor/ut_textedit.cpp
// 移除危险的 forceGestureState 函数,改用事件驱动或 Mock 方式
// 如果 QTapGesture 无法直接设置状态,可以通过发送底层事件来触发状态改变
namespace uncovered_helpers {
static TextEdit *makeEditorInWindow(Window *&win)
{
win = new Window();
win->addBlankTab(QString());
return win->currentWrapper()->textEditor();
}
// 安全的手势状态触发方式示例(具体实现取决于被测代码对手势状态的消费逻辑)
// 如果必须测试特定状态,建议使用 gmock 等框架 mock QGesture
} // namespace uncovered_helpers
// 在测试用例中,避免使用 forceGestureState
TEST(UT_Textedit_Uncovered, tapGestureTriggered)
{
Window *win = nullptr;
TextEdit *edit = makeEditorInWindow(win);
// 创建手势对象并正常触发,不强制修改内部状态
QTapGesture *tap = new QTapGesture;
// 假设可以通过其他方式触发状态更新,或仅测试默认状态下的行为
edit->tapGestureTriggered(tap);
delete tap;
win->deleteLater();
}
// 针对 UT_DeferredDeleteBlocker 的优化建议
class UT_DeferredDeleteBlocker : public QObject
{
public:
bool eventFilter(QObject *, QEvent *e) override
{
return e->type() == QEvent::DeferredDelete;
}
};
// 在测试用例中确保安装和移除配对
TEST(UT_Window_updateSizeMode, updateSizeMode_FindBarVisible)
{
Window *w = new Window();
UT_DeferredDeleteBlocker blocker;
qApp->installEventFilter(&blocker); // 安装
w->show();
w->addBlankTab();
w->currentWrapper()->textEditor()->setPlainText("hello world");
w->popupFindBar();
w->updateSizeMode();
qApp->removeEventFilter(&blocker); // 确保移除
w->deleteLater();
} |
|
@pengfeixx: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
[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 |
Add stub for slotCanRedoChanged to 134 test locations preventing SEGV. Remove QTest::qWait calls that process stale queued events.
Log: 扩充TextEdit和Window测试,修复批量测试崩溃
Influence: 提升函数覆盖率至98.7%,消除全量测试SEGV崩溃
Summary by Sourcery
Increase test coverage for TextEdit, Window, and several widget components while addressing crashes caused by missing redo stubs and unsafe event processing in bulk runs.
Bug Fixes:
Enhancements:
Tests: