aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_scrollview.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/controls/data/tst_scrollview.qml')
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index 87c39509..0e8b0835 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -71,6 +71,11 @@ TestCase {
}
Component {
+ id: scrollBarComponent
+ ScrollBar {}
+ }
+
+ Component {
id: scrollableLabel
ScrollView {
Label {
@@ -188,6 +193,15 @@ TestCase {
}
}
}
+ Component {
+ id: scrollableTextAreaWithSibling
+ ScrollView {
+ Item {
+ }
+ TextArea {
+ }
+ }
+ }
function test_scrollBars() {
var control = createTemporaryObject(scrollView, testCase, {width: 200, height: 200})
@@ -502,4 +516,64 @@ TestCase {
compare(control.contentWidth, flickable.contentWidth)
compare(control.contentHeight, flickable.contentHeight)
}
+
+ function test_textAreaWithSibling() {
+ // Checks that it does not crash when the ScrollView is deleted
+ var control = createTemporaryObject(scrollableTextAreaWithSibling, testCase)
+ verify(control)
+ }
+
+ Component {
+ id: zeroSizedContentItemComponent
+ ScrollView {
+ width: 100
+ height: 100
+ contentItem: Item {}
+ }
+ }
+
+ function test_zeroSizedContentItem() {
+ ignoreWarning(/ScrollView only supports Flickable types as its contentItem/)
+ let control = createTemporaryObject(zeroSizedContentItemComponent, testCase)
+ verify(control)
+
+ let verticalScrollBar = control.ScrollBar.vertical
+ verify(verticalScrollBar)
+ // Scrolling a ScrollView with a zero-sized contentItem shouldn't crash.
+ mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
+
+ let horizontalScrollBar = control.ScrollBar.horizontal
+ verify(verticalScrollBar)
+ mouseDrag(horizontalScrollBar, horizontalScrollBar.width / 2, horizontalScrollBar.height / 2, 50, 0)
+ }
+
+ function test_customScrollBars() {
+ let control = createTemporaryObject(scrollView, testCase)
+ verify(control)
+ control.ScrollBar.vertical.objectName = "oldVerticalScrollBar"
+ control.ScrollBar.horizontal.objectName = "oldHorizontalScrollBar"
+
+ let oldVerticalScrollBar = control.ScrollBar.vertical
+ verify(oldVerticalScrollBar)
+ compare(oldVerticalScrollBar.objectName, "oldVerticalScrollBar")
+
+ let oldHorizontalScrollBar = control.ScrollBar.horizontal
+ verify(oldHorizontalScrollBar)
+ compare(oldHorizontalScrollBar.objectName, "oldHorizontalScrollBar")
+
+ // Create the new scroll bars imperatively so that we can easily access the old ones.
+ control.ScrollBar.vertical = scrollBarComponent.createObject(control, { objectName: "newVerticalScrollBar" })
+ verify(control.ScrollBar.vertical)
+ let newVerticalScrollBar = findChild(control, "newVerticalScrollBar")
+ verify(newVerticalScrollBar)
+ verify(newVerticalScrollBar.visible)
+ verify(!oldVerticalScrollBar.visible)
+
+ control.ScrollBar.horizontal = scrollBarComponent.createObject(control, { objectName: "newHorizontalScrollBar" })
+ verify(control.ScrollBar.horizontal)
+ let newHorizontalScrollBar = findChild(control, "newHorizontalScrollBar")
+ verify(newHorizontalScrollBar)
+ verify(newHorizontalScrollBar.visible)
+ verify(!oldHorizontalScrollBar.visible)
+ }
}