on xenial help sign in
Add DisplayIndicator helper
c46741aYing-Chun Liu
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):
106 self.assertTrue(indicator_page.visible)
106 self.assertTrue(indicator_page.visible)
107 self.assertEqual(indicator_page.title, self.title)
107 self.assertEqual(indicator_page.title, self.title)
108
108
109−
110class DisplayIndicatorTestCase(IndicatorTestCase):
109class DisplayIndicatorTestCase(IndicatorTestCase):
111
110
112 def test(self):
111 def test(self):
113− self.main_window.open_indicator_page('indicator-sound')
112+
114− indicators_bar_flickable = self.main_window.select_single(
113+ indicators_menu = self.main_window._get_indicators_menu()
115− 'IndicatorsBar').select_single(
114+ display_indicator = indicators_menu.open_rotation_indicator()
116− main_window.QQuickFlickable, objectName='flickable')
115+ display_indicator.unlock_rotation()
117− indicators_bar_flickable.swipe_to_x_end()
116+ display_indicator.lock_rotation()
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)
tests/autopilot/unity8/shell/emulators/main_window.py+8−7
@@ -26,6 +26,7 @@ from autopilot import input
26from unity8.shell import emulators
26from unity8.shell import emulators
27from unity8.shell.emulators.greeter import Greeter
27from unity8.shell.emulators.greeter import Greeter
28from unity8.shell.emulators.launcher import Launcher
28from unity8.shell.emulators.launcher import Launcher
29+import unity8.indicators
29
30
30logger = logging.getLogger(__name__)
31logger = logging.getLogger(__name__)
31
32
@@ -69,9 +70,15 @@ class QQuickView(emulators.UnityEmulatorBase):
69 objectName=indicator_name+'-panelItem'
70 objectName=indicator_name+'-panelItem'
70 )
71 )
71
72
73+ def _get_indicators_menu(self):
74+ return self.select_single(
75+ unity8.indicators.IndicatorsMenu,
76+ objectName='indicators'
77+ )
78+
72 def _get_indicator_page(self, indicator_name):
79 def _get_indicator_page(self, indicator_name):
73 return self.select_single(
80 return self.select_single(
74− IndicatorPage,
81+ 'IndicatorPage',
75 objectName=indicator_name+'-page'
82 objectName=indicator_name+'-page'
76 )
83 )
77
84
@@ -166,12 +173,6 @@ class QQuickView(emulators.UnityEmulatorBase):
166 objectName='pinPadButton{}'.format(button_id)
173 objectName='pinPadButton{}'.format(button_id)
167 )
174 )
168
175
169−
170−class IndicatorPage(emulators.UnityEmulatorBase):
171−
172− """Autopilot helper for the IndicatorPage component."""
173−
174−
175class QQuickFlickable(ubuntuuitoolkit.QQuickFlickable):
176class QQuickFlickable(ubuntuuitoolkit.QQuickFlickable):
176
177
177 def swipe_to_x_end(self):
178 def swipe_to_x_end(self):