19from autopilot
import introspection
22class IndicatorPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase):
24 """Autopilot helper for the IndicatorPage component."""
31 def validate_dbus_object(cls, path, state):
37 def __init__(self, main_window, name):
38 self._main_window = main_window
41 def is_indicator_icon_visible(self):
42 panel_item = self._main_window.wait_select_single(
43 objectName=self._name+
'-panelItem')
44 return panel_item.indicatorVisible
47 """Open the indicator page.
49 :return: The custom proxy object for the indicator page.
52 if self.is_indicator_icon_visible():
53 return self._main_window.open_indicator_page(self._name)
55 return self._open_indicator_with_icon_not_visible()
57 def _open_indicator_with_icon_not_visible(self):
59 self._main_window.open_indicator_page(
'indicator-datetime')
60 self._make_indicator_icon_visible()
61 indicator_rotation_icon = self._main_window.select_single(
62 objectName=self._name+
'-panelItem')
63 self._main_window.pointing_device.click_object(indicator_rotation_icon)
64 return self._main_window.wait_select_single(
65 objectName=self._name+
'-page')
67 def _make_indicator_icon_visible(self):
68 indicators_bar = self._main_window.select_single(
'IndicatorsBar')
69 indicators_bar_flickable = indicators_bar.select_single(
70 lomiriuitoolkit.QQuickFlickable, objectName=
'flickable')
71 self._swipe_flickable_to_x_end(indicators_bar_flickable)
73 def _swipe_flickable_to_x_end(self, flickable):
76 if not flickable.atXEnd:
77 flickable.interactive.wait_for(
True)
78 while not flickable.atXEnd:
80 flickable.globalRect.y +
81 (flickable.globalRect.height // 2))
84 start_x = flickable.globalRect.x + 45
86 flickable.globalRect.x + flickable.globalRect.width - 5)
87 flickable.pointing_device.drag(
88 start_x, start_y, stop_x, stop_y)
89 flickable.dragging.wait_for(
False)
90 flickable.moving.wait_for(
False)
93 """Close the indicator page."""
94 self._main_window.close_indicator_page()
97class DisplayIndicator(Indicator):
99 def __init__(self, main_window):
100 super(DisplayIndicator, self).__init__(main_window,
101 'indicator-rotation-lock')
102 self._main_window = main_window
107 """Autopilot helper for the display indicator page."""
110 def validate_dbus_object(cls, path, state):
111 name = introspection.get_classname_from_path(path)
112 if name == b
'IndicatorPage':
113 if state[
'objectName'][1] ==
'indicator-rotation-lock-page':
118 """Toggle the rotation lock indicator to locked."""
121 switcher.checked.wait_for(
True)
123 def _get_switcher(self):
124 return self.select_single(
125 lomiriuitoolkit.CheckBox, objectName=
'switcher')
128 """Toggle the rotation lock indicator to unlocked."""
131 switcher.checked.wait_for(
False)
134class TestIndicator(Indicator):
136 def __init__(self, main_window):
137 super(TestIndicator, self).__init__(main_window,
'indicator-mock')
138 self._main_window = main_window
143 """Autopilot helper for the mock indicator page."""
146 def validate_dbus_object(cls, path, state):
147 name = introspection.get_classname_from_path(path)
148 if name == b
'IndicatorPage':
149 if state[
'objectName'][1] ==
'indicator-mock-page':
153 def get_switcher(self):
154 return self.select_single(
155 lomiriuitoolkit.CheckBox, objectName=
'switcher')
157 def get_switch_menu(self):
158 return self.select_single(
159 'SwitchMenu', objectName=
'indicator.action.switch')
161 def get_slider(self):
162 return self.select_single(objectName=
'slider')
164 def get_slider_menu(self):
165 return self.select_single(objectName=
'indicator.action.slider')
168class Slider(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase):
170 """Autopilot helper for the Slider component."""
177 def validate_dbus_object(cls, path, state):
178 name = introspection.get_classname_from_path(path)
179 if name == b
'Slider':
183 def slide_left(self, timeout=10):
184 x, y, width, height = self.globalRect
187 start_x = x + width/2
188 start_y = stop_y = y + height/2
191 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)
194 def slide_right(self, timeout=10):
195 x, y, width, height = self.globalRect
198 start_x = x + width/2
199 start_y = stop_y = y + height/2
202 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)