Merge lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal2 into lp:ubuntu-ui-toolkit
- toolbar-reveal2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Cris Dywan |
Approved revision: | 778 |
Merged at revision: | 805 |
Proposed branch: | lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal2 |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
278 lines (+89/-43) 6 files modified
components.api (+1/-0) modules/Ubuntu/Components/Toolbar.qml (+33/-16) modules/Ubuntu/Components/ToolbarItems.qml (+4/-1) tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+27/-16) tests/unit/tst_components/tst_toolbaritems.qml (+4/-4) tests/unit_x11/tst_components/tst_toolbar.qml (+20/-6) |
To merge this branch: | bzr merge lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal2 |
Related bugs: | |
Related blueprints: |
New toolbar open/close behavior
(Medium)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Leo Arias (community) | code review | Needs Fixing | |
Review via email: mp+184678@code.launchpad.net |
Commit message
Initially show toolbar, but automatically hide after timeout.
Description of the change
Update toolbar reveal/hide behavior, as specified by design. Initially show toolbar, but automatically hide after timeout.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:762
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:763
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:764
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
Tim Peeters (tpeeters) wrote : | # |
open_toolbar() in our emulators does the right thing, it only swipes in the toolbar when it is not already opened. So apps autopilot tests using that should be fine.
Leo Arias (elopio) wrote : | # |
I think some emulator tests should be updated to take this into account.
test_toolbar_
It does self.assertFals
You can change it to self.assertThat
On all the ToolbarTestCase tests, it would be better if we wait for the toolbar to hide.
You can add a setUp with: self.toolbar = self.main_
There might be a case where things can go wrong. What would happen if we check toolbar.visible while it's on the process of being hidden? If it is False just when it's starting to hide, I think the emulator will show it again properly without problems. If it's False until it's completely hidden, then the emulator will do nothing and we will see failures.
Tim Peeters (tpeeters) wrote : | # |
I don't think we should wait for the toolbar to be hidden. This is currently 5 seconds, but it can change depending on what design comes up with. Why not have no assumptions on whether it is opened, and open it when it is needed and not opened?
Leo Arias (elopio) wrote : | # |
Yes, that's how the emulator works. But I'm referring to the self-tests we have on test_emulators.py.
For example, on test_open_toolbar, if we don't wait for the toolbar to be closed, we will not be testing the action that swipes up to open the toolbar. We will still have test_opened_
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:767
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:767
http://
Executed test runs:
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:768
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
There's no test case for the new timeout property - it should be tested if it's meant to be used by apps, otherwise I would prefer to hide the API from apps or make it readonly.
I still see no testcase checking that the toolbar is truly hidden, though it was mentioned in the comments already. I'd say we want to check both API and the fact that it's not visible.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:774
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:774
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:775
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:775
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 776. By Tim Peeters
-
sleep() seems to stop the Timer. Use wait() in tests instead
- 777. By Tim Peeters
-
remove debugging code
- 778. By Tim Peeters
-
clean
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:778
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
I like the update!
Locally I'm getting 1 failure in ubuntuuitoolkit
MismatchError: String(u'Button not clicked.') != 'Button clicked.'
Tim Peeters (tpeeters) wrote : | # |
For me the autopilot tests work fine on PC:
Cris Dywan (kalikiana) wrote : | # |
All pass with a new checkout in another folder. Well, seems good then.
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2013-10-18 02:41:30 +0000 |
3 | +++ components.api 2013-10-21 17:30:28 +0000 |
4 | @@ -357,6 +357,7 @@ |
5 | modules/Ubuntu/Components/Toolbar.qml |
6 | Panel |
7 | property Item tools |
8 | + property int hideTimeout |
9 | modules/Ubuntu/Components/ToolbarButton.qml |
10 | ActionItem |
11 | modules/Ubuntu/Components/ToolbarItems.qml |
12 | |
13 | === modified file 'modules/Ubuntu/Components/Toolbar.qml' |
14 | --- modules/Ubuntu/Components/Toolbar.qml 2013-09-04 14:39:00 +0000 |
15 | +++ modules/Ubuntu/Components/Toolbar.qml 2013-10-21 17:30:28 +0000 |
16 | @@ -39,34 +39,51 @@ |
17 | */ |
18 | property Item tools: null |
19 | |
20 | + /*! |
21 | + \preliminary |
22 | + The time in milliseconds before the toolbar automatically hides after inactivity |
23 | + when it is not locked. |
24 | + */ |
25 | + property int hideTimeout: 5000 |
26 | + |
27 | /*! \internal */ |
28 | onToolsChanged: { |
29 | - if (tools && tools.hasOwnProperty("locked")) locked = tools.locked; |
30 | - if (tools && tools.hasOwnProperty("locked") && tools.hasOwnProperty("opened") |
31 | - && tools.opened && tools.locked) { |
32 | - // toolbar is locked in visible state. |
33 | - internal.updateVisibleTools(); |
34 | - toolbar.open(); |
35 | - } else if (!opened && !animating) { |
36 | - // toolbar is closed |
37 | - internal.updateVisibleTools(); |
38 | - } else { |
39 | - toolbar.close() |
40 | - // internal.visibleTools will be updated |
41 | - // when the hide animation is finished |
42 | - } |
43 | - if (tools && tools.hasOwnProperty("opened")) { |
44 | - tools.opened = toolbar.opened; |
45 | + internal.updateVisibleTools(); |
46 | + if (tools) { |
47 | + if (tools && tools.hasOwnProperty("locked")) locked = tools.locked; |
48 | + // open the toolbar, except when it is locked in closed position |
49 | + if (tools && tools.hasOwnProperty("locked") && tools.hasOwnProperty("opened") |
50 | + && !tools.opened && tools.locked) { |
51 | + // toolbar is locked in closed state |
52 | + toolbar.close(); |
53 | + } else { |
54 | + toolbar.open(); |
55 | + } |
56 | + |
57 | + if (tools && tools.hasOwnProperty("opened")) { |
58 | + tools.opened = toolbar.opened; |
59 | + } |
60 | + } else { // no tools |
61 | + locked = true; |
62 | + toolbar.close(); |
63 | } |
64 | } |
65 | |
66 | // if tools is not specified, lock the toolbar in closed position |
67 | locked: tools && tools.hasOwnProperty("locked") ? tools.locked : false |
68 | |
69 | + Timer { |
70 | + id: hideTimer |
71 | + interval: toolbar.hideTimeout |
72 | + running: toolbar.opened && !toolbar.locked |
73 | + onTriggered: toolbar.close() |
74 | + } |
75 | + |
76 | onOpenedChanged: { |
77 | if (tools && tools.hasOwnProperty("opened")) { |
78 | tools.opened = toolbar.opened; |
79 | } |
80 | + if (!toolbar.locked) hideTimer.restart() |
81 | } |
82 | |
83 | Connections { |
84 | |
85 | === modified file 'modules/Ubuntu/Components/ToolbarItems.qml' |
86 | --- modules/Ubuntu/Components/ToolbarItems.qml 2013-10-14 16:37:43 +0000 |
87 | +++ modules/Ubuntu/Components/ToolbarItems.qml 2013-10-21 17:30:28 +0000 |
88 | @@ -155,7 +155,10 @@ |
89 | property Item pageStack: null |
90 | |
91 | /*! |
92 | - The toolbar is opened |
93 | + The toolbar is opened. |
94 | + When the toolbar is not locked, this value is automatically updated |
95 | + when the toolbar is opened/closed by user interaction or by other events (such as changing |
96 | + the active \l Page). |
97 | */ |
98 | property bool opened: false |
99 | |
100 | |
101 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py' |
102 | --- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-10-14 16:40:43 +0000 |
103 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-10-21 17:30:28 +0000 |
104 | @@ -58,7 +58,10 @@ |
105 | def test_toolbar_custom_emulator(self): |
106 | toolbar = self.main_view.get_toolbar() |
107 | self.assertIsInstance(toolbar, emulators.Toolbar) |
108 | - self.assertFalse(toolbar.opened) |
109 | + |
110 | + def test_open_toolbar_returns_the_toolbar(self): |
111 | + toolbar = self.main_view.open_toolbar() |
112 | + self.assertIsInstance(toolbar, emulators.Toolbar) |
113 | |
114 | def test_get_tabs_without_tabs(self): |
115 | error = self.assertRaises( |
116 | @@ -107,6 +110,11 @@ |
117 | width: units.gu(50) |
118 | height: units.gu(50) |
119 | |
120 | + // Make sure that for these tests the toolbar starts closed. |
121 | + Component.onCompleted: { |
122 | + __propagated.toolbar.close(); |
123 | + } |
124 | + |
125 | Page { |
126 | |
127 | Label { |
128 | @@ -124,32 +132,35 @@ |
129 | onTriggered: label.text = "Button clicked." |
130 | } |
131 | } |
132 | - locked: false |
133 | - opened: false |
134 | } |
135 | } |
136 | } |
137 | """) |
138 | |
139 | + def setUp(self): |
140 | + super(ToolbarTestCase, self).setUp() |
141 | + self.toolbar = self.main_view.get_toolbar() |
142 | + self.assertFalse(self.toolbar.opened) |
143 | + |
144 | def test_open_toolbar(self): |
145 | - toolbar = self.main_view.open_toolbar() |
146 | - self.assertTrue(toolbar.opened) |
147 | - self.assertFalse(toolbar.animating) |
148 | + self.main_view.open_toolbar() |
149 | + self.assertTrue(self.toolbar.opened) |
150 | + self.assertFalse(self.toolbar.animating) |
151 | |
152 | def test_opened_toolbar_is_not_opened_again(self): |
153 | - toolbar = self.main_view.open_toolbar() |
154 | + self.main_view.open_toolbar() |
155 | with mock.patch.object( |
156 | self.main_view.pointing_device, 'drag') as mock_drag: |
157 | self.main_view.open_toolbar() |
158 | |
159 | self.assertFalse(mock_drag.called) |
160 | - self.assertTrue(toolbar.opened) |
161 | + self.assertTrue(self.toolbar.opened) |
162 | |
163 | def test_close_toolbar(self): |
164 | - toolbar = self.main_view.open_toolbar() |
165 | + self.main_view.open_toolbar() |
166 | self.main_view.close_toolbar() |
167 | - self.assertFalse(toolbar.opened) |
168 | - self.assertFalse(toolbar.animating) |
169 | + self.assertFalse(self.toolbar.opened) |
170 | + self.assertFalse(self.toolbar.animating) |
171 | |
172 | def test_closed_toolbar_is_not_closed_again(self): |
173 | with mock.patch.object( |
174 | @@ -157,19 +168,19 @@ |
175 | self.main_view.close_toolbar() |
176 | |
177 | self.assertFalse(mock_drag.called) |
178 | - self.assertFalse(self.main_view.get_toolbar().opened) |
179 | + self.assertFalse(self.toolbar.opened) |
180 | |
181 | def test_click_toolbar_button(self): |
182 | label = self.app.select_single('Label', objectName='clicked_label') |
183 | self.assertNotEqual(label.text, 'Button clicked.') |
184 | - toolbar = self.main_view.open_toolbar() |
185 | - toolbar.click_button('buttonName') |
186 | + self.main_view.open_toolbar() |
187 | + self.toolbar.click_button('buttonName') |
188 | self.assertEqual(label.text, 'Button clicked.') |
189 | |
190 | def test_click_unexisting_button(self): |
191 | - toolbar = self.main_view.open_toolbar() |
192 | + self.main_view.open_toolbar() |
193 | error = self.assertRaises( |
194 | - ValueError, toolbar.click_button, 'unexisting') |
195 | + ValueError, self.toolbar.click_button, 'unexisting') |
196 | self.assertEqual( |
197 | error.message, 'Button with objectName "unexisting" not found.') |
198 | |
199 | |
200 | === modified file 'tests/unit/tst_components/tst_toolbaritems.qml' |
201 | --- tests/unit/tst_components/tst_toolbaritems.qml 2013-09-03 10:51:40 +0000 |
202 | +++ tests/unit/tst_components/tst_toolbaritems.qml 2013-10-21 17:30:28 +0000 |
203 | @@ -61,11 +61,11 @@ |
204 | } |
205 | |
206 | function test_opened() { |
207 | - compare(toolbarItems.opened, false, "Toolbar items initially closed"); |
208 | + compare(toolbarItems.opened, true, "Toolbar items initially opened"); |
209 | + toolbarItems.opened = false; |
210 | + compare(toolbarItems.opened, false, "Toolbar items can be closed"); |
211 | toolbarItems.opened = true; |
212 | - compare(toolbarItems.opened, true, "Toolbar items can be made opened"); |
213 | - toolbarItems.opened = false; |
214 | - compare(toolbarItems.opened, false, "Toolbar items can be made closed"); |
215 | + compare(toolbarItems.opened, true, "Toolbar items can be opened"); |
216 | } |
217 | |
218 | function test_locked() { |
219 | |
220 | === renamed file 'tests/unit/tst_components/tst_toolbar.qml' => 'tests/unit_x11/tst_components/tst_toolbar.qml' |
221 | --- tests/unit/tst_components/tst_toolbar.qml 2013-09-09 19:27:26 +0000 |
222 | +++ tests/unit_x11/tst_components/tst_toolbar.qml 2013-10-21 17:30:28 +0000 |
223 | @@ -19,14 +19,21 @@ |
224 | import Ubuntu.Components 0.1 |
225 | |
226 | Item { |
227 | - width: 200 |
228 | - height: 200 |
229 | + width: units.gu(50) |
230 | + height: units.gu(80) |
231 | |
232 | MainView { |
233 | anchors.fill: parent |
234 | + width: units.gu(50) |
235 | + height: units.gu(80) |
236 | id: mainView |
237 | Page { |
238 | id: page |
239 | + title: "test page" |
240 | + Label { |
241 | + anchors.centerIn: parent |
242 | + text: "testing the toolbar" |
243 | + } |
244 | tools: ToolbarItems { |
245 | id: toolbarItems |
246 | ToolbarButton { |
247 | @@ -43,13 +50,12 @@ |
248 | function initTestCase() { |
249 | compare(page.tools, toolbarItems, "Page tools are set initially"); |
250 | compare(page.__propagated, mainView.__propagated, "propagated property is propagated from mainView to page") |
251 | - compare(mainView.__propagated.toolbar.tools, page.tools, "Toolbar tools are set to page tools initially"); |
252 | - compare(mainView.__propagated.toolbar.tools.opened, false, "Toolbar is closed initially"); |
253 | - compare(mainView.__propagated.toolbar.tools.locked, false, "Toolbar is initially not locked"); |
254 | + compare(mainView.__propagated.toolbar.tools, toolbarItems, "Toolbar tools are set to page tools initially"); |
255 | + compare(toolbarItems.opened, true, "Toolbar is opened initially"); |
256 | + compare(toolbarItems.locked, false, "Toolbar is initially not locked"); |
257 | } |
258 | |
259 | function test_opened() { |
260 | - compare(mainView.__propagated.toolbar.tools.opened, false, "Toolbar initially closed"); |
261 | mainView.__propagated.toolbar.open() |
262 | compare(mainView.__propagated.toolbar.opened, true, "Toolbar can be made opened"); |
263 | mainView.__propagated.toolbar.close(); |
264 | @@ -60,6 +66,14 @@ |
265 | compare(mainView.__propagated.toolbar.opened, false, "Toolbar can be made closed by setting page.tools.opened to false"); |
266 | } |
267 | |
268 | + function test_hideTimeout() { |
269 | + compare(mainView.__propagated.toolbar.hideTimeout, 5000, "Toolbar hide timeout is initially 5 seconds."); |
270 | + mainView.__propagated.toolbar.open(); |
271 | + compare(mainView.__propagated.toolbar.opened, true, "Toolbar can be made opened"); |
272 | + wait(mainView.__propagated.toolbar.hideTimeout + 500); // add 500 ms margin |
273 | + compare(mainView.__propagated.toolbar.opened, false, "Toolbar automatically closes after timeout"); |
274 | + } |
275 | + |
276 | function test_locked() { |
277 | compare(mainView.__propagated.toolbar.tools.locked, false, "Toolbar initially not locked"); |
278 | mainView.__propagated.toolbar.locked = true; |
FAILED: Continuous integration, rev:761 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/626/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- saucy/3215 jenkins. qa.ubuntu. com/job/ generic- mediumtests- touch/758 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-amd64- ci/483/ console jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/483 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/483/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-i386/ 3221 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-i386/ 3221/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- saucy/2709 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 760 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 760/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- maguro/ 626 jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/637
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- ui-toolkit- ci/626/ rebuild
http://