~zsombi/ubuntu-ui-toolkit/pleaseBottomEdgePreloadUrl

« back to all changes in this revision

Viewing changes to tests/unit/visual/tst_multicolumnheader.13.qml

  • Committer: Tarmac
  • Author(s): Tim Peeters
  • Date: 2016-06-30 11:34:02 UTC
  • mfrom: (2015.3.12 apl-header-height)
  • Revision ID: tarmac-20160630113402-ufid7obrl3dfjmwx
Add Header.automaticHeight property. Fixes: https://bugs.launchpad.net/bugs/1540240.

Approved by ubuntu-sdk-build-bot, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2015 Canonical Ltd.
 
2
 * Copyright 2016 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU Lesser General Public License as published by
35
35
        Page {
36
36
            id: rootPage
37
37
            title: "Root"
38
 
 
39
 
            Column {
40
 
                anchors {
41
 
                    top: parent.top
42
 
                    left: parent.left
43
 
                    right: parent.right
44
 
                }
45
 
                height: childrenRect.height
46
 
 
47
 
                ListItemWithLabel13 {
48
 
                    text: "Add page left"
49
 
                    onClicked: layout.addPageToCurrentColumn(rootPage, leftPage)
50
 
                }
51
 
                ListItemWithLabel13 {
52
 
                    text: "Add page right"
53
 
                    onClicked: layout.addPageToNextColumn(rootPage, rightPage)
54
 
                }
55
 
                ListItemWithLabel13 {
56
 
                    text: "Add sections page right"
57
 
                    onClicked: layout.addPageToNextColumn(rootPage, sectionsPage)
58
 
                }
59
 
                ListItemWithLabel13 {
60
 
                    text: "Add external page right"
61
 
                    onClicked: layout.addPageToNextColumn(
62
 
                                   rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"))
63
 
                }
64
 
                ListItemWithLabel13 {
65
 
                    text: "Add page with head contents left"
66
 
                    onClicked: layout.addPageToCurrentColumn(rootPage, headContentsPage)
67
 
                }
68
 
                ListItemWithLabel13 {
69
 
                    text: "Add page with head contents right"
70
 
                    onClicked: layout.addPageToNextColumn(rootPage, headContentsPage)
71
 
                }
72
 
                ListItemWithLabel13 {
73
 
                    text: "Add page with header left"
74
 
                    onClicked: layout.addPageToCurrentColumn(rootPage, pageWithHeader)
75
 
                }
76
 
                ListItemWithLabel13 {
77
 
                    text: "Add page with header right"
78
 
                    onClicked: layout.addPageToNextColumn(rootPage, pageWithHeader)
 
38
            flickable: null
 
39
 
 
40
            Flickable {
 
41
                anchors.fill: parent
 
42
                contentWidth: parent.width
 
43
                contentHeight: pagesColumn.height
 
44
 
 
45
                Column {
 
46
                    id: pagesColumn
 
47
                    anchors {
 
48
                        top: parent.top
 
49
                        left: parent.left
 
50
                        right: parent.right
 
51
                    }
 
52
                    height: childrenRect.height
 
53
 
 
54
                    ListItemWithLabel13 {
 
55
                        text: "Add page left"
 
56
                        onClicked: layout.addPageToCurrentColumn(rootPage, leftPage)
 
57
                    }
 
58
                    ListItemWithLabel13 {
 
59
                        text: "Add page right"
 
60
                        onClicked: layout.addPageToNextColumn(rootPage, rightPage)
 
61
                    }
 
62
                    ListItemWithLabel13 {
 
63
                        text: "Add sections page right"
 
64
                        onClicked: layout.addPageToNextColumn(rootPage, sectionsPage)
 
65
                    }
 
66
                    ListItemWithLabel13 {
 
67
                        text: "Add external page right"
 
68
                        onClicked: layout.addPageToNextColumn(
 
69
                                       rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"))
 
70
                    }
 
71
                    ListItemWithLabel13 {
 
72
                        text: "Add page with head contents left"
 
73
                        onClicked: layout.addPageToCurrentColumn(rootPage, headContentsPage)
 
74
                    }
 
75
                    ListItemWithLabel13 {
 
76
                        text: "Add page with head contents right"
 
77
                        onClicked: layout.addPageToNextColumn(rootPage, headContentsPage)
 
78
                    }
 
79
                    ListItemWithLabel13 {
 
80
                        text: "Add page with header left"
 
81
                        onClicked: layout.addPageToCurrentColumn(rootPage, pageWithHeader)
 
82
                    }
 
83
                    ListItemWithLabel13 {
 
84
                        text: "Add page with header right"
 
85
                        onClicked: layout.addPageToNextColumn(rootPage, pageWithHeader)
 
86
                    }
 
87
                    ListItemWithLabel13 {
 
88
                        text: "Add page with no automatic header height left"
 
89
                        onClicked: layout.addPageToCurrentColumn(rootPage, pageNoAutomaticHeaderHeight)
 
90
                    }
 
91
                    ListItemWithLabel13 {
 
92
                        text: "Add page with no automatic header height right"
 
93
                        onClicked: layout.addPageToNextColumn(rootPage, pageNoAutomaticHeaderHeight)
 
94
                    }
79
95
                }
80
96
            }
81
97
        }
157
173
                }
158
174
            }
159
175
        }
 
176
        Page {
 
177
            id: pageNoAutomaticHeaderHeight
 
178
            header: PageHeader {
 
179
                title: "Page with no automatic header height"
 
180
                StyleHints {
 
181
                    backgroundColor: UbuntuColors.green
 
182
                    foregroundColor: "white"
 
183
                    contentHeight: units.gu(7) // 1 GU more than the default
 
184
                }
 
185
                automaticHeight: false
 
186
            }
 
187
            Rectangle {
 
188
                anchors {
 
189
                    top: pageNoAutomaticHeaderHeight.header.bottom
 
190
                    left: parent.left
 
191
                    right: parent.right
 
192
                    bottom: parent.bottom
 
193
                    margins: units.gu(2)
 
194
                }
 
195
                color: UbuntuColors.warmGrey
 
196
                Button {
 
197
                    anchors.centerIn: parent
 
198
                    text: "Add sections to next column."
 
199
                    onTriggered: layout.addPageToNextColumn(pageNoAutomaticHeaderHeight, sectionsPage)
 
200
                }
 
201
            }
 
202
        }
160
203
    }
161
204
 
162
205
    UbuntuTestCase {
345
388
            }
346
389
        }
347
390
 
348
 
        function test_pageheader_height() {
 
391
        function test_pageheader_automatic_height() {
349
392
            if (root.columns !== 2) {
350
393
                skip("Only for wide view.");
351
394
            }
371
414
                    "Page header height is not reverted when header with sections is removed from next column.");
372
415
        }
373
416
 
 
417
        function test_pageheader_no_automatic_height_bug1540240() {
 
418
            if (root.columns !== 2) {
 
419
                skip("Only for wide view.");
 
420
            }
 
421
 
 
422
            // baseHeight was checked in test_subheader_height().
 
423
            var baseHeight = get_header(0).height;
 
424
 
 
425
            layout.addPageToNextColumn(rootPage, pageNoAutomaticHeaderHeight);
 
426
            compare(baseHeight === pageNoAutomaticHeaderHeight.header.height, false,
 
427
                    "This test makes no sense if pageNoAutomaticHeaderHeight.header.height is the default height.");
 
428
            compare(get_header(0).height, baseHeight,
 
429
                    "Page header with no automatic height affects header height in other column.");
 
430
            layout.removePages(pageNoAutomaticHeaderHeight);
 
431
            compare(get_header(0).height, baseHeight,
 
432
                    "Removing page with no automatic header height changes header height in other column.");
 
433
 
 
434
            layout.addPageToCurrentColumn(rootPage, pageNoAutomaticHeaderHeight);
 
435
            baseHeight = get_header(0).height;
 
436
            layout.addPageToNextColumn(rootPage, sectionsPage);
 
437
 
 
438
            // withSectionsHeight was checked in test_subheader_height().
 
439
            var withSectionsHeight = get_header(1).height;
 
440
            compare(withSectionsHeight > baseHeight, true,
 
441
                    "Header with sections is not more than 1 GU higher than header without sections.");
 
442
            compare(pageNoAutomaticHeaderHeight.header.height, baseHeight,
 
443
                    "Page header with no automatic height adapts its height to header with sections in other column.");
 
444
 
 
445
            layout.removePages(sectionsPage);
 
446
            compare(pageNoAutomaticHeaderHeight.header.height, baseHeight,
 
447
                    "Page header with no automatic height is changed when header with sections is removed from next column.");
 
448
        }
 
449
 
374
450
        function test_back_button_wide() {
375
451
            // FIXME: When we remove support for the old subHeader and all
376
452
            //  pages use a PageHeader, the repeated tests for PageHeader below