on xenial help sign in
Added an autopilot helper to click a scope item.
c362029Leo Arias
tests/autopilot/unity8/shell/emulators/dash.py+16−6
@@ -24,7 +24,6 @@ from unity8.shell import emulators
24
24
25from autopilot import logging as autopilot_logging
25from autopilot import logging as autopilot_logging
26from autopilot.introspection import dbus
26from autopilot.introspection import dbus
27−from testtools.matchers import MatchesAny, Equals
28from ubuntuuitoolkit import emulators as toolkit_emulators
27from ubuntuuitoolkit import emulators as toolkit_emulators
29
28
30
29
@@ -146,7 +145,8 @@ class Dash(emulators.UnityEmulatorBase):
146 current_header.globalRect.y +
145 current_header.globalRect.y +
147 current_header.height / 4)
146 current_header.height / 4)
148 self.pointing_device.click()
147 self.pointing_device.click()
149− headerContainer = current_header.select_single(objectName="headerContainer")
148+ headerContainer = current_header.select_single(
149+ objectName="headerContainer")
150 headerContainer.contentY.wait_for(0)
150 headerContainer.contentY.wait_for(0)
151 search_text_field = self._get_search_text_field()
151 search_text_field = self._get_search_text_field()
152 search_text_field.write(query)
152 search_text_field.write(query)
@@ -177,22 +177,32 @@ class GenericScopeView(emulators.UnityEmulatorBase):
177 """Open the preview of an application.
177 """Open the preview of an application.
178
178
179 :parameter category: The name of the category where the application is.
179 :parameter category: The name of the category where the application is.
180− :app_name: The name of the application.
180+ :parameter app_name: The name of the application.
181 :return: The opened preview.
181 :return: The opened preview.
182
182
183 """
183 """
184− category_element = self._get_category_element(category)
185− icon = category_element.select_single('AbstractButton', title=app_name)
186 # FIXME some categories need a long press in order to see the preview.
184 # FIXME some categories need a long press in order to see the preview.
187 # Some categories do not show previews, like recent apps.
185 # Some categories do not show previews, like recent apps.
188 # --elopio - 2014-1-14
186 # --elopio - 2014-1-14
189− self.pointing_device.click_object(icon)
187+ self.click_scope_item(category, app_name)
190 preview_list = self.wait_select_single(
188 preview_list = self.wait_select_single(
191 'PreviewListView', objectName='previewListView')
189 'PreviewListView', objectName='previewListView')
192 preview_list.x.wait_for(0)
190 preview_list.x.wait_for(0)
193 return preview_list.select_single(
191 return preview_list.select_single(
194 Preview, objectName='preview{}'.format(preview_list.currentIndex))
192 Preview, objectName='preview{}'.format(preview_list.currentIndex))
195
193
194+ @autopilot_logging.log_action(logger.debug)
195+ def click_scope_item(self, category, title):
196+ """Click an item from the scope.
197+
198+ :parameter category: The name of the category where the item is.
199+ :parameter title: The title of the item.
200+
201+ """
202+ category_element = self._get_category_element(category)
203+ icon = category_element.select_single('AbstractButton', title=title)
204+ self.pointing_device.click_object(icon)
205+
196 def _get_category_element(self, category):
206 def _get_category_element(self, category):
197 try:
207 try:
198 return self.wait_select_single(
208 return self.wait_select_single(