aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-02-25 15:25:35 +0100
committerMitch Curtis <mitch.curtis@qt.io>2020-03-13 10:59:11 +0100
commit8a442c3b7709424c768a99b304bdbdbac81f8011 (patch)
tree7cc92a2b8af719cb4a8137baecbfe10d5ae498d3 /tests
parent6cdd4b53031de17b36b30b00de0a6945470a35ad (diff)
SplitView: fix hidden items causing visible items to not be resizable
When a handle is dragged, the items on either side of it are resized. Until this patch, we were assuming that the item after the one at the handle index was visible, which was wrong. Now we iterate through each item after the one at the pressed index until we find one that's visible. Since we need this in a few other places during a handle drag, we cache it as a member variable. This patch also fixes an issue where the visibility of handles were not updated after setting a new handle delegate. Change-Id: Icd246abae2ed4dc6c3b81217b9a241b7e4debf7d Fixes: QTBUG-81867 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_splitview.qml70
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/auto/controls/data/tst_splitview.qml b/tests/auto/controls/data/tst_splitview.qml
index 74e4c68e..ae8179b2 100644
--- a/tests/auto/controls/data/tst_splitview.qml
+++ b/tests/auto/controls/data/tst_splitview.qml
@@ -148,6 +148,7 @@ TestCase {
color: "#444"
Text {
+ objectName: "handleText_" + text
text: parent.x + "," + parent.y + " " + parent.width + "x" + parent.height
color: "white"
anchors.centerIn: parent
@@ -871,6 +872,42 @@ TestCase {
}
}
+ Component {
+ id: hiddenItemSplitViewComponent
+
+ SplitView {
+ anchors.fill: parent
+ handle: handleComponent
+
+ Rectangle {
+ objectName: "steelblue"
+ color: objectName
+
+ SplitView.minimumWidth: 50
+ }
+ Rectangle {
+ objectName: "tomato"
+ color: objectName
+
+ SplitView.fillWidth: true
+ SplitView.preferredWidth: 200
+ }
+ Rectangle {
+ objectName: "navajowhite"
+ color: objectName
+ visible: false
+
+ SplitView.minimumWidth: visible ? 100 : 0
+ }
+ Rectangle {
+ objectName: "mediumseagreen"
+ color: objectName
+
+ SplitView.minimumWidth: 50
+ }
+ }
+ }
+
function test_dragHandle_data() {
var splitViewWidth = testCase.width - splitViewMargins * 2
var splitViewHeight = testCase.height - splitViewMargins * 2
@@ -1151,6 +1188,36 @@ TestCase {
{ x: 140, y: 0, width: defaultHorizontalHandleWidth, height: splitViewHeight },
{ x: 150, y: 0, width: 150, height: splitViewHeight }
]
+ },
+ {
+ tag: "hiddenItemSplitViewComponent",
+ // [50] | [200 (fill)] | [hidden] | [50]
+ component: hiddenItemSplitViewComponent,
+ orientation: Qt.Horizontal,
+ fillIndex: 1,
+ handleIndex: 1,
+ // Drag to the horizontal centre of the SplitView.
+ newHandlePos: Qt.point(splitViewMargins + 150, testCase.height / 2),
+ expectedGeometriesBeforeDrag: [
+ { x: 0, y: 0, width: 50, height: splitViewHeight },
+ { x: 50, y: 0, width: defaultHorizontalHandleWidth, height: splitViewHeight },
+ { x: 50 + defaultHorizontalHandleWidth, y: 0, width: 200 - defaultHorizontalHandleWidth * 2, height: splitViewHeight },
+ { x: 250 - (defaultHorizontalHandleWidth * 2) + defaultHorizontalHandleWidth, y: 0, width: defaultHorizontalHandleWidth, height: splitViewHeight },
+ { hidden: true }, // Third item should be hidden.
+ { hidden: true }, // Handle for third item should be hidden.
+ { x: 250 - (defaultHorizontalHandleWidth * 2) + defaultHorizontalHandleWidth * 2, y: 0, width: 50, height: splitViewHeight }
+ ],
+ expectedGeometriesAfterDrag: [
+ { x: 0, y: 0, width: 50, height: splitViewHeight },
+ { x: 50, y: 0, width: defaultHorizontalHandleWidth, height: splitViewHeight },
+ // Width of the fill item should end up smaller.
+ { x: 50 + defaultHorizontalHandleWidth, y: 0, width: 100 - defaultHorizontalHandleWidth * 2, height: splitViewHeight },
+ { x: 150 - (defaultHorizontalHandleWidth * 2) + defaultHorizontalHandleWidth, y: 0, width: defaultHorizontalHandleWidth, height: splitViewHeight },
+ { hidden: true }, // Third item should be hidden.
+ { hidden: true }, // Handle for third item should be hidden.
+ // Width of the last item should grow.
+ { x: 150 - (defaultHorizontalHandleWidth * 2) + defaultHorizontalHandleWidth * 2, y: 0, width: 150, height: splitViewHeight }
+ ]
}
]
return data
@@ -1171,7 +1238,7 @@ TestCase {
else
fillItem.SplitView.fillHeight = true
- // Check the sizes of the items before the drag.
+ // Check the sizes (and visibility) of the items before the drag.
verify(isPolishScheduled(control))
verify(waitForItemPolished(control))
compareSizes(control, data.expectedGeometriesBeforeDrag, "before drag")
@@ -1179,6 +1246,7 @@ TestCase {
// Drag the handle.
var handles = findHandles(control)
var targetHandle = handles[data.handleIndex]
+ verify(targetHandle.visible)
mousePress(targetHandle)
verify(control.resizing)
// newHandlePos is in scene coordinates, so map it to coordinates local to the handle.