on xenial help sign in
Add DisplayIndicator helper
commitc46741ad69a89418d90cbd80fce423137af6ff53 authorYing-Chun Liu <paul.liu@canonical.com> dateTue 13 Jan 2015, 17:17 (12 years ago) parent2c1b6d0
3 files changed+85−16
tests/autopilot/unity8/indicators/__init__.py+72 tests/autopilot/unity8/indicators/tests/test_indicators.py+5−9 tests/autopilot/unity8/shell/emulators/main_window.py+8−7
tests/autopilot/unity8/indicators/__init__.py+72
@@ -0,0 +1,72 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Indicators Autopilot Test Suite
4+# Copyright (C) 2013, 2014, 2015 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 import input
20+from unity8.shell import emulators
21+from unity8.shell.emulators import main_window
22+import unity8.indicators
23+
24+class IndicatorsMenu (emulators.UnityEmulatorBase):
25+ """Autopilot helper for the IndicatorPage component."""
26+ def open(self):
27+ widget = self.select_single('IndicatorItem',objectName='indicator-sound-panelItem')
28+ start_x, start_y = input.get_center_point(widget)
29+ end_x = start_x
30+ end_y = self.height
31+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
32+ self.fullyOpened.wait_for(True)
33+
34+ def open_rotation_indicator(self):
35+ self.open()
36+ indicators_bar_flickable = self.select_single(
37+ 'IndicatorsBar').select_single(
38+ main_window.QQuickFlickable, objectName='flickable')
39+ indicators_bar_flickable.swipe_to_x_end()
40+ indicator_rotation_icon = self.select_single(
41+ objectName='indicator-rotation-lock-panelItem')
42+ self.pointing_device.click_object(indicator_rotation_icon)
43+ self.fullyOpened.wait_for(True)
44+ return DisplayIndicator(self.select_single('IndicatorPage', objectName='indicator-rotation-lock-page'))
45+
46+class DisplayIndicator (emulators.UnityEmulatorBase):
47+ def __init__ (self, subject):
48+ self.__subject = subject
49+ def __getattr__(self, name):
50+ return getattr(self.__subject, name)
51+
52+ def lock_rotation(self):
53+ """Toggles the rotation lock indicator to locked.
54+
55+ Swipes open indicator-display and ensures that rotation lock is toggled
56+ to 'On'.
57+
58+ """
59+ switcher = self.select_single('CheckBox', objectName='switcher')
60+ switcher.checked = True
61+ pass
62+
63+ def unlock_rotation(self):
64+ """Toggles the rotation lock indicator to unlocked.
65+
66+ Swipes open indicator-display and ensures that rotation lock is toggled
67+ to 'Off'.
68+
69+ """
70+ switcher = self.select_single('CheckBox', objectName='switcher')
71+ switcher.checked = False
72+ pass
tests/autopilot/unity8/indicators/tests/test_indicators.py+5−9
@@ -106,15 +106,11 @@ class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
106106 self.assertTrue(indicator_page.visible)
107107 self.assertEqual(indicator_page.title, self.title)
108108
109−
110109class DisplayIndicatorTestCase(IndicatorTestCase):
111110
112111 def test(self):
113− self.main_window.open_indicator_page('indicator-sound')
114− indicators_bar_flickable = self.main_window.select_single(
115− 'IndicatorsBar').select_single(
116− main_window.QQuickFlickable, objectName='flickable')
117− indicators_bar_flickable.swipe_to_x_end()
118− indicator_rotation_icon = self.main_window.select_single(
119− objectName='indicator-rotation-lock-panelItem')
120− self.main_window.pointing_device.click_object(indicator_rotation_icon)
112+
113+ indicators_menu = self.main_window._get_indicators_menu()
114+ display_indicator = indicators_menu.open_rotation_indicator()
115+ display_indicator.unlock_rotation()
116+ display_indicator.lock_rotation()
tests/autopilot/unity8/shell/emulators/main_window.py+8−7
@@ -26,6 +26,7 @@ from autopilot import input
2626from unity8.shell import emulators
2727from unity8.shell.emulators.greeter import Greeter
2828from unity8.shell.emulators.launcher import Launcher
29+import unity8.indicators
2930
3031logger = logging.getLogger(__name__)
3132
@@ -69,9 +70,15 @@ class QQuickView(emulators.UnityEmulatorBase):
6970 objectName=indicator_name+'-panelItem'
7071 )
7172
73+ def _get_indicators_menu(self):
74+ return self.select_single(
75+ unity8.indicators.IndicatorsMenu,
76+ objectName='indicators'
77+ )
78+
7279 def _get_indicator_page(self, indicator_name):
7380 return self.select_single(
74− IndicatorPage,
81+ 'IndicatorPage',
7582 objectName=indicator_name+'-page'
7683 )
7784
@@ -166,12 +173,6 @@ class QQuickView(emulators.UnityEmulatorBase):
166173 objectName='pinPadButton{}'.format(button_id)
167174 )
168175
169−
170−class IndicatorPage(emulators.UnityEmulatorBase):
171−
172− """Autopilot helper for the IndicatorPage component."""
173−
174−
175176class QQuickFlickable(ubuntuuitoolkit.QQuickFlickable):
176177
177178 def swipe_to_x_end(self):