Fix SelectionRectangle tests

- Press-and-hold needs a release after the press.
- Doing press-and-hold at 1,1 selects the top-left cell; at that time if
  we click at 1,1 again in an effort to get rid of the selection, we're
  actually clicking on a selection handle. Let's click outside instead.

Amends c52710c10c

Change-Id: If5d459c063d2e2e1aa27a3bf0e13e8515607e701
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 5b63e2a426)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 1bc4315eaf)
This commit is contained in:
Shawn Rutledge 2023-11-15 21:33:35 -07:00
parent f7c656af68
commit 98ab3cef46
1 changed files with 3 additions and 3 deletions

View File

@ -278,7 +278,7 @@ TestCase {
// Ensure that a press and hold doesn't start a selection // Ensure that a press and hold doesn't start a selection
mousePress(tableView, 1, 1, Qt.LeftButton) mousePress(tableView, 1, 1, Qt.LeftButton)
mousePress(tableView, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000) mouseRelease(tableView, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000)
verify(!tableView.selectionModel.hasSelection) verify(!tableView.selectionModel.hasSelection)
} }
@ -417,7 +417,7 @@ TestCase {
verify(!tableView.selectionModel.hasSelection) verify(!tableView.selectionModel.hasSelection)
// Do a press and hold // Do a press and hold
mousePress(tableView, 1, 1, Qt.LeftButton) mousePress(tableView, 1, 1, Qt.LeftButton)
mousePress(tableView, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000) mouseRelease(tableView, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000)
verify(tableView.selectionModel.hasSelection) verify(tableView.selectionModel.hasSelection)
compare(tableView.selectionModel.selectedIndexes.length, 1) compare(tableView.selectionModel.selectedIndexes.length, 1)
verify(tableView.selectionModel.isSelected(tableView.model.index(0, 0))) verify(tableView.selectionModel.isSelected(tableView.model.index(0, 0)))
@ -426,7 +426,7 @@ TestCase {
compare(activeSpy.count, 1) compare(activeSpy.count, 1)
// Remove selection // Remove selection
mouseClick(tableView, 1, 1, Qt.LeftButton) mouseClick(tableView, 100, 100, Qt.LeftButton)
verify(!tableView.selectionModel.hasSelection) verify(!tableView.selectionModel.hasSelection)
compare(draggingSpy.count, 0) compare(draggingSpy.count, 0)
compare(activeSpy.count, 2) compare(activeSpy.count, 2)