Merge lp:~elopio/ubuntu-ui-toolkit/98-DeprecateHeader-autopilot into lp:~tpeeters/ubuntu-ui-toolkit/98-DeprecateHeader

Proposed by Leo Arias
Status: Merged
Merged at revision: 1105
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/98-DeprecateHeader-autopilot
Merge into: lp:~tpeeters/ubuntu-ui-toolkit/98-DeprecateHeader
Diff against target: 197 lines (+82/-6)
7 files modified
modules/Ubuntu/Components/Header.qml (+5/-0)
tests/autopilot/ubuntuuitoolkit/__init__.py (+4/-2)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py (+6/-2)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py (+11/-0)
tests/autopilot/ubuntuuitoolkit/emulators.py (+2/-2)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.DeprecatedHeaderTestCase.qml (+27/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+27/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/98-DeprecateHeader-autopilot
Reviewer Review Type Date Requested Status
Tim Peeters Approve
Review via email: mp+221956@code.launchpad.net

Commit message

Added an autoiplot helper for the deprecated header.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Tim, with this we will support people that are still using the deprecated Header, but we will log an additional warning on the autopilot side.

This is pretty ugly:
11 + property string _for_autopilot

but is the only way I know for QML to assign Header to this component. Otherwise it will consider it to be an AppHeader, and autopilot won't be able to distinguish between them.

And related to the existing app tests, they will be safe and won't require a modification if they are using main_view.get_header(). If they are doing something like select_single(Header) they will have to be updated. I don't think a lot of applications are doing that, maybe not a single one is doing it, but we have to search the code.

Revision history for this message
Tim Peeters (tpeeters) wrote :

thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Header.qml'
2--- modules/Ubuntu/Components/Header.qml 2014-05-28 19:13:40 +0000
3+++ modules/Ubuntu/Components/Header.qml 2014-06-03 20:49:38 +0000
4@@ -22,6 +22,11 @@
5 \deprecated
6 */
7 AppHeader {
8+
9+ // We need this property so QML exposes this class as Header instead of
10+ // AppHeader. This way autopilot can select the deprecated header.
11+ property string _for_autopilot
12+
13 Component.onCompleted: {
14 print("WARNING: Header is an internal component of Ubuntu.Components and" +
15 "its API may change or be removed at any moment." +
16
17=== modified file 'tests/autopilot/ubuntuuitoolkit/__init__.py'
18--- tests/autopilot/ubuntuuitoolkit/__init__.py 2014-06-02 20:15:56 +0000
19+++ tests/autopilot/ubuntuuitoolkit/__init__.py 2014-06-03 20:49:38 +0000
20@@ -18,6 +18,7 @@
21
22
23 __all__ = [
24+ 'AppHeader',
25 'base',
26 'check_autopilot_version',
27 'CheckBox',
28@@ -26,7 +27,7 @@
29 'fixture_setup',
30 'get_keyboard',
31 'get_pointing_device',
32- 'AppHeader',
33+ 'Header',
34 'listitems',
35 'MainView',
36 'OptionSelector',
37@@ -52,11 +53,12 @@
38 tests,
39 )
40 from ubuntuuitoolkit._custom_proxy_objects import (
41+ AppHeader,
42 check_autopilot_version,
43 CheckBox,
44 get_keyboard,
45 get_pointing_device,
46- AppHeader,
47+ Header,
48 listitems,
49 MainView,
50 OptionSelector,
51
52=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py'
53--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-06-02 20:15:56 +0000
54+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-06-03 20:49:38 +0000
55@@ -18,11 +18,12 @@
56
57
58 __all__ = [
59+ 'AppHeader',
60 'check_autopilot_version',
61 'CheckBox',
62 'get_keyboard',
63 'get_pointing_device',
64- 'AppHeader',
65+ 'Header',
66 'listitems',
67 'MainView',
68 'OptionSelector',
69@@ -47,7 +48,10 @@
70 UbuntuUIToolkitCustomProxyObjectBase,
71 )
72 from ubuntuuitoolkit._custom_proxy_objects._flickable import QQuickFlickable
73-from ubuntuuitoolkit._custom_proxy_objects._header import AppHeader
74+from ubuntuuitoolkit._custom_proxy_objects._header import (
75+ AppHeader,
76+ Header,
77+)
78 from ubuntuuitoolkit._custom_proxy_objects import listitems
79 from ubuntuuitoolkit._custom_proxy_objects._mainview import MainView
80 from ubuntuuitoolkit._custom_proxy_objects._optionselector import (
81
82=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py'
83--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-06-02 20:15:56 +0000
84+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-06-03 20:49:38 +0000
85@@ -204,3 +204,14 @@
86 # to find the requested button
87 return self.get_root_instance().select_single(
88 'Standard', objectName=object_name)
89+
90+
91+class Header(AppHeader):
92+ """Autopilot helper for the deprecated Header."""
93+
94+ def __init__(self, *args):
95+ logger.warning(
96+ 'Header is an internal QML component of Ubuntu.Components and '
97+ 'its API may change or be removed at any moment. Please use '
98+ 'MainView and Page instead.')
99+ super(Header, self).__init__(*args)
100
101=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
102--- tests/autopilot/ubuntuuitoolkit/emulators.py 2014-06-02 20:15:56 +0000
103+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2014-06-03 20:49:38 +0000
104@@ -36,7 +36,7 @@
105 'CheckBox',
106 'ComposerSheet',
107 'Empty',
108- 'AppHeader',
109+ 'Header',
110 'ItemSelector',
111 'MainView',
112 'MultiValue',
113@@ -61,7 +61,7 @@
114 get_keyboard,
115 get_pointing_device,
116 CheckBox,
117- AppHeader,
118+ Header,
119 MainView,
120 OptionSelector,
121 QQuickFlickable,
122
123=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.DeprecatedHeaderTestCase.qml'
124--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.DeprecatedHeaderTestCase.qml 1970-01-01 00:00:00 +0000
125+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.DeprecatedHeaderTestCase.qml 2014-06-03 20:49:38 +0000
126@@ -0,0 +1,27 @@
127+/*
128+ * Copyright 2014 Canonical Ltd.
129+ *
130+ * This program is free software; you can redistribute it and/or modify
131+ * it under the terms of the GNU Lesser General Public License as published by
132+ * the Free Software Foundation; version 3.
133+ *
134+ * This program is distributed in the hope that it will be useful,
135+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
136+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137+ * GNU Lesser General Public License for more details.
138+ *
139+ * You should have received a copy of the GNU Lesser General Public License
140+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
141+ */
142+
143+import QtQuick 2.0
144+import Ubuntu.Components 1.1
145+
146+Item {
147+
148+ objectName: 'main'
149+
150+ Header {
151+ title: 'test'
152+ }
153+}
154
155=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
156--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-06-02 20:15:56 +0000
157+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-06-03 20:49:38 +0000
158@@ -14,8 +14,12 @@
159 # You should have received a copy of the GNU Lesser General Public License
160 # along with this program. If not, see <http://www.gnu.org/licenses/>.
161
162+import logging
163 import os
164
165+import fixtures
166+from testtools.matchers import Contains
167+
168 import ubuntuuitoolkit
169 from ubuntuuitoolkit import tests
170
171@@ -184,3 +188,26 @@
172 """
173 header = self.main_view.get_header()
174 self.assertIsInstance(header, ubuntuuitoolkit.AppHeader)
175+
176+
177+class DeprecatedHeaderTestCase(tests.QMLFileAppTestCase):
178+
179+ path = os.path.abspath(__file__)
180+ dir_path = os.path.dirname(path)
181+ test_qml_file_path = os.path.join(
182+ dir_path, 'test_header.DeprecatedHeaderTestCase.qml')
183+
184+ @property
185+ def main_view(self):
186+ return self.app.select_single('QQuickItem', objectName='main')
187+
188+ def test_get_deprecated_header_must_log_deprecation_warning(self):
189+ fake_logger = fixtures.FakeLogger(level=logging.WARNING)
190+ self.useFixture(fake_logger)
191+ self.main_view.select_single(ubuntuuitoolkit.Header)
192+ self.assertThat(
193+ fake_logger.output,
194+ Contains(
195+ 'Header is an internal QML component of Ubuntu.Components and '
196+ 'its API may change or be removed at any moment. Please use '
197+ 'MainView and Page instead.'))

Subscribers

People subscribed via source and target branches

to all changes: