Merge lp:~tpeeters/ubuntu-ui-toolkit/100-SectionBar into lp:ubuntu-ui-toolkit/staging
- 100-SectionBar
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 1564 |
Merged at revision: | 1535 |
Proposed branch: | lp:~tpeeters/ubuntu-ui-toolkit/100-SectionBar |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
835 lines (+732/-0) 12 files modified
components.api (+4/-0) examples/ubuntu-ui-toolkit-gallery/Sections.qml (+47/-0) examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml (+5/-0) modules/Ubuntu/Components/1.3/Sections.qml (+101/-0) modules/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml (+119/-0) modules/Ubuntu/Components/qmldir (+1/-0) tests/autopilot/ubuntuuitoolkit/__init__.py (+2/-0) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py (+2/-0) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_sections.py (+49/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.SectionsTestCase.qml (+42/-0) tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.py (+51/-0) tests/unit_x11/tst_components/tst_sections.qml (+309/-0) |
To merge this branch: | bzr merge lp:~tpeeters/ubuntu-ui-toolkit/100-SectionBar |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Zsombor Egri | Approve | ||
Tim Peeters | Needs Fixing | ||
Review via email: mp+260502@code.launchpad.net |
Commit message
Introduce the new Sections component.
Description of the change
Introduce the new Sections component.
This component will be used (in a following MR) in the new header to replace the sections selector in the current header divider. Sections will also be available as a separate component for convergence apps that need to place the Sections outside of the single standard header.
- 1534. By Tim Peeters
-
docs
- 1535. By Tim Peeters
-
docs
- 1536. By Tim Peeters
-
spacing
- 1537. By Tim Peeters
-
spacing
- 1538. By Tim Peeters
-
update components.api
- 1539. By Tim Peeters
-
docs
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1540. By Tim Peeters
-
remove empty functions from tst_sections
- 1541. By Tim Peeters
-
sections
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1541
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
Comments inline. I'm not good with the API.
Tim Peeters (tpeeters) wrote : | # |
38 +/*!
39 + \qmltype Sections
40 + \inqmlmodule Ubuntu.Components 1.3
41 + \ingroup ubuntu
42 + \since Ubuntu.Components 1.3
43 + \brief Display a list of sections that the user can select.
44 + */
> Zsombor Egri (zsombi) wrote 7 hours ago:
> Shouldn't you have more to say here?
Yes I can extend it a bit.
45 +StyledItem {
46 + id: sections
47 + style: theme.createSty
> Zsombor Egri (zsombi) wrote 7 hours ago:
> This is wrong, once the styleName will get into staging, this will be broken. Please merge with
> styleName MR and fix this. With a small luck, we will get it soon if LP gets it.
Ok, will do. I thought I would land my MR before you land yours. ;)
48 +
49 + /*!
50 + List of strings that represent section names. Example:
51 + \qml
> Zsombor Egri (zsombi) wrote 7 hours ago:
> Hmm.... I was thinking shouldn't this be rather a list of actions? Then you don't need the
> model and the selectedIndex properties separated. The Action would drive the visual (you
> would also be able to show icons if design changes his mind - with the current setup an API
> change would be needed) and the trigger would tell which Action is selected. I feel we have
> to discuss more about this.
Ok. After our discussion, I'll make this a list of actions and keep the selectedIndex as well. Changing the selectedIndex will trigger the appropriate Action.
137 + Row {
138 + id: sectionsRow
> Zsombor Egri (zsombi) wrote 7 hours ago:
> Aren't the sections proportionally filling the space? What if a text exceeds the
> space available?
No. In the new designs, the sections are always aligned left and don't fill the space.
If the text exceeds the available space, the section list will be scrollable. I will add the scrolling in a following MR.
150 + AbstractButton {
151 + id: sectionButton
> Zsombor Egri (zsombi) wrote 7 hours ago:
> I feel like this should be rather that FlatButton instead...
We don't have a FlatButton yet. I think the AbstractButton is fine here, since the visuals are quite specific for the section selector.
399 + def test_click_
400 + error = self.assertRaises(
Zsombor Egri (zsombi) wrote 7 hours ago:
> Why do you need this? Can't you cover this in unit test?
It does not test component functionality, only verifies that the CPO works as expected.
- 1542. By Tim Peeters
-
sync staging
- 1543. By Tim Peeters
-
use styleName in Sections
- 1544. By Tim Peeters
-
extend docs a bit
- 1545. By Tim Peeters
-
use Actions instead of strings for the model
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1545
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1546. By Tim Peeters
-
changing selectedIndex triggers Action.
- 1547. By Tim Peeters
-
update components.api
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1547
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1548. By Tim Peeters
-
sync staging
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1548
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
/tmp/buildd/
/tmp/buildd/
Makefile:289: recipe for target 'docs' failed
- 1549. By Tim Peeters
-
fix docs
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1549
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tim Peeters (tpeeters) wrote : | # |
Ready for another review.
Note that Page.head.
Do we want to break that API and replace it with a list of Actions?
Zsombor Egri (zsombi) wrote : | # |
> Ready for another review.
>
> Note that Page.head.
> /developer.
> s/
>
> Do we want to break that API and replace it with a list of Actions?
Do we break the API if we say that it can be either strings - in which case we have more work - or it also can be a list of Actions? I think not.
Tim Peeters (tpeeters) wrote : | # |
Supporting both Actions and strings in PageHeadSections is problematic. Then in order to feed it to the Sections we need to convert the list of strings into a list of Actions. I don't see a simple way to do that in QML.
We can support strings and actions in Sections and PageHeadSections, and then inside Sections I'll have to support both in the Repeater. That is not difficult but I'd say it is a bit messy.
- 1550. By Tim Peeters
-
unit tests for list of strings as model
- 1551. By Tim Peeters
-
rename actions to model and support a list of strings as model
- 1552. By Tim Peeters
-
improve test app
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1552
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1553. By Tim Peeters
-
split up unit tests
- 1554. By Tim Peeters
-
update components.api
- 1555. By Tim Peeters
-
merge staging
- 1556. By Tim Peeters
-
update docs
Tim Peeters (tpeeters) wrote : | # |
Updated and ready for another review. The 'actions' property was renamed to 'model' and now accepts either a list of Actions or a list of strings. Docs and unit tests were also updated.
- 1557. By Tim Peeters
-
fix components.api
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1553
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1557
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tim Peeters (tpeeters) wrote : | # |
[10:55:46] <nerochiaro> timp: i am trying to use the Sections from your branch but when i follow the example and set actions to a list, like this "actions: [ Action { text: "A" } ]" QML gives me this error: "Cannot assign multiple values to a singular property"... any ideas why ?
[10:56:11] <nerochiaro> timp: if I create a list<Action> property and then assign it to the actions it works ok
- 1558. By Tim Peeters
-
fix
- 1559. By Tim Peeters
-
document actions/model
- 1560. By Tim Peeters
-
add Sections to the component gallery
- 1561. By Tim Peeters
-
clean tst_sections.qml
- 1562. By Tim Peeters
-
update components.api
- 1563. By Tim Peeters
-
update docs
- 1564. By Tim Peeters
-
fix docs
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1558
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1564
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'components.api' | |||
2 | --- components.api 2015-06-02 12:37:41 +0000 | |||
3 | +++ components.api 2015-06-17 12:24:49 +0000 | |||
4 | @@ -793,6 +793,10 @@ | |||
5 | 793 | property int align | 793 | property int align |
6 | 794 | property Flickable flickableItem | 794 | property Flickable flickableItem |
7 | 795 | Ubuntu.Components.ScrollbarUtils 0.1 1.0 | 795 | Ubuntu.Components.ScrollbarUtils 0.1 1.0 |
8 | 796 | Ubuntu.Components.Sections 1.3: StyledItem | ||
9 | 797 | readonly property Action actions | ||
10 | 798 | property var model | ||
11 | 799 | property int selectedIndex | ||
12 | 796 | Ubuntu.Components.ServiceProperties 1.1: QtObject | 800 | Ubuntu.Components.ServiceProperties 1.1: QtObject |
13 | 797 | property string adaptorInterface | 801 | property string adaptorInterface |
14 | 798 | readonly property string error | 802 | readonly property string error |
15 | 799 | 803 | ||
16 | === added file 'examples/ubuntu-ui-toolkit-gallery/Sections.qml' | |||
17 | --- examples/ubuntu-ui-toolkit-gallery/Sections.qml 1970-01-01 00:00:00 +0000 | |||
18 | +++ examples/ubuntu-ui-toolkit-gallery/Sections.qml 2015-06-17 12:24:49 +0000 | |||
19 | @@ -0,0 +1,47 @@ | |||
20 | 1 | /* | ||
21 | 2 | * Copyright 2015 Canonical Ltd. | ||
22 | 3 | * | ||
23 | 4 | * This program is free software; you can redistribute it and/or modify | ||
24 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
25 | 6 | * the Free Software Foundation; version 3. | ||
26 | 7 | * | ||
27 | 8 | * This program is distributed in the hope that it will be useful, | ||
28 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
29 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
30 | 11 | * GNU Lesser General Public License for more details. | ||
31 | 12 | * | ||
32 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
33 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
34 | 15 | */ | ||
35 | 16 | |||
36 | 17 | import QtQuick 2.4 | ||
37 | 18 | import Ubuntu.Components 1.3 | ||
38 | 19 | |||
39 | 20 | Template { | ||
40 | 21 | objectName: "sectionsTemplate" | ||
41 | 22 | |||
42 | 23 | TemplateSection { | ||
43 | 24 | title: "Sections" | ||
44 | 25 | className: "Sections" | ||
45 | 26 | |||
46 | 27 | TemplateRow { | ||
47 | 28 | title: i18n.tr("Enabled") | ||
48 | 29 | |||
49 | 30 | Sections { | ||
50 | 31 | actions: [ | ||
51 | 32 | Action { text: "one" }, | ||
52 | 33 | Action { text: "two" }, | ||
53 | 34 | Action { text: "three" } | ||
54 | 35 | ] | ||
55 | 36 | } | ||
56 | 37 | } | ||
57 | 38 | TemplateRow { | ||
58 | 39 | title: i18n.tr("Disabled") | ||
59 | 40 | |||
60 | 41 | Sections { | ||
61 | 42 | model: ["one", "two", "three"] | ||
62 | 43 | enabled: false | ||
63 | 44 | } | ||
64 | 45 | } | ||
65 | 46 | } | ||
66 | 47 | } | ||
67 | 0 | 48 | ||
68 | === modified file 'examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml' | |||
69 | --- examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2015-03-23 16:24:43 +0000 | |||
70 | +++ examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2015-06-17 12:24:49 +0000 | |||
71 | @@ -72,6 +72,11 @@ | |||
72 | 72 | source: "ProgressBars.qml" | 72 | source: "ProgressBars.qml" |
73 | 73 | } | 73 | } |
74 | 74 | ListElement { | 74 | ListElement { |
75 | 75 | objectName: "sectionsElement" | ||
76 | 76 | label: "Sections" | ||
77 | 77 | source: "Sections.qml" | ||
78 | 78 | } | ||
79 | 79 | ListElement { | ||
80 | 75 | objectName: "ubuntuShapesElement" | 80 | objectName: "ubuntuShapesElement" |
81 | 76 | label: "Ubuntu Shape" | 81 | label: "Ubuntu Shape" |
82 | 77 | source: "UbuntuShape.qml" | 82 | source: "UbuntuShape.qml" |
83 | 78 | 83 | ||
84 | === added file 'modules/Ubuntu/Components/1.3/Sections.qml' | |||
85 | --- modules/Ubuntu/Components/1.3/Sections.qml 1970-01-01 00:00:00 +0000 | |||
86 | +++ modules/Ubuntu/Components/1.3/Sections.qml 2015-06-17 12:24:49 +0000 | |||
87 | @@ -0,0 +1,101 @@ | |||
88 | 1 | /* | ||
89 | 2 | * Copyright 2015 Canonical Ltd. | ||
90 | 3 | * | ||
91 | 4 | * This program is free software; you can redistribute it and/or modify | ||
92 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
93 | 6 | * the Free Software Foundation; version 3. | ||
94 | 7 | * | ||
95 | 8 | * This program is distributed in the hope that it will be useful, | ||
96 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
97 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
98 | 11 | * GNU Lesser General Public License for more details. | ||
99 | 12 | * | ||
100 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
101 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
102 | 15 | */ | ||
103 | 16 | |||
104 | 17 | import QtQuick 2.4 | ||
105 | 18 | import Ubuntu.Components 1.3 | ||
106 | 19 | |||
107 | 20 | /*! | ||
108 | 21 | \qmltype Sections | ||
109 | 22 | \inqmlmodule Ubuntu.Components 1.3 | ||
110 | 23 | \ingroup ubuntu | ||
111 | 24 | \since Ubuntu.Components 1.3 | ||
112 | 25 | \brief Display a list of sections that the user can select. By tapping | ||
113 | 26 | on a section name the \l selectedIndex will be updated, and the | ||
114 | 27 | associated \l Action is triggered. | ||
115 | 28 | */ | ||
116 | 29 | StyledItem { | ||
117 | 30 | id: sections | ||
118 | 31 | styleName: "SectionsStyle" | ||
119 | 32 | |||
120 | 33 | /*! | ||
121 | 34 | List of actions that represent the sections. | ||
122 | 35 | The text of each action is displayed as the section name and clicking | ||
123 | 36 | a section will update the \l selectedIndex. | ||
124 | 37 | |||
125 | 38 | When \l selectedIndex is changed (by user interaction or by setting | ||
126 | 39 | the value), actions[selectedIndex] will be triggered. | ||
127 | 40 | |||
128 | 41 | Example: | ||
129 | 42 | \qml | ||
130 | 43 | Sections { | ||
131 | 44 | actions: [ | ||
132 | 45 | Action { | ||
133 | 46 | text: "first" | ||
134 | 47 | onTriggered: print("one") | ||
135 | 48 | }, | ||
136 | 49 | Action { | ||
137 | 50 | text: "second" | ||
138 | 51 | onTriggered: print("two") | ||
139 | 52 | }, | ||
140 | 53 | Action { | ||
141 | 54 | text: "third" | ||
142 | 55 | onTriggered: print("three") | ||
143 | 56 | } | ||
144 | 57 | ] | ||
145 | 58 | } | ||
146 | 59 | \endqml | ||
147 | 60 | It is strongly recommended to limit the number of sections to two or three. | ||
148 | 61 | The actions are used as the model for the Sections by default. | ||
149 | 62 | If no trigger functions need to be specified, \l model may be used directly | ||
150 | 63 | without setting the actions property. If both \l actions and \l model are set, | ||
151 | 64 | model overrides the actions. | ||
152 | 65 | */ | ||
153 | 66 | property list<Action> actions | ||
154 | 67 | |||
155 | 68 | /*! | ||
156 | 69 | The input model for the sections. By default model takes the \l actions | ||
157 | 70 | as input, but if no trigger functions need to be specified, it can be | ||
158 | 71 | simplified to a list of strings naming the sections: | ||
159 | 72 | \qml | ||
160 | 73 | Sections { | ||
161 | 74 | model: [ "one", "two", "three" ] | ||
162 | 75 | onSelectedIndexChanged: { | ||
163 | 76 | print("Selected section " + model[selectedIndex]); | ||
164 | 77 | } | ||
165 | 78 | } | ||
166 | 79 | \endqml | ||
167 | 80 | */ | ||
168 | 81 | property var model: actions | ||
169 | 82 | onModelChanged: { | ||
170 | 83 | if (model && model.length > 3) { | ||
171 | 84 | // FIXME: Make the Sections scrollable for more than 3 sections. | ||
172 | 85 | console.warn("It is not YET recommended or supported to use more than three sections."); | ||
173 | 86 | } | ||
174 | 87 | } | ||
175 | 88 | |||
176 | 89 | /*! | ||
177 | 90 | The index of the currently selected section in \l model. | ||
178 | 91 | */ | ||
179 | 92 | property int selectedIndex: model ? 0 : -1 | ||
180 | 93 | |||
181 | 94 | onSelectedIndexChanged: { | ||
182 | 95 | if ((selectedIndex >= 0) && (selectedIndex < model.length)) { | ||
183 | 96 | if (model[selectedIndex].hasOwnProperty("trigger")) { | ||
184 | 97 | model[selectedIndex].trigger(); | ||
185 | 98 | } | ||
186 | 99 | } | ||
187 | 100 | } | ||
188 | 101 | } | ||
189 | 0 | 102 | ||
190 | === added file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml' | |||
191 | --- modules/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml 1970-01-01 00:00:00 +0000 | |||
192 | +++ modules/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml 2015-06-17 12:24:49 +0000 | |||
193 | @@ -0,0 +1,119 @@ | |||
194 | 1 | /* | ||
195 | 2 | * Copyright 2015 Canonical Ltd. | ||
196 | 3 | * | ||
197 | 4 | * This program is free software; you can redistribute it and/or modify | ||
198 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
199 | 6 | * the Free Software Foundation; version 3. | ||
200 | 7 | * | ||
201 | 8 | * This program is distributed in the hope that it will be useful, | ||
202 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
203 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
204 | 11 | * GNU Lesser General Public License for more details. | ||
205 | 12 | * | ||
206 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
207 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
208 | 15 | */ | ||
209 | 16 | import QtQuick 2.4 | ||
210 | 17 | import Ubuntu.Components 1.3 | ||
211 | 18 | |||
212 | 19 | Item { | ||
213 | 20 | id: sectionsStyle | ||
214 | 21 | |||
215 | 22 | implicitWidth: sectionsRow.width | ||
216 | 23 | implicitHeight: units.gu(4) | ||
217 | 24 | |||
218 | 25 | enabled: styledItem.enabled | ||
219 | 26 | opacity: enabled ? 1.0 : 0.5 | ||
220 | 27 | |||
221 | 28 | /*! | ||
222 | 29 | The foreground color of unselected sections. | ||
223 | 30 | */ | ||
224 | 31 | property color sectionColor: theme.palette.selected.backgroundText | ||
225 | 32 | |||
226 | 33 | /*! | ||
227 | 34 | The foreground color of the selected section. | ||
228 | 35 | */ | ||
229 | 36 | property color selectedSectionColor: UbuntuColors.orange | ||
230 | 37 | |||
231 | 38 | /*! | ||
232 | 39 | The background color for the pressed section button. | ||
233 | 40 | */ | ||
234 | 41 | property color pressedBackgroundColor: theme.palette.selected.background | ||
235 | 42 | |||
236 | 43 | /*! | ||
237 | 44 | The font size for the text in the buttons. | ||
238 | 45 | */ | ||
239 | 46 | property string fontSize: "small" | ||
240 | 47 | |||
241 | 48 | /*! | ||
242 | 49 | The spacing on the left and right sides of the label | ||
243 | 50 | inside a section button. | ||
244 | 51 | */ | ||
245 | 52 | property real horizontalLabelSpacing: units.gu(2) | ||
246 | 53 | |||
247 | 54 | /*! | ||
248 | 55 | The height of the bar underlining the sections. | ||
249 | 56 | */ | ||
250 | 57 | property real underlineHeight: units.dp(2) | ||
251 | 58 | |||
252 | 59 | Row { | ||
253 | 60 | id: sectionsRow | ||
254 | 61 | anchors { | ||
255 | 62 | top: parent.top | ||
256 | 63 | bottom: parent.bottom | ||
257 | 64 | horizontalCenter: parent.horizontalCenter | ||
258 | 65 | } | ||
259 | 66 | width: childrenRect.width | ||
260 | 67 | |||
261 | 68 | Repeater { | ||
262 | 69 | id: sectionsRepeater | ||
263 | 70 | model: styledItem.model | ||
264 | 71 | objectName: "sections_repeater" | ||
265 | 72 | AbstractButton { | ||
266 | 73 | id: sectionButton | ||
267 | 74 | anchors { | ||
268 | 75 | top: parent ? parent.top : undefined | ||
269 | 76 | bottom: parent ? parent.bottom : undefined | ||
270 | 77 | } | ||
271 | 78 | objectName: "section_button_" + index | ||
272 | 79 | width: label.width + 2 * sectionsStyle.horizontalLabelSpacing | ||
273 | 80 | height: sectionsRow.height | ||
274 | 81 | property bool selected: index === styledItem.selectedIndex | ||
275 | 82 | onClicked: styledItem.selectedIndex = index | ||
276 | 83 | |||
277 | 84 | // Background pressed highlight | ||
278 | 85 | Rectangle { | ||
279 | 86 | visible: parent.pressed | ||
280 | 87 | anchors.fill: parent | ||
281 | 88 | color: sectionsStyle.pressedBackgroundColor | ||
282 | 89 | } | ||
283 | 90 | |||
284 | 91 | // Section title | ||
285 | 92 | Label { | ||
286 | 93 | id: label | ||
287 | 94 | objectName: "section_button_label_" + index | ||
288 | 95 | // modelData may be either a string, or an Action | ||
289 | 96 | text: modelData.hasOwnProperty("text") ? modelData.text : modelData | ||
290 | 97 | fontSize: sectionsStyle.fontSize | ||
291 | 98 | anchors.centerIn: parent | ||
292 | 99 | color: sectionButton.selected ? | ||
293 | 100 | sectionsStyle.selectedSectionColor : | ||
294 | 101 | sectionsStyle.sectionColor | ||
295 | 102 | } | ||
296 | 103 | |||
297 | 104 | // Section title underline | ||
298 | 105 | Rectangle { | ||
299 | 106 | anchors { | ||
300 | 107 | bottom: parent.bottom | ||
301 | 108 | left: parent.left | ||
302 | 109 | right: parent.right | ||
303 | 110 | } | ||
304 | 111 | height: sectionsStyle.underlineHeight | ||
305 | 112 | color: sectionButton.selected ? | ||
306 | 113 | sectionsStyle.selectedSectionColor : | ||
307 | 114 | sectionsStyle.sectionColor | ||
308 | 115 | } | ||
309 | 116 | } | ||
310 | 117 | } | ||
311 | 118 | } | ||
312 | 119 | } | ||
313 | 0 | 120 | ||
314 | === modified file 'modules/Ubuntu/Components/qmldir' | |||
315 | --- modules/Ubuntu/Components/qmldir 2015-05-12 13:41:39 +0000 | |||
316 | +++ modules/Ubuntu/Components/qmldir 2015-06-17 12:24:49 +0000 | |||
317 | @@ -133,6 +133,7 @@ | |||
318 | 133 | PageHeadConfiguration 1.3 1.3/PageHeadConfiguration.qml | 133 | PageHeadConfiguration 1.3 1.3/PageHeadConfiguration.qml |
319 | 134 | PageHeadSections 1.3 1.3/PageHeadSections.qml | 134 | PageHeadSections 1.3 1.3/PageHeadSections.qml |
320 | 135 | PageHeadState 1.3 1.3/PageHeadState.qml | 135 | PageHeadState 1.3 1.3/PageHeadState.qml |
321 | 136 | Sections 1.3 1.3/Sections.qml | ||
322 | 136 | Header 1.3 1.3/Header.qml | 137 | Header 1.3 1.3/Header.qml |
323 | 137 | CrossFadeImage 1.3 1.3/CrossFadeImage.qml | 138 | CrossFadeImage 1.3 1.3/CrossFadeImage.qml |
324 | 138 | OrientationHelper 1.3 1.3/OrientationHelper.qml | 139 | OrientationHelper 1.3 1.3/OrientationHelper.qml |
325 | 139 | 140 | ||
326 | === modified file 'tests/autopilot/ubuntuuitoolkit/__init__.py' | |||
327 | --- tests/autopilot/ubuntuuitoolkit/__init__.py 2015-05-14 20:08:45 +0000 | |||
328 | +++ tests/autopilot/ubuntuuitoolkit/__init__.py 2015-06-17 12:24:49 +0000 | |||
329 | @@ -38,6 +38,7 @@ | |||
330 | 38 | 'QQuickFlickable', | 38 | 'QQuickFlickable', |
331 | 39 | 'QQuickGridView', | 39 | 'QQuickGridView', |
332 | 40 | 'QQuickListView', | 40 | 'QQuickListView', |
333 | 41 | 'Sections', | ||
334 | 41 | 'TabBar', | 42 | 'TabBar', |
335 | 42 | 'Tabs', | 43 | 'Tabs', |
336 | 43 | 'tests', | 44 | 'tests', |
337 | @@ -76,6 +77,7 @@ | |||
338 | 76 | QQuickFlickable, | 77 | QQuickFlickable, |
339 | 77 | QQuickGridView, | 78 | QQuickGridView, |
340 | 78 | QQuickListView, | 79 | QQuickListView, |
341 | 80 | Sections, | ||
342 | 79 | TabBar, | 81 | TabBar, |
343 | 80 | Tabs, | 82 | Tabs, |
344 | 81 | TextArea, | 83 | TextArea, |
345 | 82 | 84 | ||
346 | === modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py' | |||
347 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2015-05-14 20:08:45 +0000 | |||
348 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2015-06-17 12:24:49 +0000 | |||
349 | @@ -35,6 +35,7 @@ | |||
350 | 35 | 'QQuickFlickable', | 35 | 'QQuickFlickable', |
351 | 36 | 'QQuickGridView', | 36 | 'QQuickGridView', |
352 | 37 | 'QQuickListView', | 37 | 'QQuickListView', |
353 | 38 | 'Sections', | ||
354 | 38 | 'TabBar', | 39 | 'TabBar', |
355 | 39 | 'Tabs', | 40 | 'Tabs', |
356 | 40 | 'TextArea', | 41 | 'TextArea', |
357 | @@ -46,6 +47,7 @@ | |||
358 | 46 | ] | 47 | ] |
359 | 47 | 48 | ||
360 | 48 | from ubuntuuitoolkit._custom_proxy_objects._actionbar import ActionBar | 49 | from ubuntuuitoolkit._custom_proxy_objects._actionbar import ActionBar |
361 | 50 | from ubuntuuitoolkit._custom_proxy_objects._sections import Sections | ||
362 | 49 | from ubuntuuitoolkit._custom_proxy_objects._checkbox import CheckBox | 51 | from ubuntuuitoolkit._custom_proxy_objects._checkbox import CheckBox |
363 | 50 | from ubuntuuitoolkit._custom_proxy_objects._common import ( | 52 | from ubuntuuitoolkit._custom_proxy_objects._common import ( |
364 | 51 | check_autopilot_version, | 53 | check_autopilot_version, |
365 | 52 | 54 | ||
366 | === added file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_sections.py' | |||
367 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_sections.py 1970-01-01 00:00:00 +0000 | |||
368 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_sections.py 2015-06-17 12:24:49 +0000 | |||
369 | @@ -0,0 +1,49 @@ | |||
370 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
371 | 2 | # | ||
372 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
373 | 4 | # | ||
374 | 5 | # This program is free software; you can redistribute it and/or modify | ||
375 | 6 | # it under the terms of the GNU Lesser General Public License as published by | ||
376 | 7 | # the Free Software Foundation; version 3. | ||
377 | 8 | # | ||
378 | 9 | # This program is distributed in the hope that it will be useful, | ||
379 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
380 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
381 | 12 | # GNU Lesser General Public License for more details. | ||
382 | 13 | # | ||
383 | 14 | # You should have received a copy of the GNU Lesser General Public License | ||
384 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
385 | 16 | |||
386 | 17 | import logging | ||
387 | 18 | |||
388 | 19 | from autopilot import logging as autopilot_logging | ||
389 | 20 | from autopilot.introspection import dbus | ||
390 | 21 | from ubuntuuitoolkit._custom_proxy_objects import _common | ||
391 | 22 | |||
392 | 23 | |||
393 | 24 | logger = logging.getLogger(__name__) | ||
394 | 25 | |||
395 | 26 | |||
396 | 27 | class Sections(_common.UbuntuUIToolkitCustomProxyObjectBase): | ||
397 | 28 | """Sections Autopilot custom proxy object.""" | ||
398 | 29 | |||
399 | 30 | def _get_section_button(self, section_index): | ||
400 | 31 | try: | ||
401 | 32 | object_name = "section_button_" + str(section_index) | ||
402 | 33 | button = self.select_single(objectName=object_name) | ||
403 | 34 | except dbus.StateNotFoundError: | ||
404 | 35 | raise _common.ToolkitException( | ||
405 | 36 | 'Button not found in Sections.') | ||
406 | 37 | |||
407 | 38 | return button | ||
408 | 39 | |||
409 | 40 | @autopilot_logging.log_action(logger.info) | ||
410 | 41 | def click_section_button(self, section_index): | ||
411 | 42 | """Click a section button of the Sections. | ||
412 | 43 | |||
413 | 44 | :parameter section_index: The index of the section to click. | ||
414 | 45 | :raise ToolkitException: If there is no section button with that index. | ||
415 | 46 | |||
416 | 47 | """ | ||
417 | 48 | button = self._get_section_button(section_index) | ||
418 | 49 | self.pointing_device.click_object(button) | ||
419 | 0 | 50 | ||
420 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.SectionsTestCase.qml' | |||
421 | --- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.SectionsTestCase.qml 1970-01-01 00:00:00 +0000 | |||
422 | +++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.SectionsTestCase.qml 2015-06-17 12:24:49 +0000 | |||
423 | @@ -0,0 +1,42 @@ | |||
424 | 1 | /* | ||
425 | 2 | * Copyright 2015 Canonical Ltd. | ||
426 | 3 | * | ||
427 | 4 | * This program is free software; you can redistribute it and/or modify | ||
428 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
429 | 6 | * the Free Software Foundation; version 3. | ||
430 | 7 | * | ||
431 | 8 | * This program is distributed in the hope that it will be useful, | ||
432 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
433 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
434 | 11 | * GNU Lesser General Public License for more details. | ||
435 | 12 | * | ||
436 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
437 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
438 | 15 | */ | ||
439 | 16 | |||
440 | 17 | import QtQuick 2.4 | ||
441 | 18 | import Ubuntu.Components 1.3 | ||
442 | 19 | |||
443 | 20 | MainView { | ||
444 | 21 | width: units.gu(48) | ||
445 | 22 | height: units.gu(60) | ||
446 | 23 | objectName: "mainView" | ||
447 | 24 | Page { | ||
448 | 25 | title: "Sections test" | ||
449 | 26 | Label { | ||
450 | 27 | id: label | ||
451 | 28 | objectName: "label" | ||
452 | 29 | anchors { | ||
453 | 30 | top: parent.top | ||
454 | 31 | horizontalCenter: parent.horizontalCenter | ||
455 | 32 | } | ||
456 | 33 | text: "Section " + sections.selectedIndex + " is selected." | ||
457 | 34 | } | ||
458 | 35 | Sections { | ||
459 | 36 | id: sections | ||
460 | 37 | objectName: "sections" | ||
461 | 38 | anchors.centerIn: parent | ||
462 | 39 | model: [ "first", "second", "third" ] | ||
463 | 40 | } | ||
464 | 41 | } | ||
465 | 42 | } | ||
466 | 0 | 43 | ||
467 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.py' | |||
468 | --- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.py 1970-01-01 00:00:00 +0000 | |||
469 | +++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_sections.py 2015-06-17 12:24:49 +0000 | |||
470 | @@ -0,0 +1,51 @@ | |||
471 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
472 | 2 | # | ||
473 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
474 | 4 | # | ||
475 | 5 | # This program is free software; you can redistribute it and/or modify | ||
476 | 6 | # it under the terms of the GNU Lesser General Public License as published by | ||
477 | 7 | # the Free Software Foundation; version 3. | ||
478 | 8 | # | ||
479 | 9 | # This program is distributed in the hope that it will be useful, | ||
480 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
481 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
482 | 12 | # GNU Lesser General Public License for more details. | ||
483 | 13 | # | ||
484 | 14 | # You should have received a copy of the GNU Lesser General Public License | ||
485 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
486 | 16 | |||
487 | 17 | import os | ||
488 | 18 | import ubuntuuitoolkit | ||
489 | 19 | from ubuntuuitoolkit import tests | ||
490 | 20 | |||
491 | 21 | |||
492 | 22 | class SectionsTestCase(tests.QMLFileAppTestCase): | ||
493 | 23 | |||
494 | 24 | path = os.path.abspath(__file__) | ||
495 | 25 | dir_path = os.path.dirname(path) | ||
496 | 26 | test_qml_file_path = os.path.join( | ||
497 | 27 | dir_path, 'test_sections.SectionsTestCase.qml') | ||
498 | 28 | |||
499 | 29 | def setUp(self): | ||
500 | 30 | super().setUp() | ||
501 | 31 | self.sections = self.app.select_single( | ||
502 | 32 | 'Sections', objectName='sections') | ||
503 | 33 | self.label = self.app.select_single( | ||
504 | 34 | 'Label', objectName='label') | ||
505 | 35 | self.assertEqual(self.label.text, 'Section 0 is selected.') | ||
506 | 36 | |||
507 | 37 | def test_custom_proxy_object(self): | ||
508 | 38 | self.assertIsInstance(self.sections, ubuntuuitoolkit.Sections) | ||
509 | 39 | self.assertTrue(self.sections.visible) | ||
510 | 40 | |||
511 | 41 | def test_click_section_button(self): | ||
512 | 42 | self.sections.click_section_button(2) | ||
513 | 43 | self.assertEqual(self.label.text, 'Section 2 is selected.') | ||
514 | 44 | |||
515 | 45 | def test_click_unexisting_section_button(self): | ||
516 | 46 | error = self.assertRaises( | ||
517 | 47 | ubuntuuitoolkit.ToolkitException, | ||
518 | 48 | self.sections.click_section_button, 3) | ||
519 | 49 | self.assertEqual( | ||
520 | 50 | str(error), | ||
521 | 51 | 'Button not found in Sections.') | ||
522 | 0 | 52 | ||
523 | === added file 'tests/unit_x11/tst_components/tst_sections.qml' | |||
524 | --- tests/unit_x11/tst_components/tst_sections.qml 1970-01-01 00:00:00 +0000 | |||
525 | +++ tests/unit_x11/tst_components/tst_sections.qml 2015-06-17 12:24:49 +0000 | |||
526 | @@ -0,0 +1,309 @@ | |||
527 | 1 | /* | ||
528 | 2 | * Copyright 2015 Canonical Ltd. | ||
529 | 3 | * | ||
530 | 4 | * This program is free software; you can redistribute it and/or modify | ||
531 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
532 | 6 | * the Free Software Foundation; version 3. | ||
533 | 7 | * | ||
534 | 8 | * This program is distributed in the hope that it will be useful, | ||
535 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
536 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
537 | 11 | * GNU Lesser General Public License for more details. | ||
538 | 12 | * | ||
539 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
540 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
541 | 15 | */ | ||
542 | 16 | |||
543 | 17 | import QtQuick 2.4 | ||
544 | 18 | import Ubuntu.Test 1.0 | ||
545 | 19 | import Ubuntu.Components 1.3 | ||
546 | 20 | |||
547 | 21 | Rectangle { | ||
548 | 22 | id: root | ||
549 | 23 | width: 400 | ||
550 | 24 | height: 600 | ||
551 | 25 | color: "white" | ||
552 | 26 | |||
553 | 27 | property list<Action> actionList: [ | ||
554 | 28 | Action { | ||
555 | 29 | text: "first"; | ||
556 | 30 | onTriggered: label.text = "First action triggered."; | ||
557 | 31 | }, | ||
558 | 32 | Action { | ||
559 | 33 | text: "second"; | ||
560 | 34 | onTriggered: label.text = "Second action triggered."; | ||
561 | 35 | }, | ||
562 | 36 | Action { | ||
563 | 37 | text: "third"; | ||
564 | 38 | onTriggered: label.text = "Third action triggered."; | ||
565 | 39 | } | ||
566 | 40 | ] | ||
567 | 41 | |||
568 | 42 | property var stringList: [ | ||
569 | 43 | "string one", "string two", "string three" | ||
570 | 44 | ] | ||
571 | 45 | |||
572 | 46 | Column { | ||
573 | 47 | id: column | ||
574 | 48 | anchors { | ||
575 | 49 | left: parent.left | ||
576 | 50 | right: parent.right | ||
577 | 51 | top: parent.top | ||
578 | 52 | margins: units.gu(2) | ||
579 | 53 | } | ||
580 | 54 | spacing: units.gu(2) | ||
581 | 55 | |||
582 | 56 | Label { | ||
583 | 57 | anchors.horizontalCenter: parent.horizontalCenter | ||
584 | 58 | text: "Sections with actions" | ||
585 | 59 | } | ||
586 | 60 | Label { | ||
587 | 61 | anchors.left: parent.left | ||
588 | 62 | text: "actions in-line:" | ||
589 | 63 | fontSize: small | ||
590 | 64 | } | ||
591 | 65 | Sections { | ||
592 | 66 | // Not used in the tests below, but added here to | ||
593 | 67 | // verify that the Actions can be defined directly | ||
594 | 68 | // inside the list of actions. | ||
595 | 69 | actions: [ | ||
596 | 70 | Action { text: "1" }, | ||
597 | 71 | Action { text: "2" } | ||
598 | 72 | ] | ||
599 | 73 | } | ||
600 | 74 | Label { | ||
601 | 75 | anchors.left: parent.left | ||
602 | 76 | text: "enabled:" | ||
603 | 77 | fontSize: "small" | ||
604 | 78 | } | ||
605 | 79 | Sections { | ||
606 | 80 | id: enabledSections | ||
607 | 81 | actions: root.actionList | ||
608 | 82 | } | ||
609 | 83 | Label { | ||
610 | 84 | text: "disabled:" | ||
611 | 85 | fontSize: "small" | ||
612 | 86 | } | ||
613 | 87 | Sections { | ||
614 | 88 | id: disabledSections | ||
615 | 89 | actions: root.actionList | ||
616 | 90 | enabled: false | ||
617 | 91 | } | ||
618 | 92 | Rectangle { | ||
619 | 93 | anchors { | ||
620 | 94 | left: parent.left | ||
621 | 95 | right: parent.right | ||
622 | 96 | margins: units.gu(2) | ||
623 | 97 | } | ||
624 | 98 | color: UbuntuColors.blue | ||
625 | 99 | height: units.gu(10) | ||
626 | 100 | Label { | ||
627 | 101 | id: label | ||
628 | 102 | anchors.centerIn: parent | ||
629 | 103 | text: "No action triggered." | ||
630 | 104 | color: "white" | ||
631 | 105 | } | ||
632 | 106 | } | ||
633 | 107 | Label { | ||
634 | 108 | anchors.horizontalCenter: parent.horizontalCenter | ||
635 | 109 | text: "Sections with strings" | ||
636 | 110 | } | ||
637 | 111 | Label { | ||
638 | 112 | anchors.left: parent.left | ||
639 | 113 | text: "enabled:" | ||
640 | 114 | fontSize: "small" | ||
641 | 115 | } | ||
642 | 116 | Sections { | ||
643 | 117 | id: enabledStringSections | ||
644 | 118 | model: root.stringList | ||
645 | 119 | } | ||
646 | 120 | Label { | ||
647 | 121 | anchors.left: parent.left | ||
648 | 122 | text: "disabled:" | ||
649 | 123 | fontSize: "small" | ||
650 | 124 | } | ||
651 | 125 | Sections { | ||
652 | 126 | id: disabledStringSections | ||
653 | 127 | model: root.stringList | ||
654 | 128 | enabled: false | ||
655 | 129 | } | ||
656 | 130 | } | ||
657 | 131 | |||
658 | 132 | UbuntuTestCase { | ||
659 | 133 | id: testCase | ||
660 | 134 | name: "SectionsApi" | ||
661 | 135 | when: windowShown | ||
662 | 136 | |||
663 | 137 | function initTestCase() { | ||
664 | 138 | compare(label.text, "No action triggered.", "An action was triggered initially."); | ||
665 | 139 | } | ||
666 | 140 | |||
667 | 141 | function cleanup() { | ||
668 | 142 | enabledSections.selectedIndex = 0; | ||
669 | 143 | disabledSections.selectedIndex = 0; | ||
670 | 144 | enabledStringSections.selectedIndex = 0; | ||
671 | 145 | disabledStringSections.selectedIndex = 0; | ||
672 | 146 | } | ||
673 | 147 | |||
674 | 148 | function wait_for_animation(sections) { | ||
675 | 149 | // TODO when animations are added | ||
676 | 150 | } | ||
677 | 151 | |||
678 | 152 | function get_number_of_section_buttons(sections) { | ||
679 | 153 | var repeater = findChild(sections, "sections_repeater"); | ||
680 | 154 | return repeater.count; | ||
681 | 155 | } | ||
682 | 156 | |||
683 | 157 | // return the index of the selected section button, | ||
684 | 158 | // or -1 if no selected section button is found. | ||
685 | 159 | function get_selected_section_button_index(sections) { | ||
686 | 160 | var n = get_number_of_section_buttons(sections); | ||
687 | 161 | var button; | ||
688 | 162 | for (var i=0; i < n; i++) { | ||
689 | 163 | button = findChild(sections, "section_button_"+i); | ||
690 | 164 | if (button.selected) { | ||
691 | 165 | return i; | ||
692 | 166 | } | ||
693 | 167 | } | ||
694 | 168 | return -1; | ||
695 | 169 | } | ||
696 | 170 | |||
697 | 171 | function get_selected_section_button_text(sections) { | ||
698 | 172 | var index = get_selected_section_button_index(sections); | ||
699 | 173 | if (index < 0) return "BUTTON NOT FOUND."; | ||
700 | 174 | var button = findChild(sections, "section_button_label_"+index); | ||
701 | 175 | return button.text; | ||
702 | 176 | } | ||
703 | 177 | |||
704 | 178 | function click_section_button(sections, sectionName) { | ||
705 | 179 | var index = -1; | ||
706 | 180 | var object; | ||
707 | 181 | for (index = 0; index < sections.model.length; index++) { | ||
708 | 182 | object = sections.model[index]; | ||
709 | 183 | // object may be a string or an Action | ||
710 | 184 | if (object.hasOwnProperty("text")) { | ||
711 | 185 | if (object.text === sectionName) { | ||
712 | 186 | break; | ||
713 | 187 | } | ||
714 | 188 | } else { | ||
715 | 189 | if (object === sectionName) { | ||
716 | 190 | break; | ||
717 | 191 | } | ||
718 | 192 | } | ||
719 | 193 | } | ||
720 | 194 | verify(index >= 0, "Button with name \'"+sectionName+"\' not found."); | ||
721 | 195 | var button = findChild(sections, "section_button_"+index); | ||
722 | 196 | mouseClick(button, button.width/2, button.height/2); | ||
723 | 197 | } | ||
724 | 198 | |||
725 | 199 | function check_selected_section(sections, index, name) { | ||
726 | 200 | var v = sections.selectedIndex; | ||
727 | 201 | compare(v, index, "selectedIndex "+v+" does not match "+index); | ||
728 | 202 | v = get_selected_section_button_index(sections); | ||
729 | 203 | compare(v, index, "selected button index "+v+" does not match "+index); | ||
730 | 204 | var w = get_selected_section_button_text(sections); | ||
731 | 205 | compare(w, name, "selected button text \'"+w+"\' does not match \'"+name+"\'"); | ||
732 | 206 | } | ||
733 | 207 | |||
734 | 208 | // in each test function below, test the desired behavior | ||
735 | 209 | // for both enabledSections and disabledSections. | ||
736 | 210 | |||
737 | 211 | function test_0_first_section_initially_selected_actions_enabled() { | ||
738 | 212 | check_selected_section(enabledSections, 0, "first"); | ||
739 | 213 | } | ||
740 | 214 | function test_0_first_section_initially_selected_actions_disabled() { | ||
741 | 215 | check_selected_section(disabledSections, 0, "first"); | ||
742 | 216 | } | ||
743 | 217 | function test_0_first_section_initially_selected_strings_enabled() { | ||
744 | 218 | check_selected_section(enabledStringSections, 0, "string one"); | ||
745 | 219 | } | ||
746 | 220 | function test_0_first_section_initially_selected_strings_disabled() { | ||
747 | 221 | check_selected_section(disabledStringSections, 0, "string one"); | ||
748 | 222 | } | ||
749 | 223 | |||
750 | 224 | function test_number_of_section_buttons() { | ||
751 | 225 | var n = root.actionList.length; | ||
752 | 226 | compare(get_number_of_section_buttons(enabledSections), n, | ||
753 | 227 | "Showing incorrect number of sections."); | ||
754 | 228 | compare(get_number_of_section_buttons(disabledSections), n, | ||
755 | 229 | "Showing incorrect number of disabled sections.") | ||
756 | 230 | } | ||
757 | 231 | |||
758 | 232 | function test_click_to_select_section_and_trigger_action() { | ||
759 | 233 | var index = 2; | ||
760 | 234 | var name = "third"; | ||
761 | 235 | click_section_button(enabledSections, name); | ||
762 | 236 | wait_for_animation(enabledSections); | ||
763 | 237 | check_selected_section(enabledSections, index, name); | ||
764 | 238 | var text = "Third action triggered."; | ||
765 | 239 | compare(label.text, text, "Action for clicked button not triggered."); | ||
766 | 240 | } | ||
767 | 241 | |||
768 | 242 | function test_click_disabled_section_action() { | ||
769 | 243 | var index = 2; | ||
770 | 244 | var name = "third"; | ||
771 | 245 | click_section_button(disabledSections, name); | ||
772 | 246 | wait_for_animation(disabledSections); | ||
773 | 247 | // first button should still be selected: | ||
774 | 248 | index = 0; | ||
775 | 249 | name = "first"; | ||
776 | 250 | check_selected_section(disabledSections, index, name); | ||
777 | 251 | var text = "No action triggered."; | ||
778 | 252 | compare(label.text, text, "Clicking disabled button triggered something."); | ||
779 | 253 | } | ||
780 | 254 | |||
781 | 255 | function test_click_to_select_section_string() { | ||
782 | 256 | var index = 2; | ||
783 | 257 | var name = "string three"; | ||
784 | 258 | click_section_button(enabledStringSections, name); | ||
785 | 259 | wait_for_animation(enabledStringSections); | ||
786 | 260 | check_selected_section(enabledStringSections, index, name); | ||
787 | 261 | } | ||
788 | 262 | |||
789 | 263 | function test_click_disabled_section_string() { | ||
790 | 264 | var name = "string three"; | ||
791 | 265 | click_section_button(disabledStringSections, name); | ||
792 | 266 | wait_for_animation(disabledStringSections); | ||
793 | 267 | // first button should still be selected: | ||
794 | 268 | var index = 0; | ||
795 | 269 | name = "string one"; | ||
796 | 270 | check_selected_section(disabledStringSections, index, name); | ||
797 | 271 | } | ||
798 | 272 | |||
799 | 273 | function test_set_selectedIndex_to_select_section_and_trigger_action_enabled() { | ||
800 | 274 | var index = 1; | ||
801 | 275 | var name = "second"; | ||
802 | 276 | enabledSections.selectedIndex = index; | ||
803 | 277 | wait_for_animation(enabledSections); | ||
804 | 278 | check_selected_section(enabledSections, index, name); | ||
805 | 279 | var text = "Second action triggered."; | ||
806 | 280 | compare(label.text, text, "Changing selected index did not trigger action."); | ||
807 | 281 | } | ||
808 | 282 | |||
809 | 283 | function test_set_selectedIndex_to_select_section_and_trigger_action_disabled() { | ||
810 | 284 | var index = 2; | ||
811 | 285 | var name = "third"; | ||
812 | 286 | disabledSections.selectedIndex = index; | ||
813 | 287 | wait_for_animation(disabledSections); | ||
814 | 288 | check_selected_section(disabledSections, index, name); | ||
815 | 289 | var text = "Third action triggered."; | ||
816 | 290 | compare(label.text, text, "Changing selected index for disabled Sections " + | ||
817 | 291 | "did not trigger action."); | ||
818 | 292 | } | ||
819 | 293 | |||
820 | 294 | function test_set_selectedIndex_to_select_section_string_enabled() { | ||
821 | 295 | var index = 1; | ||
822 | 296 | var name = "string two"; | ||
823 | 297 | enabledStringSections.selectedIndex = index; | ||
824 | 298 | wait_for_animation(enabledStringSections); | ||
825 | 299 | check_selected_section(enabledStringSections, index, name); | ||
826 | 300 | } | ||
827 | 301 | |||
828 | 302 | function test_set_selectedIndex_to_select_section_string_disabled() { | ||
829 | 303 | var index = 2; | ||
830 | 304 | var name = "string three"; | ||
831 | 305 | disabledStringSections.selectedIndex = index; | ||
832 | 306 | check_selected_section(disabledStringSections, index, name); | ||
833 | 307 | } | ||
834 | 308 | } | ||
835 | 309 | } |
FAILED: Continuous integration, rev:1539 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1814/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 3007 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-amd64- ci/542 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/544 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/544/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-i386- ci/541 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 2561 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 3005 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 3005/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 20824
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1814/ rebuild
http://