on xenial help sign in
Implement veebers' suggested changes, need his review.
commit168cf1cc4b967d11927f49414f56b848a6fbaf48 authorAllan LeSage <allan.lesage@canonical.com> dateTue 3 Dec 2013, 16:01 (13 years ago) parent4c919e5
4 files changed+42−35
tests/autopilot/unity8/indicators/emulators/__init__.py+10−2 tests/autopilot/unity8/indicators/emulators/widget.py+13−11 tests/autopilot/unity8/indicators/tests/test_indicators.py+17−21 tests/autopilot/unity8/shell/emulators/main_window.py+2−1
tests/autopilot/unity8/indicators/emulators/__init__.py+10−2
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
3−# Unity - Indicators Autopilot Test Suite
4−# Copyright (C) 2013 Canonical
3+# Unity Indicators Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -15,3 +15,11 @@
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+
20+
21+from autopilot.introspection import CustomEmulatorBase
22+
23+
24+class IndicatorEmulatorBase(CustomEmulatorBase):
25+ """A base class for indicator emulators."""
tests/autopilot/unity8/indicators/emulators/widget.py+13−11
@@ -16,31 +16,33 @@
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/>.
1818
19−from autopilot.introspection import CustomEmulatorBase
2019from autopilot.input import Touch
2120
21+from unity8.indicators.emulators import IndicatorEmulatorBase
2222
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))
2823
24+class DefaultIndicatorWidget(IndicatorEmulatorBase):
2925
30−class DefaultIndicatorWidget(CustomEmulatorBase):
26+ """The indicator's icon in the menu-bar."""
3127
32− def swipe_to_open_indicator(self, indicator_widget, window):
28+ # TODO: submit to autopilot.introspection.types.Rectangle
29+ def get_center(global_rect):
30+ """Returns (x, y) representing the center of a globalRect."""
31+ return (self.global_rect[0]+int(self.global_rect[2]/2),
32+ self.global_rect[1]+int(self.global_rect[3]/2))
33+
34+ def swipe_to_open_indicator(self, window):
3335 """Swipe to open the indicator, wait until it's open."""
34− start_x, start_y = get_center(indicator_widget.globalRect)
36+ start_x, start_y = self.get_center()
3537 end_x = start_x
3638 end_y = window.height
3739 self.pointer.drag(start_x, start_y,
3840 end_x, end_y)
3941 # TODO: assert that the indicator page opened
4042
41− def swipe_to_close_indicator(self, indicator_widget, window):
43+ def swipe_to_close_indicator(self, window):
4244 """Swipe to close the indicator, wait until it's closed."""
43− end_x, end_y = get_center(indicator_widget.globalRect)
45+ end_x, end_y = self.get_center()
4446 start_x = end_x
4547 start_y = window.height
4648 self.pointer.drag(start_x, start_y,
tests/autopilot/unity8/indicators/tests/test_indicators.py+17−21
@@ -1,6 +1,6 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
3−# Unity - Indicators Autopilot Test Suite
3+# Unity Indicators Autopilot Test Suite
44# Copyright (C) 2013 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
@@ -19,7 +19,7 @@
1919
2020from __future__ import absolute_import
2121
22−from autopilot import platform
22+from autopilot.platform import model
2323
2424from unity8.indicators.emulators.widget import DefaultIndicatorWidget
2525from unity8.process_helpers import unlock_unity
@@ -39,7 +39,7 @@ class IndicatorTestCase(UnityTestCase):
3939 ]
4040
4141 def setUp(self):
42− if model() == "Desktop":
42+ if self.model() == "Desktop":
4343 self.skipTest("Test cannot be run on the desktop.")
4444 super(IndicatorTestCase, self).setUp()
4545
@@ -56,20 +56,20 @@ class IndicatorTestCase(UnityTestCase):
5656class IndicatorPageTitleMatchesWidgetTestCase(UnityTestCase):
5757
5858 scenarios = [
59− ('Bluetooth', dict(indicator_name='indicator-bluetooth',
60− title='Bluetooth')),
61− ('Datetime', dict(indicator_name='indicator-datetime',
62− title='Upcoming')),
63− ('Location', dict(indicator_name='indicator-location',
64− title='Location')),
65− ('Messaging', dict(indicator_name='indicator-messages',
66− title='Incoming')),
67− ('Network', dict(indicator_name='indicator-network',
68− title='Network')),
59+ #('Bluetooth', dict(indicator_name='indicator-bluetooth',
60+ # title='Bluetooth')),
61+ #('Datetime', dict(indicator_name='indicator-datetime',
62+ # title='Upcoming')),
63+ #('Location', dict(indicator_name='indicator-location',
64+ # title='Location')),
65+ #('Messaging', dict(indicator_name='indicator-messages',
66+ # title='Incoming')),
67+ #('Network', dict(indicator_name='indicator-network',
68+ # title='Network')),
6969 ('Power', dict(indicator_name='indicator-power',
7070 title='Battery')),
71− ('Sound', dict(indicator_name='indicator-sound',
72− title='Sound')),
71+ #('Sound', dict(indicator_name='indicator-sound',
72+ # title='Sound')),
7373 ]
7474
7575 def setUp(self):
@@ -85,12 +85,8 @@ class IndicatorPageTitleMatchesWidgetTestCase(UnityTestCase):
8585 unity_proxy = self.launch_unity()
8686 unlock_unity(unity_proxy)
8787 window = self.main_window.get_qml_view()
88− widget = DefaultIndicatorWidget(
89− self.main_window.get_indicator_widget(
90− self.indicator_name
91− )
92− )
88+ widget = self.main_window.get_indicator_widget(self.indicator_name)
9389 self.assertIsNotNone(widget)
94− self.swipe_to_open_indicator(widget, window)
90+ widget.swipe_to_open_indicator(window)
9591 title = window.wait_select_single("IndicatorPage",
9692 title=self.title)
tests/autopilot/unity8/shell/emulators/main_window.py+2−1
@@ -22,6 +22,7 @@ from unity8.shell.emulators.greeter import Greeter
2222from unity8.shell.emulators.hud import Hud
2323from unity8.shell.emulators.dash import Dash
2424from unity8.shell.emulators.launcher import Launcher
25+from unity8.indicators.emulators.widget import DefaultIndicatorWidget
2526
2627
2728class MainWindow(object):
@@ -93,7 +94,7 @@ class MainWindow(object):
9394
9495 def get_indicator_widget(self, indicator_name):
9596 return self.app.select_single(
96− 'DefaultIndicatorWidget',
97+ DefaultIndicatorWidget,
9798 objectName=indicator_name+'-widget'
9899 )
99100