@@ -137,32 +137,23 @@ class Dash(emulators.UnityEmulatorBase):
137 self.dash_content_list.currentIndex.wait_for(original_index + 1)
137 self.dash_content_list.currentIndex.wait_for(original_index + 1)
140−class GenericScopeView(emulators.UnityEmulatorBase):
140+class DashPreview(emulators.UnityEmulatorBase):
141− """Autopilot emulator for generic scopes."""
141+ """Autopilot emulator for the generic preview."""
143+ def get_details(self):
144+ """Return the details of the open preview."""
145+ title = self.select_single('Label', objectName='titleLabel').text
146+ subtitle = self.select_single(
147+ 'Label', objectName='subtitleLabel').text
148+ description = self.select_single(
149+ 'Label', objectName='descriptionLabel').text
150+ return dict(title=title, subtitle=subtitle, description=description)
144−class DashApps(emulators.UnityEmulatorBase):
145− """Autopilot emulator for the applications scope."""
147− def get_applications(self, category):
148− """Return the list of applications on a category.
150− :parameter category: The name of the category.
152− """
153+class GenericScopeView(emulators.UnityEmulatorBase):
153− category_element = self._get_category_element(category)
154+ """Autopilot emulator for generic scopes."""
154− application_tiles = category_element.select_many('Tile')
155− # TODO return them on the same order they are displayed.
156− # --elopio - 2014-1-15
157− return [tile.text for tile in application_tiles]
159− def _get_category_element(self, category):
156+ preview_class = DashPreview
161− return self.wait_select_single(
162− 'Base', objectName='dashCategory{}'.format(category))
163− except dbus.StateNotFoundError:
164− raise emulators.UnityEmulatorException(
165− 'No category found with name {}'.format(category))
167 @autopilot_logging.log_action(logger.info)
158 @autopilot_logging.log_action(logger.info)
168 def open_preview(self, category, app_name):
159 def open_preview(self, category, app_name):
@@ -178,19 +169,46 @@ class DashApps(emulators.UnityEmulatorBase):
178 # Some categories do not show previews, like recent apps.
169 # Some categories do not show previews, like recent apps.
179 # --elopio - 2014-1-14
170 # --elopio - 2014-1-14
180 self.pointing_device.click_object(icon)
171 self.pointing_device.click_object(icon)
181− return self.get_root_instance().wait_select_single(AppPreview)
172+ preview = self.get_root_instance().wait_select_single(
173+ self.preview_class, isCurrent=True)
174+ preview.showProcessingAction.wait_for(False)
177+ def _get_category_element(self, category):
179+ return self.wait_select_single(
180+ 'Base', objectName='dashCategory{}'.format(category))
181+ except dbus.StateNotFoundError:
182+ raise emulators.UnityEmulatorException(
183+ 'No category found with name {}'.format(category))
184−class AppPreview(emulators.UnityEmulatorBase):
186+class AppPreview(DashPreview):
185 """Autopilot emulator for the application preview."""
187 """Autopilot emulator for the application preview."""
187 def get_details(self):
189 def get_details(self):
188 """Return the details of the application showed in its preview."""
190 """Return the details of the application showed in its preview."""
189− title = self.select_single('Label', objectName='titleLabel').text
191+ details = super(AppPreview, self).get_details()
190− publisher = self.select_single(
191− 'Label', objectName='subtitleLabel').text
192− description = self.select_single(
193− 'Label', objectName='descriptionLabel').text
194 # TODO return screenshots, icon, rating and reviews.
192 # TODO return screenshots, icon, rating and reviews.
195 # --elopio - 2014-1-15
193 # --elopio - 2014-1-15
195+ title=details.get('title'), publisher=details.get('subtitle'),
196− return dict(title=title, publisher=publisher, description=description)
196+ description=details.get('description'))
199+class DashApps(GenericScopeView):
200+ """Autopilot emulator for the applications scope."""
202+ preview_class = AppPreview
204+ def get_applications(self, category):
205+ """Return the list of applications on a category.
207+ :parameter category: The name of the category.
210+ category_element = self._get_category_element(category)
211+ application_tiles = category_element.select_many('Tile')
212+ # TODO return them on the same order they are displayed.
213+ # --elopio - 2014-1-15
214+ return [tile.text for tile in application_tiles]