~tpeeters/ubuntu-ui-toolkit/qt56fixes1

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Zsombor Egri
  • Date: 2016-08-26 08:34:20 UTC
  • mfrom: (2027.5.30 columnLayout)
  • Revision ID: tarmac-20160826083420-fvf6vu7euhs7d1g7
SplitView to Ubuntu.Components.Labs.

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
17
import QtQuick 2.4
 
18
import Ubuntu.Test 1.3
 
19
import Ubuntu.Components 1.3
 
20
import Ubuntu.Components.Labs 1.0
 
21
 
 
22
Item {
 
23
    id: main
 
24
    width: units.gu(200)
 
25
    height: units.gu(70)
 
26
 
 
27
    Sections {
 
28
        id: sections
 
29
        actions: [
 
30
            Action {
 
31
                text: "4 columns"
 
32
                onTriggered: splitView.columns = 4
 
33
            },
 
34
            Action {
 
35
                text: "2 columns"
 
36
                onTriggered: splitView.columns = 2
 
37
            }
 
38
        ]
 
39
    }
 
40
 
 
41
    SplitView {
 
42
        id: splitView
 
43
        anchors {
 
44
            fill: parent
 
45
            topMargin: sections.height
 
46
        }
 
47
        property int columns: 4
 
48
 
 
49
        layouts: [
 
50
            SplitViewLayout {
 
51
                id: mainLayout
 
52
                when: splitView.columns == 4
 
53
                ViewColumn {
 
54
                    preferredWidth: units.gu(40)
 
55
                    maximumWidth: units.gu(100)
 
56
                }
 
57
                ViewColumn {
 
58
                    fillWidth: true
 
59
                    minimumWidth: units.gu(10)
 
60
                    maximumWidth: units.gu(150)
 
61
                }
 
62
                ViewColumn {
 
63
                    preferredWidth: units.gu(50)
 
64
                }
 
65
                ViewColumn {
 
66
                    fillWidth: true
 
67
                    minimumWidth: units.gu(15)
 
68
                }
 
69
            },
 
70
            SplitViewLayout {
 
71
                when: splitView.columns == 2
 
72
                ViewColumn {
 
73
                    preferredWidth: units.gu(10)
 
74
                    minimumWidth: units.gu(30)
 
75
                }
 
76
                ViewColumn {
 
77
                    fillWidth: true
 
78
                    minimumWidth: units.gu(40)
 
79
                }
 
80
            }
 
81
        ]
 
82
 
 
83
        Repeater {
 
84
            objectName: "ignored"
 
85
            model: splitView.columns
 
86
            Rectangle {
 
87
                objectName: "column" + index
 
88
                color: UbuntuColors.red
 
89
                height: splitView.height
 
90
            }
 
91
        }
 
92
    }
 
93
 
 
94
    UbuntuTestCase {
 
95
        when: windowShown
 
96
 
 
97
        function cleanup() {
 
98
            splitView.columns = 0;
 
99
        }
 
100
 
 
101
        function test_children_data() {
 
102
            return [
 
103
                {tag: "4 columns", columns: 4, childCount: 5, children: ["column0", "column1", "column2", "column3", "ignored"]},
 
104
                {tag: "2 columns", columns: 2, childCount: 3, children: ["column0", "column1", "ignored"]},
 
105
                {tag: "0 columns", columns: 0, childCount: 1, children: ["ignored"]},
 
106
            ];
 
107
        }
 
108
        function test_children(data) {
 
109
            splitView.columns = data.columns;
 
110
            compare(splitView.children.length, data.childCount);
 
111
            for (var i in splitView.children) {
 
112
                compare(splitView.children[i].objectName, data.children[i]);
 
113
            }
 
114
        }
 
115
    }
 
116
}