on xenial help sign in
Update to autopilot 1.4.

Approved by PS Jenkins bot.

commitea5f26e70cc57f0b452026b36609069f4c365907 authorchris.gagnon <chris.gagnon@canonical.com> dateWed 6 Nov 2013, 03:34 (13 years ago) parent05ac61303e1f84
7 files changed+128−92
debian/control+1−1 tests/autopilot/unity8/shell/emulators/create_interactive_notification.py tests/autopilot/unity8/shell/emulators/dash.py+7−17 tests/autopilot/unity8/shell/emulators/hud.py+12−4 tests/autopilot/unity8/shell/emulators/main_window.py+1−1 tests/autopilot/unity8/shell/tests/__init__.py+58−27 tests/autopilot/unity8/shell/tests/test_notifications.py+49−42
debian/control+1−1
@@ -91,7 +91,7 @@ Description: Unity 8 shell
9191Package: unity8-autopilot
9292Architecture: all
9393Depends: gir1.2-glib-2.0,
94− libautopilot-qt,
94+ libautopilot-qt (>= 1.4),
9595 libqt5test5,
9696 libqt5widgets5,
9797 python-evdev,
tests/autopilot/unity8/shell/emulators/create_interactive_notification.pymode 100755 → 100644

Only the mode changed.

tests/autopilot/unity8/shell/emulators/dash.py+7−17
@@ -18,42 +18,32 @@
1818#
1919
2020from unity8.shell.emulators import UnityEmulatorBase
21−from time import sleep
21+
2222
2323class Dash(UnityEmulatorBase):
2424
2525 """An emulator that understands the Dash."""
2626
2727 def get_home_applications_grid(self):
28− for i in range(1,10):
29− get_grid = self.get_scope('home').select_single(
30− "GenericFilterGrid",
31− objectName="applications.scope"
32− )
33− if get_grid != None:
34− break
35− sleep(1)
28+ get_grid = self.get_scope('home').wait_select_single(
29+ "GenericFilterGrid",
30+ objectName="applications.scope"
31+ )
3632 return get_grid
3733
3834 def get_application_icon(self, text):
3935 """Returns a 'Tile' icon that has the text 'text' from the application
4036 grid.
4137
42− Will return None if the icon isn't found.
43−
4438 :param text: String containing the text of the icon to search for.
4539
4640 """
4741 app_grid = self.get_home_applications_grid()
48− for i in range(1,10):
49− resp_grid = app_grid.select_single('ResponsiveGridView')
50− if resp_grid != None:
51− break
52− sleep(1)
42+ resp_grid = app_grid.wait_select_single('ResponsiveGridView')
5343 return resp_grid.select_single('Tile', text=text)
5444
5545 def get_scope(self, scope_name='home'):
56− dash_content = self.select_single(
46+ dash_content = self.wait_select_single(
5747 'QQuickListView',
5848 objectName='dashContentList'
5949 )
tests/autopilot/unity8/shell/emulators/hud.py+12−4
@@ -26,6 +26,7 @@ from autopilot.input import Touch
2626
2727SwipeCoords = namedtuple('SwipeCoords', 'start_x end_x start_y end_y')
2828
29+
2930class Hud(UnityEmulatorBase, DragMixin):
3031
3132 """An emulator that understands the Hud."""
@@ -34,13 +35,18 @@ class Hud(UnityEmulatorBase, DragMixin):
3435 """Swipes open the Hud."""
3536 self.touch = Touch.create()
3637
37− window = self.get_root_instance().select_single('QQuickView')
38− hud_show_button = window.select_single("HudButton")
38+ window = self.get_root_instance().wait_select_single('QQuickView')
39+ hud_show_button = window.wait_select_single("HudButton")
3940
4041 swipe_coords = self.get_button_swipe_coords(window, hud_show_button)
4142
4243 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
43− self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y)
44+ self._drag(
45+ swipe_coords.start_x,
46+ swipe_coords.start_y,
47+ swipe_coords.start_x,
48+ swipe_coords.end_y
49+ )
4450 try:
4551 hud_show_button.opacity.wait_for(1.0)
4652 self.touch.release()
@@ -74,6 +80,8 @@ class Hud(UnityEmulatorBase, DragMixin):
7480 start_x = int(main_view.x + (main_view.width / 2))
7581 end_x = start_x
7682 start_y = main_view.y + (main_view.height - 3)
77− end_y = main_view.y + int(hud_show_button.y + (hud_show_button.height/2))
83+ end_y = main_view.y + int(
84+ hud_show_button.y + (hud_show_button.height/2)
85+ )
7886
7987 return SwipeCoords(start_x, end_x, start_y, end_y)
tests/autopilot/unity8/shell/emulators/main_window.py+1−1
@@ -38,7 +38,7 @@ class MainWindow(object):
3838 return self.app.select_single(Greeter)
3939
4040 def get_greeter_content_loader(self):
41− return self.app.select_single(
41+ return self.app.wait_select_single(
4242 "QQuickLoader",
4343 objectName="greeterContentLoader"
4444 )
tests/autopilot/unity8/shell/tests/__init__.py+58−27
@@ -34,7 +34,7 @@ import logging
3434import os.path
3535import subprocess
3636import sys
37−from testtools.matchers import Equals, NotEquals
37+from testtools.matchers import Equals
3838
3939from unity8 import (
4040 get_lib_path,
@@ -53,7 +53,7 @@ logger = logging.getLogger(__name__)
5353UNITYSHELL_GSETTINGS_SCHEMA = "org.compiz.unityshell"
5454UNITYSHELL_GSETTINGS_PATH = "/org/compiz/profiles/unity/plugins/unityshell/"
5555UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
56−UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
56+UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
5757
5858
5959def _get_device_emulation_scenarios(devices='All'):
@@ -93,17 +93,25 @@ class UnityTestCase(AutopilotTestCase):
9393 ], stderr=subprocess.STDOUT)
9494 except subprocess.CalledProcessError, e:
9595 sys.stderr.write(
96− "Error: `initctl status unity8` failed, most probably the unity8 session could not be found:\n\n"
96+ "Error: `initctl status unity8` failed, most probably the "
97+ "unity8 session could not be found:\n\n"
9798 "{0}\n"
98− "Please install unity8 or copy data/unity8.conf to {1}\n".format(
99+ "Please install unity8 or copy data/unity8.conf to "
100+ "{1}\n".format(
99101 e.output,
100− os.path.join(os.getenv("XDG_CONFIG_HOME", os.path.join(os.getenv("HOME"), ".config")), "upstart")
101− ))
102+ os.path.join(os.getenv("XDG_CONFIG_HOME",
103+ os.path.join(os.getenv("HOME"),
104+ ".config")
105+ ),
106+ "upstart")
107+ )
108+ )
102109 sys.exit(1)
103110
104111 if "start/" in output:
105112 sys.stderr.write(
106− "Error: Unity is currently running, these tests require it to be 'stopped'.\n"
113+ "Error: Unity is currently running, these tests require it to "
114+ "be 'stopped'.\n"
107115 "Please run this command before running these tests: \n"
108116 "initctl stop unity8\n"
109117 )
@@ -111,11 +119,22 @@ class UnityTestCase(AutopilotTestCase):
111119
112120 def setUp(self):
113121 super(UnityTestCase, self).setUp()
114− if Gio is not None and UNITYSHELL_GSETTINGS_SCHEMA in Gio.Settings.list_relocatable_schemas():
122+ if (Gio is not None and
123+ UNITYSHELL_GSETTINGS_SCHEMA in
124+ Gio.Settings.list_relocatable_schemas()):
125+
115126 # Hide Unity launcher
116− self._unityshell_schema = Gio.Settings.new_with_path(UNITYSHELL_GSETTINGS_SCHEMA, UNITYSHELL_GSETTINGS_PATH)
117− self._launcher_hide_mode = self._unityshell_schema.get_int(UNITYSHELL_LAUNCHER_KEY)
118− self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, UNITYSHELL_LAUNCHER_MODE)
127+ self._unityshell_schema = Gio.Settings.new_with_path(
128+ UNITYSHELL_GSETTINGS_SCHEMA,
129+ UNITYSHELL_GSETTINGS_PATH,
130+ )
131+ self._launcher_hide_mode = self._unityshell_schema.get_int(
132+ UNITYSHELL_LAUNCHER_KEY,
133+ )
134+ self._unityshell_schema.set_int(
135+ UNITYSHELL_LAUNCHER_KEY,
136+ UNITYSHELL_LAUNCHER_MODE,
137+ )
119138 self.addCleanup(self._reset_launcher)
120139
121140 self._proxy = None
@@ -136,7 +155,10 @@ class UnityTestCase(AutopilotTestCase):
136155
137156 def _reset_launcher(self):
138157 """Reset Unity launcher hide mode"""
139− self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, self._launcher_hide_mode)
158+ self._unityshell_schema.set_int(
159+ UNITYSHELL_LAUNCHER_KEY,
160+ self._launcher_hide_mode,
161+ )
140162
141163 def _setup_display_details(self):
142164 scale_divisor = self._determine_geometry()
@@ -217,7 +239,10 @@ class UnityTestCase(AutopilotTestCase):
217239 def _upstart_reset_env(self, key, value):
218240 logger.info("Resetting upstart env %s to %s", key, value)
219241 if value is None:
220− subprocess.call(["/sbin/initctl", "unset-env", key], stderr=subprocess.STDOUT)
242+ subprocess.call(
243+ ["/sbin/initctl", "unset-env", key],
244+ stderr=subprocess.STDOUT,
245+ )
221246 else:
222247 subprocess.call([
223248 "/sbin/initctl",
@@ -244,9 +269,13 @@ class UnityTestCase(AutopilotTestCase):
244269 self._setup_extra_mock_environment_patch()
245270
246271 # FIXME: we shouldn't be doing this
247− # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and /tmp/mir_socket as last resort
272+ # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and
273+ # /tmp/mir_socket as last resort
248274 try:
249− os.unlink(os.getenv('MIR_SOCKET', os.path.join(os.getenv('XDG_RUNTIME_DIR', "/tmp"), "mir_socket")))
275+ os.unlink(
276+ os.getenv('MIR_SOCKET',
277+ os.path.join(os.getenv('XDG_RUNTIME_DIR', "/tmp"),
278+ "mir_socket")))
250279 except OSError:
251280 pass
252281 try:
@@ -256,7 +285,7 @@ class UnityTestCase(AutopilotTestCase):
256285
257286 app_proxy = self._launch_unity_with_upstart(
258287 binary_path,
259− self.unity_geometry_args
288+ self.unity_geometry_args,
260289 )
261290
262291 self._set_proxy(app_proxy)
@@ -275,14 +304,16 @@ class UnityTestCase(AutopilotTestCase):
275304 binary_arg = "BINARY=%s" % binary_path
276305 extra_args = "ARGS=%s" % " ".join(args)
277306
278− output = subprocess.check_output([
279− "/sbin/initctl",
280− "start",
281− "unity8",
282− binary_arg,
283− extra_args
284− ] + ["%s=%s" % (k,v) for k,v in self._environment.iteritems()],
285− stderr=subprocess.STDOUT)
307+ output = subprocess.check_output(
308+ [
309+ "/sbin/initctl",
310+ "start",
311+ "unity8",
312+ binary_arg,
313+ extra_args,
314+ ] + ["%s=%s" % (k, v) for k, v in self._environment.iteritems()],
315+ stderr=subprocess.STDOUT,
316+ )
286317
287318 self.addCleanup(self._cleanup_launching_upstart_unity)
288319
@@ -296,7 +327,8 @@ class UnityTestCase(AutopilotTestCase):
296327 def _cleanup_launching_upstart_unity(self):
297328 logger.info("Stopping unity")
298329 try:
299− subprocess.check_output(["/sbin/initctl", "stop", "unity8"], stderr=subprocess.STDOUT)
330+ subprocess.check_output(
331+ ["/sbin/initctl", "stop", "unity8"], stderr=subprocess.STDOUT)
300332 except subprocess.CalledProcessError:
301333 logger.warning("Appears unity was already stopped!")
302334
@@ -366,8 +398,7 @@ class UnityTestCase(AutopilotTestCase):
366398 self.assertThat(home_scope.isCurrent, Eventually(Equals(True)))
367399
368400 def get_dash(self):
369− dash = self._proxy.select_single(Dash)
370− self.assertThat(dash, NotEquals(None))
401+ dash = self._proxy.wait_select_single(Dash)
371402 return dash
372403
373404 @property
tests/autopilot/unity8/shell/tests/test_notifications.py+49−42
@@ -45,7 +45,7 @@ class NotificationsBase(UnityTestCase):
4545 """Given an icons file name returns the full path (either system or
4646 source tree.
4747
48− Consider the graphics directory as root so for example (runnign tests
48+ Consider the graphics directory as root so for example (running tests
4949 from installed unity8-autopilot package):
5050 >>> self.get_icon_path('clock.png')
5151 /usr/share/unity8/graphics/clock.png
@@ -145,8 +145,8 @@ class InteractiveNotificationBase(NotificationsBase):
145145 hints,
146146 )
147147
148− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
149− self.assertThat(get_notification, Eventually(NotEquals(None)))
148+ get_notification = lambda: notify_list.wait_select_single(
149+ 'Notification', objectName='notification1')
150150 notification = get_notification()
151151
152152 self.touch.tap_object(
@@ -156,7 +156,8 @@ class InteractiveNotificationBase(NotificationsBase):
156156 self.assert_notification_action_id_was_called('action_id')
157157
158158 def test_sd_incoming_call(self):
159− """Rejecting a call should make notification expand and offer more options."""
159+ """Rejecting a call should make notification expand and
160+ offer more options."""
160161 self.launch_unity()
161162 greeter = self.main_window.get_greeter()
162163 greeter.swipe()
@@ -191,8 +192,8 @@ class InteractiveNotificationBase(NotificationsBase):
191192 hints
192193 )
193194
194− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
195− self.assertThat(get_notification, Eventually(NotEquals(None)))
195+ get_notification = lambda: notify_list.wait_select_single(
196+ 'Notification', objectName='notification1')
196197 notification = get_notification()
197198 self._assert_notification(notification, None, None, True, True, 1.0)
198199 initial_height = notification.height
@@ -200,8 +201,10 @@ class InteractiveNotificationBase(NotificationsBase):
200201 self.assertThat(
201202 notification.height,
202203 Eventually(Equals(initial_height +
203− 3 * notification.select_single(objectName="buttonColumn").spacing +
204− 3 * notification.select_single(objectName="button4").height)))
204+ 3 * notification.select_single(
205+ objectName="buttonColumn").spacing +
206+ 3 * notification.select_single(
207+ objectName="button4").height)))
205208 self.touch.tap_object(notification.select_single(objectName="button4"))
206209 self.assert_notification_action_id_was_called("action_decline_4")
207210
@@ -360,13 +363,20 @@ class EphemeralNotificationsTests(NotificationsBase):
360363
361364 notification.show()
362365
363− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
364− self.assertThat(get_notification, Eventually(NotEquals(None)))
365− notification = get_notification()
366− self._assert_notification(notification, summary, body, True, True, 1.0)
366+ notification = lambda: notify_list.wait_select_single(
367+ 'Notification', objectName='notification1')
368+ self._assert_notification(
369+ notification(),
370+ summary,
371+ body,
372+ True,
373+ True,
374+ 1.0,
375+ )
367376
368377 def test_icon_summary(self):
369− """Notification must display the expected summary and secondary icon."""
378+ """Notification must display the expected summary and secondary
379+ icon."""
370380 self.launch_unity()
371381 greeter = self.main_window.get_greeter()
372382 greeter.swipe()
@@ -391,11 +401,11 @@ class EphemeralNotificationsTests(NotificationsBase):
391401
392402 notification.show()
393403
394− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
395− self.assertThat(get_notification, Eventually(NotEquals(None)))
396− notification = get_notification()
404+ notification = lambda: notify_list.wait_select_single(
405+ 'Notification', objectName='notification1')
406+
397407 self._assert_notification(
398− notification,
408+ notification(),
399409 summary,
400410 None,
401411 False,
@@ -404,7 +414,8 @@ class EphemeralNotificationsTests(NotificationsBase):
404414 )
405415
406416 def test_urgency_order(self):
407− """Notifications must be displayed in order according to their urgency."""
417+ """Notifications must be displayed in order according to their
418+ urgency."""
408419 self.launch_unity()
409420 greeter = self.main_window.get_greeter()
410421 greeter.swipe()
@@ -448,11 +459,10 @@ class EphemeralNotificationsTests(NotificationsBase):
448459 )
449460 notification_critical.show()
450461
451− get_notification = lambda: notify_list.select_single(
462+ get_notification = lambda: notify_list.wait_select_single(
452463 'Notification',
453464 summary=summary_critical
454465 )
455− self.assertThat(get_notification, Eventually(NotEquals(None)))
456466
457467 notification = get_notification()
458468 self._assert_notification(
@@ -464,11 +474,10 @@ class EphemeralNotificationsTests(NotificationsBase):
464474 1.0
465475 )
466476
467− get_normal_notification = lambda: notify_list.select_single(
477+ get_normal_notification = lambda: notify_list.wait_select_single(
468478 'Notification',
469479 summary=summary_normal
470480 )
471− self.assertThat(get_normal_notification, Eventually(NotEquals(None)))
472481 notification = get_normal_notification()
473482 self._assert_notification(
474483 notification,
@@ -479,11 +488,10 @@ class EphemeralNotificationsTests(NotificationsBase):
479488 1.0
480489 )
481490
482− get_low_notification = lambda: notify_list.select_single(
491+ get_low_notification = lambda: notify_list.wait_select_single(
483492 'Notification',
484493 summary=summary_low
485494 )
486− self.assertThat(get_low_notification, Eventually(NotEquals(None)))
487495 notification = get_low_notification()
488496 self._assert_notification(
489497 notification,
@@ -508,9 +516,8 @@ class EphemeralNotificationsTests(NotificationsBase):
508516 notification = self._create_ephemeral_notification(summary, body)
509517 notification.show()
510518
511− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
512− self.assertThat(get_notification, Eventually(NotEquals(None)))
513− notification = get_notification()
519+ notification = notify_list.wait_select_single(
520+ 'Notification', objectName='notification1')
514521 self._assert_notification(
515522 notification,
516523 summary,
@@ -533,14 +540,14 @@ class EphemeralNotificationsTests(NotificationsBase):
533540 notification = self._create_ephemeral_notification(summary)
534541 notification.show()
535542
536− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
537− self.assertThat(get_notification, Eventually(NotEquals(None)))
538− notification = get_notification()
543+ notification = notify_list.wait_select_single(
544+ 'Notification', objectName='notification1')
539545
540546 self._assert_notification(notification, summary, '', False, False, 1.0)
541547
542548 def test_update_notification_same_layout(self):
543− """Notification must allow updating its contents while being displayed."""
549+ """Notification must allow updating its contents while being
550+ displayed."""
544551 self.launch_unity()
545552 greeter = self.main_window.get_greeter()
546553 greeter.swipe()
@@ -558,8 +565,8 @@ class EphemeralNotificationsTests(NotificationsBase):
558565 )
559566 notification.show()
560567
561− get_notification = lambda: notify_list.select_single('Notification', summary=summary)
562− self.assertThat(get_notification, Eventually(NotEquals(None)))
568+ get_notification = lambda: notify_list.wait_select_single(
569+ 'Notification', summary=summary)
563570 self._assert_notification(
564571 get_notification(),
565572 summary,
@@ -575,11 +582,11 @@ class EphemeralNotificationsTests(NotificationsBase):
575582 icon_path = self._get_icon_path('avatars/amanda.png')
576583 notification.update(summary, body, icon_path)
577584 notification.show()
578− self.assertThat(get_notification, Eventually(NotEquals(None)))
579585 self._assert_notification(get_notification(), summary, body)
580586
581587 def test_update_notification_layout_change(self):
582− """Notification must allow updating its contents and layout while being displayed."""
588+ """Notification must allow updating its contents and layout while
589+ being displayed."""
583590 self.launch_unity()
584591 greeter = self.main_window.get_greeter()
585592 greeter.swipe()
@@ -603,8 +610,8 @@ class EphemeralNotificationsTests(NotificationsBase):
603610 )
604611 notification.show()
605612
606− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
607− self.assertThat(get_notification, Eventually(NotEquals(None)))
613+ get_notification = lambda: notify_list.wait_select_single(
614+ 'Notification', objectName='notification1')
608615 self._assert_notification(
609616 get_notification(),
610617 summary,
@@ -645,8 +652,8 @@ class EphemeralNotificationsTests(NotificationsBase):
645652
646653 notification.show()
647654
648− get_notification = lambda: notify_list.select_single('Notification', objectName='notification1')
649− self.assertThat(get_notification, Eventually(NotEquals(None)))
655+ get_notification = lambda: notify_list.wait_select_single(
656+ 'Notification', objectName='notification1')
650657 notification = get_notification()
651658 self._assert_notification(
652659 notification,
@@ -662,7 +669,8 @@ class EphemeralNotificationsTests(NotificationsBase):
662669 'Did you watch the air-race in Oshkosh last week?',
663670 'Phil owned the place like no one before him!',
664671 'Did really everything in the race work according to regulations?',
665− 'Somehow I think to remember Burt Williams did cut corners and was not punished for this.',
672+ 'Somehow I think to remember Burt Williams did cut corners and '
673+ 'was not punished for this.',
666674 'Hopefully the referees will watch the videos of the race.',
667675 'Burt could get fined with US$ 50000 for that rule-violation :)'
668676 ]
@@ -677,11 +685,10 @@ class EphemeralNotificationsTests(NotificationsBase):
677685 hints=[('x-canonical-append', 'true')]
678686 )
679687 notification.show()
680− get_notification = lambda: notify_list.select_single(
688+ get_notification = lambda: notify_list.wait_select_single(
681689 'Notification',
682690 objectName='notification1'
683691 )
684− self.assertThat(get_notification, Eventually(NotEquals(None)))
685692 notification = get_notification()
686693 self._assert_notification(
687694 notification,