on xenial help sign in
Added a test to swipe out an application started by url-dispatcher.
20d4a3dLeo Arias
debian/control+3−1
@@ -103,7 +103,8 @@ Description: Unity 8 shell
103
103
104Package: unity8-autopilot
104Package: unity8-autopilot
105Architecture: all
105Architecture: all
106+Depends: camera-app,
106−Depends: gir1.2-glib-2.0,
107+ gir1.2-glib-2.0,
107 libautopilot-qt (>= 1.4),
108 libautopilot-qt (>= 1.4),
108 libqt5test5,
109 libqt5test5,
109 libqt5widgets5,
110 libqt5widgets5,
@@ -113,6 +114,7 @@ Depends: gir1.2-glib-2.0,
113 python-mock,
114 python-mock,
114 unity8 (>= ${source:Version}),
115 unity8 (>= ${source:Version}),
115 unity8-fake-env (>= ${source:Version}),
116 unity8-fake-env (>= ${source:Version}),
117+ url-dispatcher-tools,
116 ${misc:Depends},
118 ${misc:Depends},
117 ${python:Depends},
119 ${python:Depends},
118 ${shlibs:Depends},
120 ${shlibs:Depends},
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+9−13
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2013 Canonical
4+# Copyright (C) 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -44,9 +44,8 @@ class ApplicationLifecycleTests(UnityTestCase):
44 self.skipTest("Test cannot be run on the desktop.")
44 self.skipTest("Test cannot be run on the desktop.")
45
45
46 def swipe_screen_from_right(self):
46 def swipe_screen_from_right(self):
47− qml_view = self.main_window.get_qml_view()
47+ width = self.main_window.width
48− width = qml_view.width
49− height = qml_view.height
48+ height = self.main_window.height
50 start_x = width
49 start_x = width
51 start_y = int(height/2)
50 start_y = int(height/2)
52 end_x = int(width/2)
51 end_x = int(width/2)
@@ -55,9 +54,6 @@ class ApplicationLifecycleTests(UnityTestCase):
55 logger.info("Swiping screen from the right edge")
54 logger.info("Swiping screen from the right edge")
56 self.touch.drag(start_x, start_y, end_x, end_y)
55 self.touch.drag(start_x, start_y, end_x, end_y)
57
56
58− def _get_current_focused_app_id(self):
59− return self._proxy.select_single("Shell").currentFocusedAppId
60−
61 def _launch_app(self, app_name):
57 def _launch_app(self, app_name):
62 """Launches the application *app_name*
58 """Launches the application *app_name*
63
59
@@ -86,7 +82,7 @@ class ApplicationLifecycleTests(UnityTestCase):
86
82
87 self.assertThat(app, NotEquals(None))
83 self.assertThat(app, NotEquals(None))
88 self.assertThat(
84 self.assertThat(
89− self._get_current_focused_app_id(),
85+ self.main_window.get_current_focused_app_id(),
90 Eventually(Equals("messaging-app"))
86 Eventually(Equals("messaging-app"))
91 )
87 )
92
88
@@ -98,13 +94,13 @@ class ApplicationLifecycleTests(UnityTestCase):
98
94
99 self._launch_app("messaging-app")
95 self._launch_app("messaging-app")
100 self.assertThat(
96 self.assertThat(
101− self._get_current_focused_app_id(),
97+ self.main_window.get_current_focused_app_id(),
102 Eventually(Equals("messaging-app"))
98 Eventually(Equals("messaging-app"))
103 )
99 )
104
100
105 self._launch_app("address-book-app")
101 self._launch_app("address-book-app")
106 self.assertThat(
102 self.assertThat(
107− self._get_current_focused_app_id(),
103+ self.main_window.get_current_focused_app_id(),
108 Eventually(Equals("address-book-app"))
104 Eventually(Equals("address-book-app"))
109 )
105 )
110
106
@@ -119,19 +115,19 @@ class ApplicationLifecycleTests(UnityTestCase):
119
115
120 self._launch_app("messaging-app")
116 self._launch_app("messaging-app")
121 self.assertThat(
117 self.assertThat(
122− self._get_current_focused_app_id(),
118+ self.main_window.get_current_focused_app_id(),
123 Eventually(Equals("messaging-app"))
119 Eventually(Equals("messaging-app"))
124 )
120 )
125
121
126 self._launch_app("address-book-app")
122 self._launch_app("address-book-app")
127 self.assertThat(
123 self.assertThat(
128− self._get_current_focused_app_id(),
124+ self.main_window.get_current_focused_app_id(),
129 Eventually(Equals("address-book-app"))
125 Eventually(Equals("address-book-app"))
130 )
126 )
131
127
132 self.swipe_screen_from_right()
128 self.swipe_screen_from_right()
133
129
134 self.assertThat(
130 self.assertThat(
135− self._get_current_focused_app_id(),
131+ self.main_window.get_current_focused_app_id(),
136 Eventually(Equals("messaging-app"))
132 Eventually(Equals("messaging-app"))
137 )
133 )
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.pynew file+56
@@ -0,0 +1,56 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2014 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+"""Test the integration with the URL dispatcher service."""
21+
22+import os
23+
24+from autopilot import platform
25+from autopilot.matchers import Eventually
26+from testtools.matchers import Equals
27+
28+from unity8 import process_helpers
29+from unity8.shell import tests
30+
31+
32+class URLDispatcherTestCase(tests.UnityTestCase):
33+
34+ scenarios = tests._get_device_emulation_scenarios()
35+
36+ def setUp(self):
37+ if platform.model() == 'Desktop':
38+ self.skipTest("URL dispatcher doesn't works on the desktop.")
39+ super(URLDispatcherTestCase, self).setUp()
40+ unity_proxy = self.launch_unity()
41+ process_helpers.unlock_unity(unity_proxy)
42+
43+ def test_swipe_out_application_started_by_url_dispatcher(self):
44+ self.assertEqual('', self.main_window.get_current_focused_app_id())
45+ # XXX we shouldn't depend on external applictions; but the camera app
46+ # is already a depedency for other tests, so it's not that bad to use
47+ # it while the url-dispatcher implements the testability features to
48+ # let us launch a fake app. --elopio - 2014-02-05
49+ os.system('url-dispatcher application:///camera-app.desktop')
50+ self.assertThat(
51+ self.main_window.get_current_focused_app_id,
52+ Eventually(Equals('camera-app')))
53+ self.main_window.show_dash_swiping()
54+ self.assertThat(
55+ self.main_window.get_current_focused_app_id,
56+ Eventually(Equals('')))
tests/autopilot/unity8/process_helpers.py+7−6
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Utilities
3# Unity Autopilot Utilities
4−# Copyright (C) 2013 Canonical
4+# Copyright (C) 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -23,8 +23,8 @@ from autopilot.introspection import (
23)
23)
24import logging
24import logging
25import subprocess
25import subprocess
26−from unity8.shell.emulators import UnityEmulatorBase
26+from unity8.shell import emulators
27−from unity8.shell.emulators.main_window import MainWindow
27+from unity8.shell.emulators import main_window as main_window_emulator
28
28
29logger = logging.getLogger(__name__)
29logger = logging.getLogger(__name__)
30
30
@@ -54,7 +54,7 @@ def unlock_unity(unity_proxy_obj=None):
54 try:
54 try:
55 pid = _get_unity_pid()
55 pid = _get_unity_pid()
56 unity = _get_unity_proxy_object(pid)
56 unity = _get_unity_proxy_object(pid)
57− main_window = MainWindow(unity)
57+ main_window = unity.select_single(main_window_emulator.QQuickView)
58 except ProcessSearchError as e:
58 except ProcessSearchError as e:
59 raise CannotAccessUnity(
59 raise CannotAccessUnity(
60 "Cannot introspect unity, make sure that it has been started "
60 "Cannot introspect unity, make sure that it has been started "
@@ -64,7 +64,8 @@ def unlock_unity(unity_proxy_obj=None):
64 % str(e)
64 % str(e)
65 )
65 )
66 else:
66 else:
67− main_window = MainWindow(unity_proxy_obj)
67+ main_window = unity_proxy_obj.select_single(
68+ main_window_emulator.QQuickView)
68
69
69 greeter = main_window.get_greeter()
70 greeter = main_window.get_greeter()
70 if greeter.created == False:
71 if greeter.created == False:
@@ -155,5 +156,5 @@ def _get_unity_pid():
155def _get_unity_proxy_object(pid):
156def _get_unity_proxy_object(pid):
156 return get_proxy_object_for_existing_process(
157 return get_proxy_object_for_existing_process(
157 pid=pid,
158 pid=pid,
158− emulator_base=UnityEmulatorBase,
159+ emulator_base=emulators.UnityEmulatorBase,
159 )
160 )
tests/autopilot/unity8/shell/emulators/__init__.py−1
@@ -19,7 +19,6 @@
19
19
20from autopilot import input, introspection
20from autopilot import input, introspection
21
21
22−
23class UnityEmulatorBase(introspection.CustomEmulatorBase):
22class UnityEmulatorBase(introspection.CustomEmulatorBase):
24 """A base class for all unity emulators."""
23 """A base class for all unity emulators."""
25
24
tests/autopilot/unity8/shell/emulators/main_window.py+45−27
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -17,85 +17,103 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
18#
19
19
20+import logging
20
21
22+from autopilot import logging as autopilot_logging
23+
24+from unity8.shell import emulators
21from unity8.shell.emulators.greeter import Greeter
25from unity8.shell.emulators.greeter import Greeter
22from unity8.shell.emulators.hud import Hud
26from unity8.shell.emulators.hud import Hud
23from unity8.shell.emulators.dash import Dash
27from unity8.shell.emulators.dash import Dash
24from unity8.shell.emulators.launcher import Launcher
28from unity8.shell.emulators.launcher import Launcher
25
29
30+logger = logging.getLogger(__name__)
26
31
27−class MainWindow(object):
28− """An emulator class that makes it easy to interact with the shell"""
29−
30− def __init__(self, app):
31− self.app = app
32
32
33− def get_qml_view(self):
33+class QQuickView(emulators.UnityEmulatorBase):
34− """Get the main QML view"""
34+ """An emulator class that makes it easy to interact with the shell"""
35− return self.app.select_single("QQuickView")
36
35
37 def get_greeter(self):
36 def get_greeter(self):
38− return self.app.select_single(Greeter)
37+ return self.select_single(Greeter)
39
38
40 def get_greeter_content_loader(self):
39 def get_greeter_content_loader(self):
41− return self.app.wait_select_single(
40+ return self.wait_select_single(
42 "QQuickLoader",
41 "QQuickLoader",
43 objectName="greeterContentLoader"
42 objectName="greeterContentLoader"
44 )
43 )
45
44
46 def get_greeter_background(self):
45 def get_greeter_background(self):
46+ return self.select_single(
47− return self.app.select_single("CrossFadeImage", objectName="greeterBackground")
47+ "CrossFadeImage", objectName="greeterBackground")
48
48
49 def get_login_loader(self):
49 def get_login_loader(self):
50− return self.app.select_single("QQuickLoader", objectName="loginLoader")
50+ return self.select_single("QQuickLoader", objectName="loginLoader")
51
51
52 def get_login_list(self):
52 def get_login_list(self):
53− return self.app.select_single("LoginList")
53+ return self.select_single("LoginList")
54
54
55 def get_hud(self):
55 def get_hud(self):
56− return self.app.select_single(Hud)
56+ return self.select_single(Hud)
57
57
58 def get_hud_showable(self):
58 def get_hud_showable(self):
59− return self.app.select_single("Showable", objectName="hudShowable")
59+ return self.select_single("Showable", objectName="hudShowable")
60
60
61 def get_hud_show_button(self):
61 def get_hud_show_button(self):
62− return self.app.select_single("HudButton")
62+ return self.select_single("HudButton")
63
63
64 def get_hud_edge_drag_area(self):
64 def get_hud_edge_drag_area(self):
65− return self.app.select_single(objectName="hudDragArea")
65+ return self.select_single(objectName="hudDragArea")
66
66
67 def get_dash(self):
67 def get_dash(self):
68− return self.app.select_single(Dash)
68+ return self.select_single(Dash)
69
69
70 def get_bottombar(self):
70 def get_bottombar(self):
71− return self.app.select_single("Bottombar")
71+ return self.select_single("Bottombar")
72
72
73 def get_launcher(self):
73 def get_launcher(self):
74− return self.app.select_single(Launcher)
74+ return self.select_single(Launcher)
75
75
76 def get_pinPadLoader(self):
76 def get_pinPadLoader(self):
77− return self.app.select_single(
77+ return self.select_single(
78 "QQuickLoader",
78 "QQuickLoader",
79 objectName="pinPadLoader"
79 objectName="pinPadLoader"
80 )
80 )
81
81
82 def get_pinPadButton(self, buttonId):
82 def get_pinPadButton(self, buttonId):
83− return self.app.select_single(
83+ return self.select_single(
84 "PinPadButton",
84 "PinPadButton",
85 objectName="pinPadButton%i" % buttonId
85 objectName="pinPadButton%i" % buttonId
86 )
86 )
87
87
88 def get_lockscreen(self):
88 def get_lockscreen(self):
89− return self.app.select_single("Lockscreen")
89+ return self.select_single("Lockscreen")
90
90
91 def get_pinentryField(self):
91 def get_pinentryField(self):
92− return self.app.select_single(objectName="pinentryField")
92+ return self.select_single(objectName="pinentryField")
93
93
94 def get_indicator(self, indicator_name):
94 def get_indicator(self, indicator_name):
95− return self.app.select_single(
95+ return self.select_single(
96 'DefaultIndicatorWidget',
96 'DefaultIndicatorWidget',
97 objectName=indicator_name+'-widget'
97 objectName=indicator_name+'-widget'
98 )
98 )
99
99
100 def get_shell_background(self):
100 def get_shell_background(self):
101+ return self.select_single(
101− return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
102+ "CrossFadeImage", objectName="backgroundImage")
103+
104+ @autopilot_logging.log_action(logger.info)
105+ def show_dash_swiping(self):
106+ """Show the dash swiping from the left."""
107+ width = self.width
108+ height = self.height
109+ start_x = 0
110+ start_y = height // 2
111+ end_x = width // 2
112+ end_y = start_y
113+
114+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
115+ return self.get_dash()
116+
117+ def get_current_focused_app_id(self):
118+ """Return the id of the focused application."""
119+ return self.select_single('Shell').currentFocusedAppId
tests/autopilot/unity8/shell/tests/__init__.py+3−3
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -43,8 +43,8 @@ from unity8 import (
43 get_data_dirs
43 get_data_dirs
44)
44)
45from unity8.process_helpers import restart_unity_with_testability
45from unity8.process_helpers import restart_unity_with_testability
46+from unity8.shell.emulators import main_window as main_window_emulator
46from unity8.shell.emulators.dash import Dash
47from unity8.shell.emulators.dash import Dash
47−from unity8.shell.emulators.main_window import MainWindow
48
48
49
49
50logger = logging.getLogger(__name__)
50logger = logging.getLogger(__name__)
@@ -391,4 +391,4 @@ class UnityTestCase(AutopilotTestCase):
391
391
392 @property
392 @property
393 def main_window(self):
393 def main_window(self):
394− return MainWindow(self._proxy)
394+ return self._proxy.select_single(main_window_emulator.QQuickView)
tests/autopilot/unity8/shell/tests/test_hud.py+4−7
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@ class TestHud(UnityTestCase, DragMixin):
41 """
41 """
42 unity_proxy = self.launch_unity()
42 unity_proxy = self.launch_unity()
43 unlock_unity(unity_proxy)
43 unlock_unity(unity_proxy)
44− window = self.main_window.get_qml_view()
45 hud_show_button = self.main_window.get_hud_show_button()
44 hud_show_button = self.main_window.get_hud_show_button()
46 edge_drag_area = self.main_window.get_hud_edge_drag_area()
45 edge_drag_area = self.main_window.get_hud_edge_drag_area()
47 hud = self.main_window.get_hud()
46 hud = self.main_window.get_hud()
@@ -49,7 +48,7 @@ class TestHud(UnityTestCase, DragMixin):
49 self._launch_test_app_from_app_screen()
48 self._launch_test_app_from_app_screen()
50
49
51 swipe_coords = hud.get_button_swipe_coords(
50 swipe_coords = hud.get_button_swipe_coords(
52− window,
51+ self.main_window,
53 hud_show_button
52 hud_show_button
54 )
53 )
55 initialBottomMargin = int(hud_show_button.bottomMargin)
54 initialBottomMargin = int(hud_show_button.bottomMargin)
@@ -83,14 +82,13 @@ class TestHud(UnityTestCase, DragMixin):
83 """
82 """
84 unity_proxy = self.launch_unity()
83 unity_proxy = self.launch_unity()
85 unlock_unity(unity_proxy)
84 unlock_unity(unity_proxy)
86− window = self.main_window.get_qml_view()
87 hud_show_button = self.main_window.get_hud_show_button()
85 hud_show_button = self.main_window.get_hud_show_button()
88 hud = self.main_window.get_hud()
86 hud = self.main_window.get_hud()
89
87
90 self._launch_test_app_from_app_screen()
88 self._launch_test_app_from_app_screen()
91
89
92 swipe_coords = hud.get_button_swipe_coords(
90 swipe_coords = hud.get_button_swipe_coords(
93− window,
91+ self.main_window,
94 hud_show_button
92 hud_show_button
95 )
93 )
96
94
@@ -137,7 +135,6 @@ class TestHud(UnityTestCase, DragMixin):
137 """
135 """
138 unity_proxy = self.launch_unity()
136 unity_proxy = self.launch_unity()
139 unlock_unity(unity_proxy)
137 unlock_unity(unity_proxy)
140− window = self.main_window.get_qml_view()
141 hud = self.main_window.get_hud()
138 hud = self.main_window.get_hud()
142
139
143 self._launch_test_app_from_app_screen()
140 self._launch_test_app_from_app_screen()
@@ -146,7 +143,7 @@ class TestHud(UnityTestCase, DragMixin):
146
143
147 start_x, start_y = hud.get_close_button_coords()
144 start_x, start_y = hud.get_close_button_coords()
148 end_x = start_x
145 end_x = start_x
149− end_y = int(window.height / 2)
146+ end_y = int(self.main_window.height / 2)
150
147
151 self.touch.drag(start_x, start_y, end_x, end_y)
148 self.touch.drag(start_x, start_y, end_x, end_y)
152 self.assertThat(hud.shown, Eventually(Equals(False)))
149 self.assertThat(hud.shown, Eventually(Equals(False)))
tests/autopilot/unity8/shell/tests/test_notifications.py+2−3
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -61,8 +61,7 @@ class NotificationsBase(UnityTestCase):
61 return os.path.dirname(__file__) + "/../../../../../qml/graphics/" + icon_name
61 return os.path.dirname(__file__) + "/../../../../../qml/graphics/" + icon_name
62
62
63 def _get_notifications_list(self):
63 def _get_notifications_list(self):
64− main_view = self.main_window.get_qml_view()
64+ return self.main_window.select_single(
65− return main_view.select_single(
66 "Notifications",
65 "Notifications",
67 objectName='notificationList'
66 objectName='notificationList'
68 )
67 )