Merge lp:~canonical-platform-qa/ubuntu-system-tests/helpers-autopilot-selftests into lp:ubuntu-system-tests

Proposed by Richard Huddie
Status: Work in progress
Proposed branch: lp:~canonical-platform-qa/ubuntu-system-tests/helpers-autopilot-selftests
Merge into: lp:ubuntu-system-tests
Diff against target: 436 lines (+209/-35)
10 files modified
setup.py (+1/-1)
ubuntu_system_tests/helpers/unity8/__init__.py (+7/-0)
ubuntu_system_tests/selftests/helpers/base.py (+45/-0)
ubuntu_system_tests/selftests/helpers/unity8/test_dash.py (+75/-0)
ubuntu_system_tests/selftests/helpers/unity8/test_shell.py (+51/-0)
ubuntu_system_tests/selftests/host/test_command_line.py (+3/-3)
ubuntu_system_tests/selftests/host/test_config.py (+12/-12)
ubuntu_system_tests/selftests/host/test_results.py (+7/-7)
ubuntu_system_tests/selftests/host/test_testbed_commands.py (+5/-7)
ubuntu_system_tests/selftests/host/test_tests_to_run.py (+3/-5)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-system-tests/helpers-autopilot-selftests
Reviewer Review Type Date Requested Status
Canonical Platform QA Team Pending
Review via email: mp+295340@code.launchpad.net
To post a comment you must log in.
390. By Richard Huddie

Some basic tests, don't restart unity8.

391. By Richard Huddie

search selftest.

392. By Richard Huddie

Open scope test.

393. By Richard Huddie

More dash helpers tests.

394. By Richard Huddie

Merge from trunk.

395. By Richard Huddie

Minor updates.

396. By Richard Huddie

Merge from trunk.

397. By Richard Huddie

unity8 shellview selftests.

Unmerged revisions

397. By Richard Huddie

unity8 shellview selftests.

396. By Richard Huddie

Merge from trunk.

395. By Richard Huddie

Minor updates.

394. By Richard Huddie

Merge from trunk.

393. By Richard Huddie

More dash helpers tests.

392. By Richard Huddie

Open scope test.

391. By Richard Huddie

search selftest.

390. By Richard Huddie

Some basic tests, don't restart unity8.

389. By Richard Huddie

Move existing selftests to host directory.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2016-05-09 13:56:53 +0000
3+++ setup.py 2016-06-07 18:44:26 +0000
4@@ -48,7 +48,7 @@
5 'ubuntu-system-tests = ubuntu_system_tests.run:main'
6 ]
7 },
8- test_suite='ubuntu_system_tests.selftests',
9+ test_suite='ubuntu_system_tests.selftests.host',
10 tests_require=[
11 'python-subunit',
12 ]
13
14=== modified file 'ubuntu_system_tests/helpers/unity8/__init__.py'
15--- ubuntu_system_tests/helpers/unity8/__init__.py 2016-05-05 19:11:42 +0000
16+++ ubuntu_system_tests/helpers/unity8/__init__.py 2016-06-07 18:44:26 +0000
17@@ -19,6 +19,8 @@
18 #
19
20 from ubuntuuitoolkit import UbuntuUIToolkitCustomProxyObjectBase
21+from ubuntuuitoolkit._custom_proxy_objects._common import (
22+ _is_testability_enabled_for_process)
23 from unity8 import process_helpers
24
25 from autopilot import introspection
26@@ -27,6 +29,7 @@
27
28 from ubuntu_system_tests.helpers import context
29 from ubuntu_system_tests.helpers import timer
30+from ubuntu_system_tests.helpers.processes import get_process_id
31 from ubuntu_system_tests.helpers.unity8 import greeter
32
33 PROC_NAME = 'unity8'
34@@ -49,6 +52,10 @@
35 greeter.hide_greeter_with_dbus()
36
37
38+def is_testability_enabled_for_unity8():
39+ return _is_testability_enabled_for_process(get_process_id(PROC_NAME))
40+
41+
42 def _is_unity8_running():
43 return process_helpers.is_job_running('unity8')
44
45
46=== added directory 'ubuntu_system_tests/selftests/helpers'
47=== added file 'ubuntu_system_tests/selftests/helpers/base.py'
48--- ubuntu_system_tests/selftests/helpers/base.py 1970-01-01 00:00:00 +0000
49+++ ubuntu_system_tests/selftests/helpers/base.py 2016-06-07 18:44:26 +0000
50@@ -0,0 +1,45 @@
51+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
52+
53+#
54+# Ubuntu System Tests
55+# Copyright (C) 2016 Canonical
56+#
57+# This program is free software: you can redistribute it and/or modify
58+# it under the terms of the GNU General Public License as published by
59+# the Free Software Foundation, either version 3 of the License, or
60+# (at your option) any later version.
61+#
62+# This program is distributed in the hope that it will be useful,
63+# but WITHOUT ANY WARRANTY; without even the implied warranty of
64+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65+# GNU General Public License for more details.
66+#
67+# You should have received a copy of the GNU General Public License
68+# along with this program. If not, see <http://www.gnu.org/licenses/>.
69+#
70+
71+import logging
72+
73+from ubuntu_system_tests.helpers import unity8
74+from ubuntu_system_tests.tests.base import BaseUbuntuSystemTestCase
75+
76+logger = logging.getLogger(__name__)
77+
78+
79+class BaseHelperSelfTestCase(BaseUbuntuSystemTestCase):
80+
81+ @classmethod
82+ def setUpClass(cls):
83+ pass
84+
85+ @classmethod
86+ def tearDownClass(cls):
87+ pass
88+
89+ def setUp(self):
90+ super().setUp()
91+ if not unity8.is_testability_enabled_for_unity8():
92+ self.shell = self.restart_unity().main_window
93+ else:
94+ self.shell = self._get_unity8_proxy_object().main_window
95+ self.shell.show_dash_from_launcher()
96
97=== added directory 'ubuntu_system_tests/selftests/helpers/unity8'
98=== added file 'ubuntu_system_tests/selftests/helpers/unity8/test_dash.py'
99--- ubuntu_system_tests/selftests/helpers/unity8/test_dash.py 1970-01-01 00:00:00 +0000
100+++ ubuntu_system_tests/selftests/helpers/unity8/test_dash.py 2016-06-07 18:44:26 +0000
101@@ -0,0 +1,75 @@
102+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
103+
104+#
105+# Ubuntu System Tests
106+# Copyright (C) 2016 Canonical
107+#
108+# This program is free software: you can redistribute it and/or modify
109+# it under the terms of the GNU General Public License as published by
110+# the Free Software Foundation, either version 3 of the License, or
111+# (at your option) any later version.
112+#
113+# This program is distributed in the hope that it will be useful,
114+# but WITHOUT ANY WARRANTY; without even the implied warranty of
115+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+# GNU General Public License for more details.
117+#
118+# You should have received a copy of the GNU General Public License
119+# along with this program. If not, see <http://www.gnu.org/licenses/>.
120+#
121+
122+from ubuntu_system_tests.helpers.maliit import get_keyboard
123+from ubuntu_system_tests.helpers.unity8 import get_dash
124+from ubuntu_system_tests.selftests.helpers import base
125+
126+
127+class DashHelpersTestCase(base.BaseHelperSelfTestCase):
128+
129+ def setUp(self):
130+ super().setUp()
131+ self.dash = get_dash()
132+
133+ def _open_apps_scope(self):
134+ original = self.dash.get_current_scope().get_title()
135+ self.dash.open_scope('clickscope')
136+ apps_scope = self.dash.get_current_scope()
137+ apps_title = apps_scope.get_title()
138+ self.assertEqual(apps_title, 'Apps')
139+ self.assertNotEqual(apps_title, original)
140+ return apps_scope
141+
142+ def test_scroll_scope_left_right(self):
143+ original = self.dash.get_current_scope().get_title()
144+ self.dash.scroll_to_right_scope()
145+ right = self.dash.get_current_scope().get_title()
146+ self.assertNotEqual(original, right)
147+ self.dash.scroll_to_left_scope()
148+ left = self.dash.get_current_scope().get_title()
149+ self.assertEqual(original, left)
150+
151+ def test_manage_scopes(self):
152+ manager = self.dash.open_manage_scopes()
153+ self.assertGreater(len(manager.get_scopes_list()), 0)
154+
155+ def test_search(self):
156+ textfield = self.dash.get_search_text_field()
157+ query = 'test query'
158+ self.dash.enter_search_query(query, get_keyboard())
159+ self.assertEqual(textfield.text, query)
160+
161+ def test_open_scope(self):
162+ self._open_apps_scope()
163+
164+ def test_wait_for_dash_loaded(self):
165+ scope = self._open_apps_scope()
166+ scope.refresh()
167+ self.dash.wait_for_dash_loaded()
168+
169+ def test_wait_for_processing_to_complete(self):
170+ scope = self._open_apps_scope()
171+ scope.refresh()
172+ self.dash.wait_for_processing_to_complete()
173+
174+ def test_get_application_icon(self):
175+ self._open_apps_scope()
176+ self.assertIsNotNone(self.dash.get_application_icon('Phone'))
177
178=== added file 'ubuntu_system_tests/selftests/helpers/unity8/test_shell.py'
179--- ubuntu_system_tests/selftests/helpers/unity8/test_shell.py 1970-01-01 00:00:00 +0000
180+++ ubuntu_system_tests/selftests/helpers/unity8/test_shell.py 2016-06-07 18:44:26 +0000
181@@ -0,0 +1,51 @@
182+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
183+
184+#
185+# Ubuntu System Tests
186+# Copyright (C) 2016 Canonical
187+#
188+# This program is free software: you can redistribute it and/or modify
189+# it under the terms of the GNU General Public License as published by
190+# the Free Software Foundation, either version 3 of the License, or
191+# (at your option) any later version.
192+#
193+# This program is distributed in the hope that it will be useful,
194+# but WITHOUT ANY WARRANTY; without even the implied warranty of
195+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
196+# GNU General Public License for more details.
197+#
198+# You should have received a copy of the GNU General Public License
199+# along with this program. If not, see <http://www.gnu.org/licenses/>.
200+#
201+
202+
203+from ubuntu_system_tests.helpers.unity8 import get_dash
204+from ubuntu_system_tests.selftests.helpers import base
205+
206+
207+class ShellViewHelpersTestCase(base.BaseHelperSelfTestCase):
208+
209+ def setUp(self):
210+ super().setUp()
211+ self.dash = get_dash()
212+
213+ def _launch_application(self, app_id):
214+ self.shell.launch_application(app_id)
215+ self.assertEqual(self.shell.get_current_focused_app(), app_id)
216+
217+ def test_launch_application(self):
218+ self.assertEqual(self.shell.get_current_focused_app(), 'unity8-dash')
219+ self._launch_application('dialer-app')
220+
221+ def test_show_dash_from_launcher(self):
222+ self._launch_application('dialer-app')
223+ self.shell.show_dash_from_launcher()
224+ self.assertEqual(self.shell.get_current_focused_app(), 'unity8-dash')
225+
226+ def test_open_launcher(self):
227+ self.assertFalse(self.shell.is_launcher_open())
228+ launcher = self.shell.open_launcher()
229+ self.assertTrue(self.shell.is_launcher_open())
230+ launcher.click_dash_icon()
231+ launcher.shown.wait_for(False)
232+ self.assertFalse(self.shell.is_launcher_open())
233
234=== added directory 'ubuntu_system_tests/selftests/host'
235=== renamed file 'ubuntu_system_tests/selftests/__init__.py' => 'ubuntu_system_tests/selftests/host/__init__.py'
236=== renamed file 'ubuntu_system_tests/selftests/test_command_line.py' => 'ubuntu_system_tests/selftests/host/test_command_line.py'
237--- ubuntu_system_tests/selftests/test_command_line.py 2016-05-26 16:40:52 +0000
238+++ ubuntu_system_tests/selftests/host/test_command_line.py 2016-06-07 18:44:26 +0000
239@@ -26,9 +26,9 @@
240
241 import testscenarios
242
243-from ubuntu_system_tests import selftests
244 from ubuntu_system_tests.host import command_line
245 from ubuntu_system_tests.common import config
246+from ubuntu_system_tests.selftests.host import ConfigBaseTestCase
247
248
249 def check_any_item_in_list_contains_value(list, value):
250@@ -39,7 +39,7 @@
251 return any(item.startswith(value) for item in list)
252
253
254-class CommandLineTestCase(selftests.ConfigBaseTestCase):
255+class CommandLineTestCase(ConfigBaseTestCase):
256
257 def setUp(self):
258 super().setUp()
259@@ -269,7 +269,7 @@
260 self.assertEqual(tmp_control_content, expected_content)
261
262
263-class RunSystemTestsCommandsTestCase(selftests.ConfigBaseTestCase,
264+class RunSystemTestsCommandsTestCase(ConfigBaseTestCase,
265 testscenarios.TestWithScenarios):
266
267 scenarios = [
268
269=== renamed file 'ubuntu_system_tests/selftests/test_config.py' => 'ubuntu_system_tests/selftests/host/test_config.py'
270--- ubuntu_system_tests/selftests/test_config.py 2016-05-06 16:39:14 +0000
271+++ ubuntu_system_tests/selftests/host/test_config.py 2016-06-07 18:44:26 +0000
272@@ -25,13 +25,14 @@
273 import fixtures
274 from autopilot.introspection import ProxyBase
275
276-from ubuntu_system_tests import selftests
277 from ubuntu_system_tests.common import config
278 from ubuntu_system_tests.common.options import Option
279 from ubuntu_system_tests.helpers.autopilot import override_proxy_timeout
280-
281-
282-class HelpersTestCase(selftests.ConfigBaseTestCase):
283+from ubuntu_system_tests.selftests.host import (
284+ ConfigBaseTestCase, DEFAULT_SECTION)
285+
286+
287+class HelpersTestCase(ConfigBaseTestCase):
288
289 def get_mock_proxy(self):
290 """Returns a rubbish proxy object that doesn't actually do anything."""
291@@ -58,7 +59,7 @@
292 self.assertEqual(proxy._poll_time, original_timeout)
293
294
295-class ConfigDirTestCase(selftests.ConfigBaseTestCase):
296+class ConfigDirTestCase(ConfigBaseTestCase):
297
298 def test_default_config_dir_must_be_in_home(self):
299 config_dir = os.path.join(os.environ.get('HOME'), '.config')
300@@ -70,7 +71,7 @@
301 self.assertEqual(xdg_dir, config.get_user_config_dir())
302
303
304-class UbuntuSystemTestsStackTestCase(selftests.ConfigBaseTestCase):
305+class UbuntuSystemTestsStackTestCase(ConfigBaseTestCase):
306
307 def test_store_location(self):
308 config_stack = config.UbuntuSystemTestsConfig()
309@@ -82,7 +83,7 @@
310 def test_get_autopilot_config_string(self):
311 config_stack = config.UbuntuSystemTestsConfig()
312 config_stack.get_config_from_string(
313- selftests.DEFAULT_SECTION + 'option1 = value1\noption2 = value2\n')
314+ DEFAULT_SECTION + 'option1 = value1\noption2 = value2\n')
315
316 autopilot_config_string = config_stack.get_autopilot_config_string()
317 self.assertEqual(
318@@ -118,8 +119,7 @@
319 stream.seek(0)
320
321
322-class UbuntuSystemTestsStackWithTestOptionsTestCase(
323- selftests.ConfigBaseTestCase):
324+class UbuntuSystemTestsStackWithTestOptionsTestCase(ConfigBaseTestCase):
325
326 MANDATORY = [
327 Option('test.option1', help_string='Test option 1', mandatory=True),
328@@ -176,7 +176,7 @@
329 self.register_test_options(only_default)
330 config_stack = config.UbuntuSystemTestsConfig(
331 options=self.test_options)
332- config_string = selftests.DEFAULT_SECTION
333+ config_string = DEFAULT_SECTION
334 config_string += '\n'.join(
335 ['{} = {}\n'.format(o, v) for o, v in self.ALL_EXISTING_OPTIONS]
336 )
337@@ -288,7 +288,7 @@
338 config_lines.pop()
339
340 expected_config_lines = [
341- selftests.DEFAULT_SECTION,
342+ DEFAULT_SECTION,
343 # Already existing options.
344 'test.option7 = option7 existing value\n',
345 'test.option8 = option8 existing value\n',
346@@ -316,7 +316,7 @@
347 config_lines.pop()
348
349 expected_config_lines = [
350- selftests.DEFAULT_SECTION,
351+ DEFAULT_SECTION,
352 # Already existing options.
353 'test.option7 = option7 existing value\n',
354 'test.option8 = option8 existing value\n',
355
356=== renamed file 'ubuntu_system_tests/selftests/test_results.py' => 'ubuntu_system_tests/selftests/host/test_results.py'
357--- ubuntu_system_tests/selftests/test_results.py 2016-05-09 12:46:08 +0000
358+++ ubuntu_system_tests/selftests/host/test_results.py 2016-06-07 18:44:26 +0000
359@@ -22,19 +22,19 @@
360 import os
361 from unittest import mock
362
363-from ubuntu_system_tests import selftests
364+from ubuntu_system_tests.common import config
365 from ubuntu_system_tests.host import results
366-from ubuntu_system_tests.common import config
367-
368-
369-class ResultsTestCase(selftests.ConfigBaseTestCase):
370+from ubuntu_system_tests.selftests.host import (
371+ ConfigBaseTestCase, DEFAULT_SECTION)
372+
373+
374+class ResultsTestCase(ConfigBaseTestCase):
375
376 def setUp(self):
377 super().setUp()
378 self.config_stack = config.UbuntuSystemTestsConfig()
379 self.config_stack.get_config_from_string(
380- selftests.DEFAULT_SECTION + 'output_dir = {}'.format(
381- self.uniq_dir))
382+ DEFAULT_SECTION + 'output_dir = {}'.format(self.uniq_dir))
383
384 def test_convert_subunit_results_to_pyunit(self):
385 artifacts_directory = results.get_artifacts_directory(
386
387=== renamed file 'ubuntu_system_tests/selftests/test_testbed_commands.py' => 'ubuntu_system_tests/selftests/host/test_testbed_commands.py'
388--- ubuntu_system_tests/selftests/test_testbed_commands.py 2016-05-06 16:39:14 +0000
389+++ ubuntu_system_tests/selftests/host/test_testbed_commands.py 2016-06-07 18:44:26 +0000
390@@ -18,14 +18,12 @@
391 # along with this program. If not, see <http://www.gnu.org/licenses/>.
392 #
393
394-from ubuntu_system_tests import (
395- systemtests,
396- selftests
397-)
398+from ubuntu_system_tests import systemtests
399 from ubuntu_system_tests.common import config
400-
401-
402-class AutopilotCommandsTestCase(selftests.ConfigBaseTestCase):
403+from ubuntu_system_tests.selftests.host import ConfigBaseTestCase
404+
405+
406+class AutopilotCommandsTestCase(ConfigBaseTestCase):
407
408 def test_verbose_flag_present_by_default(self):
409 self.config_stack = config.UbuntuSystemTestsConfig()
410
411=== renamed file 'ubuntu_system_tests/selftests/test_tests_to_run.py' => 'ubuntu_system_tests/selftests/host/test_tests_to_run.py'
412--- ubuntu_system_tests/selftests/test_tests_to_run.py 2016-05-06 16:39:14 +0000
413+++ ubuntu_system_tests/selftests/host/test_tests_to_run.py 2016-06-07 18:44:26 +0000
414@@ -28,11 +28,9 @@
415 import fixtures
416 import testscenarios
417
418-from ubuntu_system_tests import (
419- external_tests,
420- selftests,
421-)
422+from ubuntu_system_tests import external_tests
423 from ubuntu_system_tests.common import get_tests_ids_to_run
424+from ubuntu_system_tests.selftests.host import ConfigBaseTestCase
425
426
427 class ExternalTestsListFile(fixtures.Fixture):
428@@ -170,7 +168,7 @@
429 self.assertTrue(fake_process_helpers.is_job_running('unity8'))
430
431
432-class GetTestIdsToRunTestCase(selftests.ConfigBaseTestCase):
433+class GetTestIdsToRunTestCase(ConfigBaseTestCase):
434
435 def test_get_tests_with_no_internal_tests_module(self):
436 external_tests = ['external_test_1']

Subscribers

People subscribed via source and target branches

to all changes: