Merge lp:~tpeeters/ubuntu-ui-toolkit/ensureVisible into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1345
Merged at revision: 1343
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/ensureVisible
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 154 lines (+79/-7)
3 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py (+7/-7)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HideShowTestCase.qml (+44/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+28/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/ensureVisible
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Leo Arias (community) code review Approve
Review via email: mp+242674@code.launchpad.net

Commit message

Add ensure_visible() function to header AP helper.

To post a comment you must log in.
1342. By Tim Peeters

add comment

1343. By Tim Peeters

flake8

1344. By Tim Peeters

remove _show_if_not_visible()

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

136 + def test_show_header(self):

It would be clearer if you rename this test to test_ensure_header_visible_must_show_it_when_not_visible

137 + """Test that header.ensure_visible() shows the header.
138 + """

It will look a little better if you put the closing quotes in the same line. Also, that's a rule from pep 257 for one-line docstrings. We are not currently enforcing pep257, but it makes the code look nicer.

Other than that, it looks good. Thanks!
You have a pep8 error that's making the tests fail. Please fix it and make sure that the tests pass before merging. I will leave you my approval here.

review: Approve (code review)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1345. By Tim Peeters

Leo's review comments

Revision history for this message
Zsombor Egri (zsombi) wrote :

Looks good. Thx!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py'
2--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-09-18 15:04:43 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-11-25 10:38:20 +0000
4@@ -34,7 +34,7 @@
5 class AppHeader(_common.UbuntuUIToolkitCustomProxyObjectBase):
6 """AppHeader Autopilot custom proxy object."""
7
8- def _show_if_not_visible(self):
9+ def ensure_visible(self):
10 if not self._is_visible():
11 self._show()
12
13@@ -67,7 +67,7 @@
14 range or useDeprecatedToolbar is set.
15
16 """
17- self._show_if_not_visible()
18+ self.ensure_visible()
19
20 if self.useDeprecatedToolbar:
21 raise _common.ToolkitException('Old header has no sections')
22@@ -92,7 +92,7 @@
23 return sectionsProperties.selectedIndex
24
25 def click_back_button(self):
26- self._show_if_not_visible()
27+ self.ensure_visible()
28
29 if self.useDeprecatedToolbar:
30 raise _common.ToolkitException('Old header has no back button')
31@@ -107,7 +107,7 @@
32 self.wait_for_animation()
33
34 def click_custom_back_button(self):
35- self._show_if_not_visible()
36+ self.ensure_visible()
37
38 if self.useDeprecatedToolbar:
39 raise _common.ToolkitException(
40@@ -139,7 +139,7 @@
41 :raise ToolkitException: If the main view has no tabs.
42
43 """
44- self._show_if_not_visible()
45+ self.ensure_visible()
46
47 if self.useDeprecatedToolbar:
48 self._switch_to_next_tab_in_deprecated_tabbar()
49@@ -171,7 +171,7 @@
50 of range or useDeprecatedToolbar is set.
51
52 """
53- self._show_if_not_visible()
54+ self.ensure_visible()
55
56 if self.useDeprecatedToolbar:
57 raise _common.ToolkitException(
58@@ -211,7 +211,7 @@
59 name.
60
61 """
62- self._show_if_not_visible()
63+ self.ensure_visible()
64
65 button = self._get_action_button(action_object_name)
66 self.pointing_device.click_object(button)
67
68=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HideShowTestCase.qml'
69--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HideShowTestCase.qml 1970-01-01 00:00:00 +0000
70+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HideShowTestCase.qml 2014-11-25 10:38:20 +0000
71@@ -0,0 +1,44 @@
72+/*
73+ * Copyright 2014 Canonical Ltd.
74+ *
75+ * This program is free software; you can redistribute it and/or modify
76+ * it under the terms of the GNU Lesser General Public License as published by
77+ * the Free Software Foundation; version 3.
78+ *
79+ * This program is distributed in the hope that it will be useful,
80+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
81+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82+ * GNU Lesser General Public License for more details.
83+ *
84+ * You should have received a copy of the GNU Lesser General Public License
85+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
86+ */
87+
88+import QtQuick 2.0
89+import Ubuntu.Components 1.1
90+import Ubuntu.Components.ListItems 1.0 as ListItem
91+
92+MainView {
93+ width: units.gu(48)
94+ height: units.gu(60)
95+
96+ useDeprecatedToolbar: false
97+
98+ Page {
99+ id: page
100+ title: "Test title"
101+
102+ ListView {
103+ id: testListView
104+ objectName: "testListView"
105+ anchors.fill: parent
106+ model: 20
107+
108+ delegate: ListItem.Standard {
109+ objectName: "testListElement%1".arg(index)
110+ text: "test list element %1".arg(index)
111+ height: units.gu(5)
112+ }
113+ }
114+ }
115+}
116
117=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
118--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-07-30 12:45:31 +0000
119+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-11-25 10:38:20 +0000
120@@ -24,6 +24,34 @@
121 from ubuntuuitoolkit import tests
122
123
124+class HideShowTestCase(tests.QMLFileAppTestCase):
125+
126+ path = os.path.abspath(__file__)
127+ dir_path = os.path.dirname(path)
128+ test_qml_file_path = os.path.join(
129+ dir_path,
130+ 'test_header.HideShowTestCase.qml')
131+
132+ def setUp(self):
133+ super(HideShowTestCase, self).setUp()
134+ self.header = self.main_view.get_header()
135+
136+ def test_ensure_header_visible_must_show_it_when_not_visible(self):
137+ """Test that header.ensure_visible() shows the header."""
138+
139+ # NOTE: Using the internal _is_visible() function here.
140+ # It is not made public because besides testing the
141+ # ensure_visible() function, there is no use for it.
142+ self.assertEquals(self.header._is_visible(), True)
143+ # Scroll down to hide the header
144+ self.list_view = self.main_view.select_single(
145+ ubuntuuitoolkit.QQuickListView, objectName='testListView')
146+ self.list_view.click_element('testListElement19')
147+ self.assertEquals(self.header._is_visible(), False)
148+ self.header.ensure_visible()
149+ self.assertEquals(self.header._is_visible(), True)
150+
151+
152 class ActionsTestCase(tests.QMLFileAppTestCase):
153
154 path = os.path.abspath(__file__)

Subscribers

People subscribed via source and target branches