Merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/register_url_dispatcher into lp:ubuntu-ui-toolkit/staging
- register_url_dispatcher
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 1533 |
Merged at revision: | 1529 |
Proposed branch: | lp:~canonical-platform-qa/ubuntu-ui-toolkit/register_url_dispatcher |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
223 lines (+119/-4) 4 files modified
debian/control (+1/-0) tests/autopilot/ubuntuuitoolkit/fixture_setup.py (+45/-1) tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.LaunchFakeApplicationTestCase.qml (+30/-0) tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+43/-3) |
To merge this branch: | bzr merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/register_url_dispatcher |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Zsombor Egri | Approve | ||
Review via email: mp+260923@code.launchpad.net |
Commit message
Add url protocols to the fake application.
Adds a dependency to url-dispatcher-
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1528
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:1529
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) wrote : | # |
FAILED: Continuous integration, rev:1530
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:1531
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) wrote : | # |
FAILED: Continuous integration, rev:1532
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) wrote : | # |
FAILED: Continuous integration, rev:1533
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) wrote : | # |
FAILED: Continuous integration, rev:1533
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
One obs. inline.
Leo Arias (elopio) wrote : | # |
Replied. Thanks for checking zsombi.
Zsombor Egri (zsombi) wrote : | # |
Ok, approved then. I mixed with the uri-handler functionality.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2015-06-02 11:38:57 +0000 |
3 | +++ debian/control 2015-06-08 23:01:09 +0000 |
4 | @@ -149,6 +149,7 @@ |
5 | qttestability-autopilot, |
6 | ubuntu-ui-toolkit-examples (>= ${source:Version}), |
7 | upstart, |
8 | + url-dispatcher-tools, |
9 | qtdeclarative5-ubuntu-ui-toolkit-plugin (>= ${source:Version}) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles, |
10 | qml-module-qttest | qtdeclarative5-test-plugin, |
11 | Description: Test package for Ubuntu UI Toolkit |
12 | |
13 | === modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py' |
14 | --- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2015-06-01 15:25:19 +0000 |
15 | +++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2015-06-08 23:01:09 +0000 |
16 | @@ -15,9 +15,11 @@ |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | import copy |
20 | +import json |
21 | import logging |
22 | import os |
23 | import shutil |
24 | +import subprocess |
25 | import tempfile |
26 | |
27 | import fixtures |
28 | @@ -56,18 +58,24 @@ |
29 | |
30 | def __init__( |
31 | self, qml_file_contents=DEFAULT_QML_FILE_CONTENTS, |
32 | - desktop_file_dict=None): |
33 | + desktop_file_dict=None, url_dispatcher_protocols=None): |
34 | super().__init__() |
35 | self._qml_file_contents = qml_file_contents |
36 | if desktop_file_dict is None: |
37 | self._desktop_file_dict = copy.deepcopy(DEFAULT_DESKTOP_FILE_DICT) |
38 | else: |
39 | self._desktop_file_dict = copy.deepcopy(desktop_file_dict) |
40 | + self.url_dispatcher_protocols = url_dispatcher_protocols |
41 | |
42 | def setUp(self): |
43 | super().setUp() |
44 | self.qml_file_path, self.desktop_file_path = ( |
45 | self._create_test_application()) |
46 | + desktop_file_name = os.path.basename(self.desktop_file_path) |
47 | + self.application_name, _ = os.path.splitext(desktop_file_name) |
48 | + if self.url_dispatcher_protocols: |
49 | + self.url_dispatcher_file_path = ( |
50 | + self._register_url_dispatcher_protocols(self.application_name)) |
51 | |
52 | def _create_test_application(self): |
53 | qml_file_path = self._write_test_qml_file() |
54 | @@ -111,6 +119,42 @@ |
55 | return os.path.join( |
56 | os.environ.get('HOME'), '.local', 'share', 'applications') |
57 | |
58 | + def _register_url_dispatcher_protocols(self, application_name): |
59 | + url_dispatcher_file_path = self._write_url_dispatcher_file( |
60 | + application_name) |
61 | + self.addCleanup(os.remove, url_dispatcher_file_path) |
62 | + self._update_url_dispatcher_directory(url_dispatcher_file_path) |
63 | + return url_dispatcher_file_path |
64 | + |
65 | + def _write_url_dispatcher_file(self, application_name): |
66 | + url_dispatcher_dir = self._get_local_url_dispatcher_directory() |
67 | + if not os.path.exists(url_dispatcher_dir): |
68 | + os.makedirs(url_dispatcher_dir) |
69 | + |
70 | + protocol_list = [ |
71 | + {'protocol': protocol} |
72 | + for protocol in self.url_dispatcher_protocols] |
73 | + |
74 | + url_dispatcher_file_path = os.path.join( |
75 | + url_dispatcher_dir, application_name + '.url-dispatcher') |
76 | + with open(url_dispatcher_file_path, 'w') as url_dispatcher_file: |
77 | + url_dispatcher_file.write(json.dumps(protocol_list)) |
78 | + |
79 | + return url_dispatcher_file_path |
80 | + |
81 | + def _get_local_url_dispatcher_directory(self): |
82 | + return os.path.join( |
83 | + os.environ.get('HOME'), '.config', 'url-dispatcher', 'urls') |
84 | + |
85 | + def _update_url_dispatcher_directory(self, url_dispatcher_file_path): |
86 | + # FIXME This should be updated calling |
87 | + # initctl start url-dispatcher-update-user, but it is not working. |
88 | + # https://bugs.launchpad.net/ubuntu/+source/url-dispatcher/+bug/1461496 |
89 | + # --elopio - 2015-06-02 |
90 | + subprocess.check_output( |
91 | + '/usr/lib/*/url-dispatcher/update-directory ' + |
92 | + url_dispatcher_file_path, shell=True) |
93 | + |
94 | |
95 | class InitctlEnvironmentVariable(fixtures.Fixture): |
96 | """Set the value of initctl environment variables.""" |
97 | |
98 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.LaunchFakeApplicationTestCase.qml' |
99 | --- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.LaunchFakeApplicationTestCase.qml 1970-01-01 00:00:00 +0000 |
100 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.LaunchFakeApplicationTestCase.qml 2015-06-08 23:01:09 +0000 |
101 | @@ -0,0 +1,30 @@ |
102 | +/* |
103 | + * Copyright 2015 Canonical Ltd. |
104 | + * |
105 | + * This program is free software; you can redistribute it and/or modify |
106 | + * it under the terms of the GNU Lesser General Public License as published by |
107 | + * the Free Software Foundation; version 3. |
108 | + * |
109 | + * This program is distributed in the hope that it will be useful, |
110 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
111 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
112 | + * GNU Lesser General Public License for more details. |
113 | + * |
114 | + * You should have received a copy of the GNU Lesser General Public License |
115 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
116 | + */ |
117 | + |
118 | +import QtQuick 2.3 |
119 | +import Ubuntu.Components 1.2 |
120 | + |
121 | +MainView { |
122 | + width: units.gu(48) |
123 | + height: units.gu(60) |
124 | + objectName: "mainView" |
125 | + |
126 | + Label { |
127 | + id: label |
128 | + objectName: 'testLabel' |
129 | + text: 'Test application.' |
130 | + } |
131 | +} |
132 | |
133 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py' |
134 | --- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2015-06-01 15:25:19 +0000 |
135 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2015-06-08 23:01:09 +0000 |
136 | @@ -15,6 +15,7 @@ |
137 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
138 | |
139 | import os |
140 | +import subprocess |
141 | import tempfile |
142 | |
143 | from unittest import mock |
144 | @@ -22,6 +23,7 @@ |
145 | import testtools |
146 | from autopilot import ( |
147 | display, |
148 | + introspection, |
149 | platform, |
150 | testcase as autopilot_testcase |
151 | ) |
152 | @@ -140,7 +142,8 @@ |
153 | os.path.dirname(fake_application.desktop_file_path)) |
154 | |
155 | def test_fake_application_files_must_be_removed_after_test(self): |
156 | - fake_application = fixture_setup.FakeApplication() |
157 | + fake_application = fixture_setup.FakeApplication( |
158 | + url_dispatcher_protocols=['testprotocol']) |
159 | |
160 | def inner_test(): |
161 | class TestWithFakeApplication(testtools.TestCase): |
162 | @@ -151,6 +154,8 @@ |
163 | inner_test().run() |
164 | self.assertThat(fake_application.qml_file_path, Not(FileExists())) |
165 | self.assertThat(fake_application.desktop_file_path, Not(FileExists())) |
166 | + self.assertThat( |
167 | + fake_application.url_dispatcher_file_path, Not(FileExists())) |
168 | |
169 | |
170 | class LaunchFakeApplicationTestCase(autopilot_testcase.AutopilotTestCase): |
171 | @@ -159,7 +164,7 @@ |
172 | fake_application = fixture_setup.FakeApplication() |
173 | self.useFixture(fake_application) |
174 | |
175 | - self.application = self.launch_test_application( |
176 | + application = self.launch_test_application( |
177 | base.get_qmlscene_launch_command(), |
178 | fake_application.qml_file_path, |
179 | '--desktop_file_hint={0}'.format( |
180 | @@ -167,7 +172,42 @@ |
181 | app_type='qt') |
182 | |
183 | # We can select a component from the application. |
184 | - self.application.select_single('Label', objectName='testLabel') |
185 | + application.select_single('Label', objectName='testLabel') |
186 | + |
187 | + def test_launch_fake_application_from_url_dispatcher(self): |
188 | + if platform.model() == 'Desktop': |
189 | + self.skipTest('Not yet working on desktop') |
190 | + |
191 | + path = os.path.abspath(__file__) |
192 | + dir_path = os.path.dirname(path) |
193 | + qml_file_path = os.path.join( |
194 | + dir_path, 'test_fixture_setup.LaunchFakeApplicationTestCase.qml') |
195 | + with open(qml_file_path) as qml_file: |
196 | + qml_file_contents = qml_file.read() |
197 | + |
198 | + fake_application = fixture_setup.FakeApplication( |
199 | + qml_file_contents=qml_file_contents, |
200 | + url_dispatcher_protocols=['testprotocol']) |
201 | + self.useFixture(fake_application) |
202 | + |
203 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
204 | + QT_LOAD_TESTABILITY=1)) |
205 | + |
206 | + self.addCleanup( |
207 | + subprocess.check_output, |
208 | + ['ubuntu-app-stop', fake_application.application_name]) |
209 | + |
210 | + subprocess.check_output( |
211 | + ['url-dispatcher', 'testprotocol://test']) |
212 | + |
213 | + pid = int(subprocess.check_output( |
214 | + ['ubuntu-app-pid', fake_application.application_name]).strip()) |
215 | + |
216 | + application = introspection.get_proxy_object_for_existing_process( |
217 | + pid=pid) |
218 | + |
219 | + # We can select a component from the application. |
220 | + application.select_single('Label', objectName='testLabel') |
221 | |
222 | |
223 | class InitctlEnvironmentVariableTestCase(testtools.TestCase): |
FAILED: Continuous integration, rev:1526 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1846/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 3062/console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-amd64- ci/574/ console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/576/ console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-i386- ci/573/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 3060/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1846/ rebuild
http://