on xenial help sign in
Remove emulator, preferring main_window opening of indicator.
commit53a2287a05112ed9120633ea938dfbd1385c61da authorAllan LeSage <allan.lesage@canonical.com> dateThu 27 Mar 2014, 17:07 (13 years ago) parentc0c316d
5 files changed+36−92
tests/autopilot/unity8/indicators/emulators/__init__.py−18 tests/autopilot/unity8/indicators/emulators/widget.py−57 tests/autopilot/unity8/indicators/tests/__init__.py+1−1 tests/autopilot/unity8/indicators/tests/test_indicators.py+7−12 tests/autopilot/unity8/shell/emulators/main_window.py+28−4
tests/autopilot/unity8/indicators/emulators/__init__.pydeleted−18
@@ -1,18 +0,0 @@
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/>.
18−#
tests/autopilot/unity8/indicators/emulators/widget.pydeleted−57
@@ -1,57 +0,0 @@
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/>.
18−
19−from unity8.shell.emulators import UnityEmulatorBase
20−
21−
22−class DefaultIndicatorWidget(UnityEmulatorBase):
23−
24− """The indicator's icon in the menu-bar."""
25−
26− def __init__(self, *args, **kwargs):
27− super(DefaultIndicatorWidget, self).__init__(*args, **kwargs)
28−
29− # TODO: submit to autopilot.introspection.types.Rectangle [alesage 2013-12-06]
30− def get_center(self):
31− """Returns (x, y) representing the center of a globalRect."""
32− return (
33− self.globalRect.x+int(self.globalRect.width/2),
34− self.globalRect.y+int(self.globalRect.height/2)
35− )
36−
37− def swipe_to_open_indicator(self, window):
38− """Swipe to open the indicator, wait until it's open."""
39− start_x, start_y = self.get_center()
40− end_x = start_x
41− end_y = window.height
42− self.pointing_device.drag(
43− start_x, start_y,
44− end_x, end_y
45− )
46− # TODO: assert that the indicator page opened [alesage 2013-12-06]
47−
48− def swipe_to_close_indicator(self, window):
49− """Swipe to close the indicator, wait until it's closed."""
50− end_x, end_y = self.get_center()
51− start_x = end_x
52− start_y = window.height
53− self.pointing_device.drag(
54− start_x, start_y,
55− end_x, end_y
56− )
57− # TODO: assert that the indicator page closed [alesage 2013-12-06]
tests/autopilot/unity8/indicators/tests/__init__.py+1−1
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity - Indicators Autopilot Test Suite
4−# Copyright (C) 2013 Canonical
4+# Copyright (C) 2013, 2014 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
tests/autopilot/unity8/indicators/tests/test_indicators.py+7−12
@@ -18,7 +18,6 @@
1818
1919from __future__ import absolute_import
2020
21−from autopilot import platform
2221from testscenarios import multiply_scenarios
2322
2423from unity8.process_helpers import unlock_unity
@@ -30,9 +29,11 @@ class IndicatorTestCase(UnityTestCase):
3029 device_emulation_scenarios = _get_device_emulation_scenarios()
3130
3231 def setUp(self):
33− if platform.model() == "Desktop":
34− self.skipTest("Test cannot be run on the desktop.")
32+ if platform.model() == 'Desktop':
33+ self.skipTest('Test cannot be run on the desktop.')
3534 super(IndicatorTestCase, self).setUp()
35+ self.unity_proxy = self.launch_unity()
36+ unlock_unity(self.unity_proxy)
3637
3738
3839class IndicatorExistsTestCase(IndicatorTestCase):
@@ -52,8 +53,6 @@ class IndicatorExistsTestCase(IndicatorTestCase):
5253 )
5354
5455 def test_indicator_exists(self):
55− unity_proxy = self.launch_unity()
56− unlock_unity(unity_proxy)
5756 self.main_window.get_indicator_widget(
5857 self.indicator_name
5958 )
@@ -87,11 +86,7 @@ class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
8786
8887 See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
8988 """
90− unity_proxy = self.launch_unity()
91− unlock_unity(unity_proxy)
92− widget = self.main_window.get_indicator_widget(self.indicator_name)
93− widget.swipe_to_open_indicator(self.main_window)
94− indicator_page = self.main_window.get_indicator_page(
95− indicator_title=self.title
96− )
89+ indicator_page = self.main_window.open_indicator_page(
90+ self.indicator_name)
9791 self.assertTrue(indicator_page.visible)
92+ self.assertEqual(indicator_page.title, self.title)
tests/autopilot/unity8/shell/emulators/main_window.py+28−4
@@ -20,13 +20,13 @@
2020import logging
2121
2222from autopilot import logging as autopilot_logging
23+from autopilot.input._common import get_center_point
2324
2425from unity8.shell import emulators
2526from unity8.shell.emulators.greeter import Greeter
2627from unity8.shell.emulators.hud import Hud
2728from unity8.shell.emulators.dash import Dash
2829from unity8.shell.emulators.launcher import Launcher
29−from unity8.indicators.emulators.widget import DefaultIndicatorWidget
3030
3131logger = logging.getLogger(__name__)
3232
@@ -90,16 +90,40 @@ class QQuickView(emulators.UnityEmulatorBase):
9090
9191 def get_indicator_widget(self, indicator_name):
9292 return self.select_single(
93− DefaultIndicatorWidget,
93+ 'DefaultIndicatorWidget',
9494 objectName=indicator_name+'-widget'
9595 )
9696
97− def get_indicator_page(self, indicator_title):
97+ def get_indicator_page(self, indicator_name):
9898 return self.select_single(
9999 'DefaultIndicatorPage',
100− title=indicator_title
100+ objectName=indicator_name+'-page'
101101 )
102102
103+ @autopilot_logging.log_action(logger.info)
104+ def open_indicator_page(self, indicator_name):
105+ """Return the indicator page.
106+
107+ Swipe to open the indicator, wait until it's open.
108+ """
109+ widget = self.get_indicator_widget(indicator_name)
110+ start_x, start_y = get_center_point(widget)
111+ end_x = start_x
112+ end_y = self.height
113+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
114+ # TODO: assert that the indicator page opened [alesage 2013-12-06]
115+ return self.get_indicator_page(indicator_name)
116+
117+ @autopilot_logging.log_action(logger.info)
118+ def close_indicator_page(self, indicator_name):
119+ """Swipe to close the indicator, wait until it's closed."""
120+ widget = self.get_indicator_widget(indicator_name)
121+ end_x, end_y = get_center_point(widget)
122+ start_x = end_x
123+ start_y = self.height
124+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
125+ # TODO: assert that the indicator page closed [alesage 2013-12-06]
126+
103127 def get_shell_background(self):
104128 return self.select_single(
105129 "CrossFadeImage", objectName="backgroundImage")