on xenial help sign in
Initial implementation of veebers' comments, more to do.
commit4c919e5599bd888f7b25a5e2c29944e29326c60c authorAllan LeSage <allan.lesage@canonical.com> dateFri 29 Nov 2013, 14:02 (13 years ago) parent29047e4
4 files changed+78−60
tests/autopilot/unity8/indicators/emulators/__init__.py+17 tests/autopilot/unity8/indicators/emulators/widget.py+48 tests/autopilot/unity8/indicators/tests/__init__.py−48 tests/autopilot/unity8/indicators/tests/test_indicators.py+13−12
tests/autopilot/unity8/indicators/emulators/__init__.pynew file+17
@@ -0,0 +1,17 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity - Indicators Autopilot Test Suite
4+# Copyright (C) 2013 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/>.
tests/autopilot/unity8/indicators/emulators/widget.pynew file+48
@@ -0,0 +1,48 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from autopilot.introspection import CustomEmulatorBase
20+from autopilot.input import Touch
21+
22+
23+# TODO: submit to autopilot.introspection.types.Rectangle
24+def get_center(global_rect):
25+ """Returns (x, y) representing the center of a globalRect."""
26+ return (global_rect[0]+int(global_rect[2]/2),
27+ global_rect[1]+int(global_rect[3]/2))
28+
29+
30+class DefaultIndicatorWidget(CustomEmulatorBase):
31+
32+ def swipe_to_open_indicator(self, indicator_widget, window):
33+ """Swipe to open the indicator, wait until it's open."""
34+ start_x, start_y = get_center(indicator_widget.globalRect)
35+ end_x = start_x
36+ end_y = window.height
37+ self.pointer.drag(start_x, start_y,
38+ end_x, end_y)
39+ # TODO: assert that the indicator page opened
40+
41+ def swipe_to_close_indicator(self, indicator_widget, window):
42+ """Swipe to close the indicator, wait until it's closed."""
43+ end_x, end_y = get_center(indicator_widget.globalRect)
44+ start_x = end_x
45+ start_y = window.height
46+ self.pointer.drag(start_x, start_y,
47+ end_x, end_y)
48+ # TODO: assert that the indicator page closed
tests/autopilot/unity8/indicators/tests/__init__.py−48
@@ -15,51 +15,3 @@
1515#
1616# You should have received a copy of the GNU General Public License
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−
19−from __future__ import absolute_import
20−
21−from autopilot.input import Pointer, Touch
22−
23−from unity8.shell.tests import UnityTestCase
24−
25−
26−# TODO: submit to autopilot.introspection.types.Rectangle
27−def get_center(global_rect):
28− """Returns (x, y) representing the center of a globalRect."""
29− return (global_rect[0]+int(global_rect[2]/2),
30− global_rect[1]+int(global_rect[3]/2))
31−
32−
33−class IndicatorBaseTestCase(UnityTestCase):
34−
35− def setUp(self):
36− super(IndicatorBaseTestCase, self).setUp()
37− self.pointer = Pointer(Touch.create())
38−
39− # Because some tests are manually manipulating the finger, we want to
40− # cleanup if the test fails, but we don't want to fail with an exception if
41− # we don't.
42− def _maybe_release_finger(self):
43− """Only release the finger if it is in fact down."""
44− if self.touch._touch_finger is not None:
45− self.touch.release()
46−
47− def swipe_to_open_indicator(self, indicator_widget, window):
48− """Swipe to open the indicator, wait until it's open."""
49− start_x, start_y = get_center(indicator_widget.globalRect)
50− end_x = start_x
51− end_y = window.height
52− self.pointer.drag(start_x, start_y,
53− end_x, end_y)
54− self.addCleanup(self._maybe_release_finger)
55− # TODO: assert that the indicator page opened
56−
57− def swipe_to_close_indicator(self, indicator_widget, window):
58− """Swipe to close the indicator, wait until it's closed."""
59− end_x, end_y = get_center(indicator_widget.globalRect)
60− start_x = end_x
61− start_y = window.height
62− self.pointer.drag(start_x, start_y,
63− end_x, end_y)
64− self.addCleanup(self._maybe_release_finger)
65− # TODO: assert that the indicator page closed
tests/autopilot/unity8/indicators/tests/test_indicators.py+13−12
@@ -20,13 +20,13 @@
2020from __future__ import absolute_import
2121
2222from autopilot import platform
23−from testtools import skipIf
2423
24+from unity8.indicators.emulators.widget import DefaultIndicatorWidget
2525from unity8.process_helpers import unlock_unity
26−from unity8.indicators.tests import IndicatorBaseTestCase
26+from unity8.shell.tests import UnityTestCase
2727
2828
29−class IndicatorTestCase(IndicatorBaseTestCase):
29+class IndicatorTestCase(UnityTestCase):
3030
3131 scenarios = [
3232 ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
@@ -38,9 +38,9 @@ class IndicatorTestCase(IndicatorBaseTestCase):
3838 ('Sound', dict(indicator_name='indicator-sound')),
3939 ]
4040
41− @skipIf(platform.image_codename() == 'Desktop',
42− "Unity8/phablet-only test!")
4341 def setUp(self):
42+ if model() == "Desktop":
43+ self.skipTest("Test cannot be run on the desktop.")
4444 super(IndicatorTestCase, self).setUp()
4545
4646 def test_indicator_exists(self):
@@ -53,7 +53,7 @@ class IndicatorTestCase(IndicatorBaseTestCase):
5353 self.assertIsNotNone(widget)
5454
5555
56−class IndicatorPageTitleMatchesWidgetTestCase(IndicatorBaseTestCase):
56+class IndicatorPageTitleMatchesWidgetTestCase(UnityTestCase):
5757
5858 scenarios = [
5959 ('Bluetooth', dict(indicator_name='indicator-bluetooth',
@@ -72,24 +72,25 @@ class IndicatorPageTitleMatchesWidgetTestCase(IndicatorBaseTestCase):
7272 title='Sound')),
7373 ]
7474
75− @skipIf(platform.image_codename() == 'Desktop',
76− "Unity8/phablet-only test!")
7775 def setUp(self):
76+ if model() == "Desktop":
77+ self.skipTest("Test cannot be run on the desktop.")
7878 super(IndicatorPageTitleMatchesWidgetTestCase, self).setUp()
7979
8080 def test_indicator_page_title_matches_widget(self):
81− """When I swipe open an indicator, I should see its correct title.
81+ """Swiping open an indicator must show its correct title.
8282
8383 See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
8484 """
8585 unity_proxy = self.launch_unity()
8686 unlock_unity(unity_proxy)
8787 window = self.main_window.get_qml_view()
88− widget = self.main_window.get_indicator_widget(
89− self.indicator_name
88+ widget = DefaultIndicatorWidget(
89+ self.main_window.get_indicator_widget(
90+ self.indicator_name
91+ )
9092 )
9193 self.assertIsNotNone(widget)
9294 self.swipe_to_open_indicator(widget, window)
9395 title = window.wait_select_single("IndicatorPage",
9496 title=self.title)
95− self.assertIsNotNone(title)