aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-08-06 11:35:25 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-09 17:14:16 +0000
commite7204f4658f6dee169481657ccda17c115ab2c7c (patch)
tree9f163fe0af177ece157c499cce604f9ea7ba39ba /tests
parentdcce7e732d9182cd19d4fa8c3284762307f99ebd (diff)
SelectionRectangle: ensure we track correctly which handle is being dragged
As it stood, we would check if the user dragged on the top-left handle by checking which component was being used to instatiate the handle. This goes wrong if both the top-left and the bottom-right handle is instantiated from the same delegate component. This patch will make it explicit which handle is being instatiated instead. Fixes: QTBUG-95622 Change-Id: I592a99bf0e3daf0b566e07494aa2de69e010749d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 35f948a1add8a46d85c6383971e9ebff3e0dada7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_selectionrectangle.qml31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/quickcontrols2/controls/data/tst_selectionrectangle.qml b/tests/auto/quickcontrols2/controls/data/tst_selectionrectangle.qml
index 13ddf00f95..4e4a7e61c8 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_selectionrectangle.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_selectionrectangle.qml
@@ -285,7 +285,7 @@ TestCase {
}
}
- function test_handleDragBottomRight() {
+ function test_handleDragBottomRight_shrink() {
let tableView = createTemporaryObject(tableviewComp, testCase)
verify(tableView)
let selectionRectangle = tableView.selectionRectangle
@@ -308,4 +308,33 @@ TestCase {
compare(tableView.selectionModel.selectedIndexes.length, 1)
verify(tableView.selectionModel.isSelected(tableView.model.index(1, 1)))
}
+
+ function test_handleDragBottomRight_expand() {
+ let tableView = createTemporaryObject(tableviewComp, testCase)
+ verify(tableView)
+ let selectionRectangle = tableView.selectionRectangle
+ verify(selectionRectangle)
+
+ selectionRectangle.selectionMode = SelectionRectangle.Drag
+
+ verify(!tableView.selectionModel.hasSelection)
+ // Select four cells in the middle
+ mouseDrag(tableView, cellWidth + 1, cellHeight + 1, (cellWidth * 2) - 2, (cellHeight * 2) - 2, Qt.LeftButton)
+ compare(tableView.selectionModel.selectedIndexes.length, 4)
+ for (var x = 1; x < 3; ++x) {
+ for (var y = 1; y < 3; ++y) {
+ verify(tableView.selectionModel.isSelected(tableView.model.index(x, y)))
+ }
+ }
+
+ // Drag on the bottom right handle, so that the selection expands to cell 9 cells
+ mouseDrag(tableView, cellWidth * 3, cellHeight * 3, cellWidth * 4, cellHeight * 4, Qt.LeftButton)
+ compare(tableView.selectionModel.selectedIndexes.length, 9)
+ for (x = 1; x < 4; ++x) {
+ for (y = 1; y < 4; ++y) {
+ verify(tableView.selectionModel.isSelected(tableView.model.index(x, y)))
+ }
+ }
+ }
+
}