Merge lp:~faenil/ubuntu-ui-toolkit/scrollbar_defaultTopBottomMargins into lp:ubuntu-ui-toolkit/staging

Proposed by Andrea Bernabei
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 1907
Merged at revision: 1910
Proposed branch: lp:~faenil/ubuntu-ui-toolkit/scrollbar_defaultTopBottomMargins
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 512 lines (+393/-15)
5 files modified
examples/ubuntu-ui-toolkit-gallery/Template.qml (+1/-4)
src/Ubuntu/Components/1.3/ScrollView.qml (+7/-0)
src/Ubuntu/Components/1.3/Scrollbar.qml (+48/-10)
tests/unit_x11/tst_components/tst_scrollbar.qml (+26/-1)
tests/unit_x11/tst_components/tst_scrollbar_header.qml (+311/-0)
To merge this branch: bzr merge lp:~faenil/ubuntu-ui-toolkit/scrollbar_defaultTopBottomMargins
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+289946@code.launchpad.net

Commit message

Change Scrollbar default top and bottom anchor margins. Tests included.

Description of the change

With this MR Scrollbar will default to using Flickable.topMargin and Flickable.bottomMargin (which are CONTENT margins, not anchor ones) as top/bottom ANCHORS margins.

This is to workaround the fact that Header and BottomEdgeHint modify Flickable.topMargin/bottomMargin in order to make space for themselves.

The solution was brainstormed with timp, zsombi, kalikiana.
If the developer wants to have custom Flickable top/bottomMargin (content margins), he will have to also modify Scrollbar margins.
This usecase will be addressed by a future MR, as the solution is still being brainstormed.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Great fix, nice tests, that's my boy :)

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/ubuntu-ui-toolkit-gallery/Template.qml'
--- examples/ubuntu-ui-toolkit-gallery/Template.qml 2016-01-13 16:14:08 +0000
+++ examples/ubuntu-ui-toolkit-gallery/Template.qml 2016-03-24 10:43:42 +0000
@@ -34,19 +34,16 @@
34 }34 }
3535
36 ScrollView {36 ScrollView {
37 //anchors.fill: parent
38 //anchors.topMargin: template.header.flickable ? 0 : template.header.height
39 objectName: "TemplateScrollView"37 objectName: "TemplateScrollView"
40 anchors {38 anchors {
41 fill: parent39 fill: parent
42 topMargin: template.header.flickable ? 0 : template.header.height40 topMargin: template.header.flickable ? 0 : template.header.height
43 }41 }
42
44 Flickable {43 Flickable {
45 id: templateFlickable44 id: templateFlickable
46 objectName: "TemplateFlickable"45 objectName: "TemplateFlickable"
47 anchors.fill: parent46 anchors.fill: parent
48 topMargin: units.gu(2)
49 bottomMargin: units.gu(2)
50 contentHeight: column.height47 contentHeight: column.height
51 interactive: contentHeight > height48 interactive: contentHeight > height
52 Column {49 Column {
5350
=== modified file 'src/Ubuntu/Components/1.3/ScrollView.qml'
--- src/Ubuntu/Components/1.3/ScrollView.qml 2016-02-18 12:39:14 +0000
+++ src/Ubuntu/Components/1.3/ScrollView.qml 2016-03-24 10:43:42 +0000
@@ -30,6 +30,13 @@
30 migrate to ScrollView, to ensure the UX is ready for convergent devices and is consistent with the30 migrate to ScrollView, to ensure the UX is ready for convergent devices and is consistent with the
31 rest of the platform.31 rest of the platform.
3232
33 ScrollView wraps \l {Scrollbar}(s) in a view, and provides additional features such as:
34 \list
35 \li - Keyboard navigation and focus handling, for a complete convergent experience.
36 \li - Automatic position handling of vertical and horizontal scrollbars, preventing them from
37 overlapping one another when both on screen.
38 \endlist
39
33 Adding scrollbars and keyboard input handling to a QML item is as simple as wrapping that item in a40 Adding scrollbars and keyboard input handling to a QML item is as simple as wrapping that item in a
34 ScrollView, as shown in the following example:41 ScrollView, as shown in the following example:
3542
3643
=== modified file 'src/Ubuntu/Components/1.3/Scrollbar.qml'
--- src/Ubuntu/Components/1.3/Scrollbar.qml 2016-02-25 12:59:27 +0000
+++ src/Ubuntu/Components/1.3/Scrollbar.qml 2016-03-24 10:43:42 +0000
@@ -18,14 +18,19 @@
18import Ubuntu.Components 1.3 as Toolkit18import Ubuntu.Components 1.3 as Toolkit
1919
20/*!20/*!
21 \qmltype ScrollBar21 \qmltype Scrollbar
22 \inqmlmodule Ubuntu.Components 1.122 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu23 \ingroup ubuntu
24 \brief The ScrollBar component provides scrolling functionality for24 \brief The Scrollbar component provides scrolling functionality for
25 scrollable views (i.e. Flickable, ListView).25 scrollable views (i.e. Flickable, ListView).
2626
27 The ScrollBar can be set to any flickable and has built-in anchoring setup27 \b NOTE: the Scrollbar component was revamped for OTA9 and used for the implementation
28 to the attached flickable's front, rear, top or bottom. the scrollbar can28 of \l ScrollView. Apps targeting system version OTA9 (or newer) should use ScrollView instead
29 of Scrollbar, as it features convergent-ready features, such as (but not limited to)
30 keyboard input handling.
31
32 The Scrollbar can be set to any flickable and has built-in anchoring setup
33 to the attached flickable's front, rear, top or bottom. The scrollbar can
29 also be aligned using anchors, however the built-in align functionality34 also be aligned using anchors, however the built-in align functionality
30 makes sure to have the proper alignemt applied based on theme and layout35 makes sure to have the proper alignemt applied based on theme and layout
31 direction (RTL or LTR).36 direction (RTL or LTR).
@@ -57,6 +62,43 @@
57 }62 }
58 }63 }
59 \endqml64 \endqml
65
66 \section1 Vertical Scrollbar and Flickable behaviour
67
68 Since Flickable's topMargin and bottomMargin are modified by Ubuntu components
69 such as \l BottomEdgeHint and \l Header in their positioning logic, the Scrollbar component
70 uses the value of those properties to its top and bottom anchors margins, by default. This is
71 to prevent any overlap with BottomEdgeHint or Header (see \l {Vertical Scrollbar and Header behaviour}
72 for more info about that). In case you need to specify custom Flickable
73 content margins (note: we're talking about content margins, not anchors ones), you will also have to
74 override the top and bottom anchors margins of the Scrollbar accordingly.
75
76 \section1 Vertical Scrollbar and Header behaviour
77
78 The thumb of the Scrollbar should not move or resize unexpectedly. It would be confusing,
79 for instance, if it moved under the user's finger (or pointer) while he's dragging it.
80
81 Because the size and position of the thumb in a scrollbar is related to the size of the
82 trough (or track) it slides in, it is important that the trough does not resize or move while the
83 user is interacting with the component.
84
85 In the context of a \l Page with a \l Header that slides in and out dynamically when the user
86 flicks the surface (see \l {Header::flickable}), a vertical Scrollbar that is linked
87 to the same flickable surface as the Header behaves as described below:
88
89 \list
90 \li - when the Header is exposed, the Scrollbar component sits right below it, \
91 thus avoiding overlaps;
92
93 \li - when the Header hides due to the user either flicking the surface or dragging \
94 the thumb, the trough of the Scrollbar does not resize or move, thus avoiding \
95 unexpected changes in thumb's position or size. As a side effect, the space \
96 above the Scrollbar, previously occupied by Header, stays empty until the Header \
97 is exposed again.
98
99 \endlist
100 \br
101 This behaviour is intended and makes for a less confusing User Experience.
60 */102 */
61103
62Toolkit.StyledItem {104Toolkit.StyledItem {
@@ -135,9 +177,9 @@
135 right: internals.rightAnchor(__viewport ? __viewport : flickableItem)177 right: internals.rightAnchor(__viewport ? __viewport : flickableItem)
136 rightMargin: internals.rightAnchorMargin()178 rightMargin: internals.rightAnchorMargin()
137 top: internals.topAnchor(__viewport ? __viewport : flickableItem)179 top: internals.topAnchor(__viewport ? __viewport : flickableItem)
138 topMargin: internals.topAnchorMargin()180 topMargin: (flickableItem ? flickableItem.topMargin : 0) + internals.topAnchorMargin()
139 bottom: internals.bottomAnchor(__viewport ? __viewport : flickableItem)181 bottom: internals.bottomAnchor(__viewport ? __viewport : flickableItem)
140 bottomMargin: internals.bottomAnchorMargin()182 bottomMargin: (flickableItem ? flickableItem.bottomMargin : 0) + internals.bottomAnchorMargin()
141 }183 }
142184
143 /*!185 /*!
@@ -183,7 +225,6 @@
183 && __buddyScrollbar.align === Qt.AlignLeading225 && __buddyScrollbar.align === Qt.AlignLeading
184 && __buddyScrollbar.__styleInstance.isScrollable)226 && __buddyScrollbar.__styleInstance.isScrollable)
185 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle227 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle
186 //return buddyScrollbar.__styleInstance.indicatorThickness
187 // *ELSE FALLTHROUGH*228 // *ELSE FALLTHROUGH*
188 default:229 default:
189 return 0230 return 0
@@ -209,7 +250,6 @@
209 && __buddyScrollbar.align === Qt.AlignTrailing250 && __buddyScrollbar.align === Qt.AlignTrailing
210 && __buddyScrollbar.__styleInstance.isScrollable)251 && __buddyScrollbar.__styleInstance.isScrollable)
211 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle252 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle
212 //return buddyScrollbar.__styleInstance.indicatorThickness
213 // *ELSE FALLTHROUGH*253 // *ELSE FALLTHROUGH*
214 default:254 default:
215 return 0255 return 0
@@ -234,7 +274,6 @@
234 && __buddyScrollbar.align === Qt.AlignTop274 && __buddyScrollbar.align === Qt.AlignTop
235 && __buddyScrollbar.__styleInstance.isScrollable)275 && __buddyScrollbar.__styleInstance.isScrollable)
236 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle276 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle
237 //return buddyScrollbar.__styleInstance.indicatorThickness
238 // *ELSE FALLTHROUGH*277 // *ELSE FALLTHROUGH*
239278
240 default:279 default:
@@ -260,7 +299,6 @@
260 && __buddyScrollbar.align === Qt.AlignBottom299 && __buddyScrollbar.align === Qt.AlignBottom
261 && __buddyScrollbar.__styleInstance.isScrollable)300 && __buddyScrollbar.__styleInstance.isScrollable)
262 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle301 return __buddyScrollbar.__styleInstance.troughThicknessSteppersStyle
263 //return buddyScrollbar.__styleInstance.indicatorThickness
264 // *ELSE FALLTHROUGH*302 // *ELSE FALLTHROUGH*
265 default:303 default:
266 return 0304 return 0
267305
=== modified file 'tests/unit_x11/tst_components/tst_scrollbar.qml'
--- tests/unit_x11/tst_components/tst_scrollbar.qml 2016-02-25 17:22:48 +0000
+++ tests/unit_x11/tst_components/tst_scrollbar.qml 2016-03-24 10:43:42 +0000
@@ -867,7 +867,32 @@
867 flickableSanityCheck.rightMargin = -units.gu(3)867 flickableSanityCheck.rightMargin = -units.gu(3)
868 flickableSanityCheck.bottomMargin = -units.gu(4)868 flickableSanityCheck.bottomMargin = -units.gu(4)
869 performStyleSanityCheck(scrollbarSanityCheck)869 performStyleSanityCheck(scrollbarSanityCheck)
870870 }
871
872 //Test that Scrollbar defaults to Flickable.topMargin/bottomMargin (content margins)
873 //as its ANCHORS margins
874 function test_topBottomMargins(data) {
875 var freshTestItem = getFreshFlickable(data.alignment)
876 var flickable = freshTestItem.flickable
877 var scrollbar = freshTestItem.scrollbar
878
879 compare(scrollbar.__styleInstance.isScrollable, true, "The view is not scrollable.")
880 compare(scrollbar.__styleInstance.alwaysOnScrollbars, false, "This test assumes overlay scrollbars (if you need to change this, fix the expected margins).")
881 compare(scrollbar.anchors.topMargin, flickable.topMargin, "Wrong anchors.topMargin.")
882 compare(scrollbar.anchors.bottomMargin, flickable.bottomMargin, "Wrong anchors.bottomMargin.")
883
884 flickable.topMargin = units.gu(1)
885 compare(scrollbar.anchors.topMargin, units.gu(1), "Wrong anchors.topMargin.")
886 compare(scrollbar.anchors.bottomMargin, flickable.bottomMargin, "Wrong anchors.bottomMargin.")
887
888 flickable.bottomMargin = units.gu(3)
889 compare(scrollbar.anchors.topMargin, units.gu(1), "Wrong anchors.topMargin.")
890 compare(scrollbar.anchors.bottomMargin, units.gu(3), "Wrong anchors.bottomMargin.")
891
892 flickable.topMargin = 0
893 flickable.bottomMargin = units.gu(6)
894 compare(scrollbar.anchors.topMargin, 0, "Wrong anchors.topMargin.")
895 compare(scrollbar.anchors.bottomMargin, units.gu(6), "Wrong anchors.bottomMargin.")
871 }896 }
872 }897 }
873}898}
874899
=== added file 'tests/unit_x11/tst_components/tst_scrollbar_header.qml'
--- tests/unit_x11/tst_components/tst_scrollbar_header.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_components/tst_scrollbar_header.qml 2016-03-24 10:43:42 +0000
@@ -0,0 +1,311 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Andrea Bernabei <andrea.bernabei@canonical.com>
17 */
18
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Test 1.0
22import Ubuntu.Components 1.3
23import Ubuntu.Components.Styles 1.3
24import QtQml.Models 2.1
25
26Item {
27 id: main
28 width: units.gu(50)
29 height: units.gu(100)
30
31 Component {
32 id: flickableComp
33 Item {
34 id: item
35 width: units.gu(20)
36 height: units.gu(30)
37 property alias flickable: freshFlickable
38 property alias scrollbar: freshScrollbar
39 property alias content: content
40 property alias scrollbarAlignment: freshScrollbar.align
41
42 //Don't change this to a ListView, this usecase has to be simple,
43 //we don't want the difficulties added by ListView, i.e. delegates
44 //size estimation, dynamic contentWidth/Height, etc
45 Flickable {
46 id: freshFlickable
47 anchors.fill: parent
48 contentHeight: content.height
49 contentWidth: content.width
50 clip: true
51 Rectangle {
52 id: content
53 width: units.gu(40)
54 //make this much taller than the flickable to avoid timing issues when
55 //detecting if the flickable is flicking in the tests
56 height: units.gu(200)
57 color: "blue"
58 }
59 }
60 Scrollbar {
61 id: freshScrollbar
62 flickableItem: parent.flickable
63 }
64 }
65 }
66
67 SignalSpy {
68 id: signalSpy
69 }
70 SignalSpy {
71 id: anotherSignalSpy
72 }
73
74 Flickable {
75 anchors.fill: parent
76 Column {
77 id: column
78 Repeater {
79 model: layoutsModel
80 }
81 }
82 }
83
84 VisualItemModel {
85 id: layoutsModel
86 Item {
87 width: childrenRect.width
88 height: childrenRect.height
89 Flickable {
90 id: randomFlickable
91 }
92
93 //complex PageHeader example taken from the PageHeader tutorial
94 //https://developer.ubuntu.com/en/blog/2016/02/24/pageheader-tutorial/
95 MainView {
96 id: mainView_movingHeaderTest
97 width: units.gu(50)
98 height: units.gu(80)
99 clip: true
100
101 property alias page: pageItem
102 property alias standardHeader: standardHeaderItem
103 property alias editHeader: editHeaderItem
104
105 Page {
106 id: pageItem
107 header: standardHeaderItem
108
109 onHeaderChanged: console.log("NEW HEADER")
110 Flickable {
111 id: flickable_movingHeaderTest
112 anchors.fill: parent
113 //just make sure the scrollbar is scrollable
114 contentHeight: mainView_movingHeaderTest.height * 2
115 contentWidth: mainView_movingHeaderTest.width * 2
116 Label {
117 text: "Use the icons in the header."
118 visible: standardHeaderItem.visible
119 }
120 }
121 Scrollbar {
122 id: scrollbar_movingHeaderTest
123 flickableItem: flickable_movingHeaderTest
124 }
125
126 PageHeader {
127 id: standardHeaderItem
128 visible: pageItem.header === standardHeaderItem
129 title: "Default title"
130 flickable: flickable_movingHeaderTest
131 trailingActionBar.actions: [
132 Action {
133 iconName: "edit"
134 text: "Edit"
135 onTriggered: pageItem.header = editHeaderItem
136 }
137 ]
138 }
139 PageHeader {
140 id: editHeaderItem
141 visible: pageItem.header === editHeaderItem
142 flickable: flickable_movingHeaderTest
143 property Component delegate: Component {
144 AbstractButton {
145 id: button
146 action: modelData
147 width: label.width + units.gu(4)
148 height: parent.height
149 Rectangle {
150 color: UbuntuColors.slate
151 opacity: 0.1
152 anchors.fill: parent
153 visible: button.pressed
154 }
155 Label {
156 anchors.centerIn: parent
157 id: label
158 text: action.text
159 font.weight: text === "Confirm"
160 ? Font.Normal
161 : Font.Light
162 }
163 }
164 }
165 leadingActionBar {
166 anchors.leftMargin: 0
167 actions: Action {
168 text: "Cancel"
169 iconName: "close"
170 onTriggered: pageItem.header = standardHeaderItem
171 }
172 delegate: editHeaderItem.delegate
173 }
174 trailingActionBar {
175 anchors.rightMargin: 0
176 actions: Action {
177 text: "Confirm"
178 iconName: "tick"
179 onTriggered: pageItem.header = standardHeaderItem
180 }
181 delegate: editHeaderItem.delegate
182 }
183 extension: Toolbar {
184 anchors {
185 left: parent.left
186 right: parent.right
187 bottom: parent.bottom
188 }
189 trailingActionBar.actions: [
190 Action { iconName: "bookmark-new" },
191 Action { iconName: "add" },
192 Action { iconName: "edit-select-all" },
193 Action { iconName: "edit-copy" },
194 Action { iconName: "select" }
195 ]
196 leadingActionBar.actions: Action {
197 iconName: "delete"
198 text: "delete"
199 onTriggered: print("Delete action triggered")
200 }
201 }
202 }
203
204 }
205 }
206
207 }
208 }
209
210 ScrollbarTestCase {
211 name: "Scrollbar"
212
213 function getMovingHeaderView() {
214 var wrapper = movingHeaderHandlingItem.createObject(column)
215 verify(wrapper !== null, "Error: dynamic item creation failed.")
216 currComponent = wrapper
217 return currComponent
218 }
219
220 function cleanup() {
221 if (currComponent) {
222 currComponent.destroy()
223 currComponent = null
224 }
225 gc()
226 }
227
228 function checkScrollbarPositionRelativeToPage(scrollbar, page, expectedY, msgPrefix) {
229 compare(scrollbar.mapToItem(page).y, expectedY, msgPrefix + ": Scrollbar does not start below the header.")
230 }
231
232 function test_handlingOfMovingHeader_data() {
233 return [
234 { tag: "Standard header", header: standardHeaderItem },
235 { tag: "Edit header (with extensions)", header: editHeaderItem },
236 //Setting header to null means using the old header, and:
237 //- We don't support this behaviour when using the old header
238 //- There is no API to get the height of the old header, so we can't test it
239 //{ tag: "Null header", header: null }
240 ]
241 }
242 function test_handlingOfMovingHeader(data) {
243 var page = pageItem
244 var header = data.header
245
246 page.header = header
247 console.log(page.header, header.flickable)
248
249 //make sure the currently tested header is the one driving the flickable changes
250 //FIXME: this should not be needed after #1560458 is fixed
251 header.flickable = null
252 header.flickable = flickable_movingHeaderTest
253
254 compare(page.header, header, "Handling of moving header: wrong header.")
255 compare(scrollbar_movingHeaderTest.__styleInstance.isVertical, true, "Scrollbar is not vertical.")
256 compare(scrollbar_movingHeaderTest.__styleInstance.isScrollable, true, "Scrollbar is not scrollable.")
257
258 //don't do the rest of the checks on the null header, just check that it's aligning with the old header implementation
259 //(page.head.contents.height)
260 if (data.header === null) {
261 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.head.contents.height, data.tag)
262 return
263 } else {
264 header.flickable = flickable_movingHeaderTest
265 compare(header.flickable, flickable_movingHeaderTest, "Wrong PageHeader flickable.")
266 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height, data.tag)
267 }
268
269 var tmpHeaderHeight = header.height
270 page.header.height += units.gu(1)
271 //make sure the header actually has a different height now
272 verify(scrollbar_movingHeaderTest.height !== tmpHeaderHeight, "Header height changed value.")
273 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height,
274 data.tag + ", after changing height")
275
276 //now link the header to a null flickable and check that scrollbar is covered
277 //the header (yes, we're checking that it creates bad UX, because we're expecting the
278 //developer to set the anchors accordingly so that we don't need to add inter-components
279 //dependencies. The test Page does not handle this on purpose, so the header
280 //should cover the scrollbar)
281 header.flickable = null
282 compare(header.flickable, null, "Wrong PageHeader flickable.")
283 expectFailContinue("Standard header", "Waiting on Header bug #1560458")
284 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, 0, data.tag)
285
286 //reassign the correct flickable and check again
287 header.flickable = flickable_movingHeaderTest
288 compare(header.flickable, flickable_movingHeaderTest, "Wrong PageHeader flickable.")
289 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height, data.tag + ", scrollbar")
290
291 header.visible = false
292 compare(header.visible, false, "Header visibility did not change, should have been false.")
293 expectFailContinue("", "Waiting on Header bug #1560458")
294 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, 0, data.tag + ", invisible header")
295
296 header.visible = true
297 compare(header.visible, true, "Header visibility did not change, should have been true.")
298 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height, data.tag + ", visible header")
299
300 //even if the header has opacity 0, we should still take it into account. This is a standard in
301 //QtQuick, you don't ignore a component just because opacity is 0, as that is also used for animations
302 header.opacity = 0.0
303 compare(header.opacity, 0.0, "Header opacity did not change, should have been 0.")
304 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height, data.tag + ", 0.0 header opacity")
305
306 header.opacity = 1.0
307 compare(header.opacity, 1.0, "Header opacity did not change, should have been 1.")
308 checkScrollbarPositionRelativeToPage(scrollbar_movingHeaderTest, page, page.header.height, data.tag + ", 1.0 header opacity")
309 }
310 }
311}

Subscribers

People subscribed via source and target branches