on xenial help sign in
Reorganized the custom proxy objects.
commitb25e178edd6b9eb2ce196065b47bce78f4da05e7 authorLeo Arias <leo.arias@canonical.com> dateTue 13 Jan 2015, 11:54 (12 years ago) parentfce4168
3 files changed+78−76
tests/autopilot/unity8/indicators/__init__.py+73−46 tests/autopilot/unity8/indicators/tests/test_indicators.py+5−6 tests/autopilot/unity8/shell/emulators/main_window.py−24
tests/autopilot/unity8/indicators/__init__.py+73−46
@@ -12,70 +12,97 @@
1212# but WITHOUT ANY WARRANTY; without even the implied warranty of
1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414# GNU General Public License for more details.
15−#
1615# You should have received a copy of the GNU General Public License
1716# along with this program. If not, see <http://www.gnu.org/licenses/>.
1817
19−from autopilot import input
20−from unity8.shell import emulators
21−from unity8.shell.emulators import main_window
2218import ubuntuuitoolkit
19+from autopilot import introspection
2320
21+from unity8.shell import emulators
2422
25−class IndicatorsMenu(emulators.UnityEmulatorBase):
23+
24+class IndicatorPage(emulators.UnityEmulatorBase):
2625
2726 """Autopilot helper for the IndicatorPage component."""
2827
29− def open(self):
30− widget = self.select_single(
31− 'IndicatorItem', objectName='indicator-sound-panelItem')
32− start_x, start_y = input.get_center_point(widget)
33− end_x = start_x
34− end_y = self.globalRect.y + self.openedHeight
35− self.pointing_device.drag(start_x, start_y, end_x, end_y)
36− self.fullyOpened.wait_for(True)
37−
38− def open_rotation_indicator(self):
39− self.open()
40− indicators_bar_flickable = self.select_single(
41− 'IndicatorsBar').select_single(
42− main_window.QQuickFlickable, objectName='flickable')
43− indicators_bar_flickable.swipe_to_x_end()
44− indicator_rotation_icon = self.select_single(
45− objectName='indicator-rotation-lock-panelItem')
46− self.pointing_device.click_object(indicator_rotation_icon)
47− self.fullyOpened.wait_for(True)
48− return DisplayIndicator(
49− self.select_single(
50− 'IndicatorPage', objectName='indicator-rotation-lock-page'))
28+ # XXX Because of https://bugs.launchpad.net/autopilot-qt/+bug/1341671
29+ # we need to make sure it does not match in any selection.
5130
31+ @classmethod
32+ def validate_dbus_object(cls, path, state):
33+ return False
5234
53−class DisplayIndicator(emulators.UnityEmulatorBase):
5435
55− def __init__(self, subject):
56− self.__subject = subject
36+class DisplayIndicator(object):
5737
58− def __getattr__(self, name):
59− return getattr(self.__subject, name)
38+ def __init__(self, main_window):
39+ self._main_window = main_window
6040
61− def lock_rotation(self):
62− """Toggles the rotation lock indicator to locked.
41+ def open(self):
42+ """Open the display indicator page.
6343
64− Swipes open indicator-display and ensures that rotation lock is toggled
65− to 'On'.
44+ :return: The custom proxy object for the display indicator page.
6645
6746 """
68− switcher = self.select_single(
69− ubuntuuitoolkit.CheckBox, objectName='switcher')
70− switcher.check()
71−
72− def unlock_rotation(self):
73− """Toggles the rotation lock indicator to unlocked.
47+ # TODO open the indicator directly if it is displayed in the menu.
48+ # open any displayed indicator.
49+ self._main_window.open_indicator_page('indicator-datetime')
50+ self._make_indicator_icon_visible()
51+ indicator_rotation_icon = self._main_window.select_single(
52+ objectName='indicator-rotation-lock-panelItem')
53+ self._main_window.pointing_device.click_object(indicator_rotation_icon)
54+ indicators_menu = self._main_window.select_single('IndicatorsMenu')
55+ indicators_menu.fullyOpened.wait_for(True)
56+ return self._main_window.select_single(
57+ objectName='indicator-rotation-lock-page')
58+
59+ def _make_indicator_icon_visible(self):
60+ indicators_bar_flickable = self._main_window.select_single(
61+ 'IndicatorsBar').select_single(
62+ ubuntuuitoolkit.QQuickFlickable, objectName='flickable')
63+ self._swipe_flickable_to_x_end(indicators_bar_flickable)
64+
65+ def _swipe_flickable_to_x_end(self, flickable):
66+ # XXX this should be implemented as a general horizontal swiping in
67+ # the toolkit custom proxy object.
68+ if not flickable.atXEnd:
69+ while not flickable.atXEnd:
70+ start_y = stop_y = (
71+ flickable.globalRect.y +
72+ (flickable.globalRect.height // 2))
73+ # We can't start the swipe from the border because it would
74+ # open the launcher
75+ start_x = flickable.globalRect.x + 45
76+ stop_x = (
77+ flickable.globalRect.x + flickable.globalRect.width - 5)
78+ flickable.pointing_device.drag(
79+ start_x, start_y, stop_x, stop_y)
80+ flickable.dragging.wait_for(False)
81+ flickable.moving.wait_for(False)
82+
83+
84+class DisplayIndicatorPage(IndicatorPage):
85+
86+ """Autopilot helper for the display indicator page."""
87+
88+ @classmethod
89+ def validate_dbus_object(cls, path, state):
90+ name = introspection.get_classname_from_path(path)
91+ if name == b'IndicatorPage':
92+ if state['objectName'][1] == 'indicator-rotation-lock-page':
93+ return True
94+ return False
7495
75− Swipes open indicator-display and ensures that rotation lock is toggled
76− to 'Off'.
96+ def lock_rotation(self):
97+ """Toggles the rotation lock indicator to locked."""
98+ switcher = self._get_switcher()
99+ switcher.check()
77100
78− """
79− switcher = self.select_single(
101+ def _get_switcher(self):
102+ return self.select_single(
80103 ubuntuuitoolkit.CheckBox, objectName='switcher')
104+
105+ def unlock_rotation(self):
106+ """Toggles the rotation lock indicator to unlocked."""
107+ switcher = self._get_switcher()
81108 switcher.uncheck()
tests/autopilot/unity8/indicators/tests/test_indicators.py+5−6
@@ -22,8 +22,8 @@ from testscenarios import multiply_scenarios
2222
2323from autopilot import platform
2424
25+from unity8 import indicators
2526from unity8.process_helpers import unlock_unity
26−from unity8.shell.emulators import main_window
2727from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2828
2929
@@ -109,8 +109,7 @@ class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
109109class DisplayIndicatorTestCase(IndicatorTestCase):
110110
111111 def test(self):
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()
112+ display_indicator = indicators.DisplayIndicator(self.main_window)
113+ display_indicator_page = display_indicator.open()
114+ display_indicator_page.unlock_rotation()
115+ display_indicator_page.lock_rotation()
tests/autopilot/unity8/shell/emulators/main_window.py−24
@@ -70,12 +70,6 @@ class QQuickView(emulators.UnityEmulatorBase):
7070 objectName=indicator_name+'-panelItem'
7171 )
7272
73− def _get_indicators_menu(self):
74− return self.select_single(
75− unity8.indicators.IndicatorsMenu,
76− objectName='indicators'
77− )
78−
7973 def _get_indicator_page(self, indicator_name):
8074 return self.select_single(
8175 'IndicatorPage',
@@ -172,21 +166,3 @@ class QQuickView(emulators.UnityEmulatorBase):
172166 'PinPadButton',
173167 objectName='pinPadButton{}'.format(button_id)
174168 )
175−
176−class QQuickFlickable(ubuntuuitoolkit.QQuickFlickable):
177−
178− def swipe_to_x_end(self):
179− if not self.atXEnd:
180− containers = self._get_containers()
181− while not self.atXEnd:
182− self.swipe_to_show_x_end(containers)
183−
184− def swipe_to_show_x_end(self, containers):
185− start_y = stop_y = self.globalRect.y + (self.globalRect.height // 2)
186− # We can't start the swipe from the border because it would open the
187− # launcher
188− start_x = self.globalRect.x + 45
189− stop_x = self.globalRect.x + self.globalRect.width - 5
190− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
191− self.dragging.wait_for(False)
192− self.moving.wait_for(False)