Repository navigation
test(ut): add regression cases for 12 blocked PMS bugs without fix commits #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1344,3 +1344,74 @@ TEST_F(TextEditTest, BUG60989_UpdateFont_SelectAllInView_NoHang) | |
| EXPECT_TRUE(cur.hasSelection()); | ||
| EXPECT_LT(cur.selectionEnd() - cur.selectionStart(), edit->document()->characterCount()); | ||
| } | ||
|
|
||
| // PMS: https://pms.uniontech.com/bug-view-46081.html commit: N/A(批次4:git 历史无修复提交,按 PMS 复现步骤 + master d634cbad 代码语义锚定) | ||
| // 场景:alt+鼠标列选择模式下,复制/剪切/粘贴异常(列选区内容未按行拼接进入剪贴板)。 | ||
| // 锚定语义:TextEdit::copy(true) 的 m_bIsAltMod 分支将各列选区文本按 "\n" 拼接写入剪贴板; | ||
| // 文本保持不变、列选区保留(copy 不破坏选择状态)。 | ||
| TEST_F(TextEditTest, BUG46081_ColumnSelectionCopy_JoinsLines) | ||
| { | ||
| // Arrange: 三行各造一个列选区(每行前 2 字符),进入列编辑模式 | ||
| setDocText(QString("aa\nbb\ncc\n")); | ||
| QList<QTextEdit::ExtraSelection> sels; | ||
| for (int line = 0; line < 3; ++line) { | ||
| QTextCursor cur(edit->document()); | ||
| const int blockPos = edit->document()->findBlockByNumber(line).position(); | ||
| cur.setPosition(blockPos); | ||
| cur.setPosition(blockPos + 2, QTextCursor::KeepAnchor); | ||
| QTextEdit::ExtraSelection sel; | ||
| sel.cursor = cur; | ||
| sels << sel; | ||
| } | ||
| edit->restoreColumnEditSelection(sels); | ||
| edit->m_bIsAltMod = true; | ||
|
|
||
| // Act: 列复制(ignoreCheck=true 绕开权限校验,聚焦列分支) | ||
| edit->copy(true); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Column cut has no regression case When column-selection cut is broken while copy and paste continue to work, a defect limited to column-selection cut remains undetected because the new cases exercise Add a column-selection cut test that checks the clipboard contents and the resulting document text. Prompt for AI agentsIn `tests/editor_core/test_dtextedit_edit.cpp` at line 1370:
**Column cut has no regression case**
When column-selection cut is broken while copy and paste continue to work, a defect limited to column-selection cut remains undetected because the new cases exercise `copy(true)` and `paste()`, but never invoke cut or verify its text and clipboard effects. Add a column-cut case with assertions for both.
Add a column-selection cut test that checks the clipboard contents and the resulting document text. |
||
|
|
||
| // Assert: 剪贴板为各选区按行拼接;文本未被改动;列选区仍在 | ||
| EXPECT_EQ(QApplication::clipboard()->text(), QString("aa\nbb\ncc")); | ||
| EXPECT_EQ(edit->toPlainText(), QString("aa\nbb\ncc\n")); | ||
| EXPECT_EQ(edit->m_altModSelections.size(), 3); | ||
| EXPECT_TRUE(edit->m_bIsAltMod); | ||
| } | ||
|
|
||
| // PMS: https://pms.uniontech.com/bug-view-46081.html commit: N/A(批次4:无修复提交,按 PMS 步骤 + master 代码语义锚定) | ||
| // 场景:alt 列选择后粘贴,粘贴内容应作用于各列选区且可整体撤销。 | ||
| // 锚定语义:TextEdit::paste() 的 m_bIsAltMod 分支走 insertColumnEditTextEx → | ||
| // InsertTextUndoCommand(列路径):每个列选区替换为剪贴板文本(多选区共享同一插入文本, | ||
| // InsertTextUndoCommand::redo 列分支语义);undo_ 后完整还原文本与列选区。 | ||
| TEST_F(TextEditTest, BUG46081_ColumnPaste_ReplacesEachSelectionAndUndoRestores) | ||
| { | ||
| // Arrange: 三行各造列选区(每行首字符),剪贴板单行文本 | ||
| setDocText(QString("xx\nyy\nzz\n")); | ||
| QList<QTextEdit::ExtraSelection> sels; | ||
| for (int line = 0; line < 3; ++line) { | ||
| QTextCursor cur(edit->document()); | ||
| const int blockPos = edit->document()->findBlockByNumber(line).position(); | ||
| cur.setPosition(blockPos); | ||
| cur.setPosition(blockPos + 1, QTextCursor::KeepAnchor); | ||
| QTextEdit::ExtraSelection sel; | ||
| sel.cursor = cur; | ||
| sels << sel; | ||
| } | ||
| edit->restoreColumnEditSelection(sels); | ||
| edit->m_bIsAltMod = true; | ||
| QApplication::clipboard()->setText(QStringLiteral("1")); | ||
|
|
||
| // Act: 列粘贴 | ||
| edit->paste(); | ||
|
|
||
| // Assert: 每个选区被剪贴板文本替换 | ||
| EXPECT_EQ(edit->toPlainText(), QString("1x\n1y\n1z\n")); | ||
| EXPECT_EQ(edit->m_altModSelections.size(), 3); | ||
|
|
||
| // Act: 撤销整次列粘贴 | ||
| edit->undo_(); | ||
|
|
||
| // Assert: 文本与列选区完整还原(可逆) | ||
| EXPECT_EQ(edit->toPlainText(), QString("xx\nyy\nzz\n")); | ||
| ASSERT_EQ(edit->m_altModSelections.size(), 3); | ||
| EXPECT_EQ(edit->m_altModSelections.first().cursor.selectedText(), QString("x")); | ||
| EXPECT_EQ(edit->m_altModSelections.last().cursor.selectedText(), QString("z")); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High · Signal callback outlives its captures
When
sigChangeWindowSizeis emitted after the test returns, the context-less connection on the suite-wideSettings::instance()invokes a lambda that references the expiredlastModeandpokeslocals, causing use-after-scope and potentially corrupting memory or crashing the test process.Give the connection a test-scoped context or disconnect it before the captured locals leave scope.
Prompt for AI agents