on xenial help sign in
Visible ordering for dash_apps.
83742abAllan LeSage
tests/autopilot/unity8/shell/emulators/dash.py+8−4
@@ -159,7 +159,7 @@ class GenericScopeView(emulators.UnityEmulatorBase):
159 def _get_category_element(self, category):
159 def _get_category_element(self, category):
160 try:
160 try:
161 return self.wait_select_single(
161 return self.wait_select_single(
162− 'Base', objectName='dashCategory{}'.format(category))
162+ 'Base', objectName='dashSectionHeader{}'.format(category))
163 except dbus.StateNotFoundError:
163 except dbus.StateNotFoundError:
164 raise emulators.UnityEmulatorException(
164 raise emulators.UnityEmulatorException(
165 'No category found with name {}'.format(category))
165 'No category found with name {}'.format(category))
@@ -176,10 +176,14 @@ class DashApps(GenericScopeView):
176 """
176 """
177 category_element = self._get_category_element(category)
177 category_element = self._get_category_element(category)
178 application_tiles = category_element.select_many('Card')
178 application_tiles = category_element.select_many('Card')
179− # TODO return them on the same order they are displayed.
180− # --elopio - 2014-1-15
181 result = []
179 result = []
182 for card in application_tiles:
180 for card in application_tiles:
183 if card.objectName != 'cardToolCard':
181 if card.objectName != 'cardToolCard':
184 result.append(card)
182 result.append(card)
183+
184+ def visible_order(card):
185+ """Enable sorting of cards by vertical, horizontal."""
186+ # NOTE that we limit testable resolution to 10K
187+ return card.globalRect[1] * 10000 + card.globalRect[0]
188+
185− return result
189+ return sorted(result, key=visible_order)
tests/autopilot/unity8/shell/tests/test_emulators.py+13
@@ -32,6 +32,8 @@ try:
32except ImportError:
32except ImportError:
33 import mock
33 import mock
34
34
35+from time import sleep
36+
35from testtools.matchers import Contains, HasLength
37from testtools.matchers import Contains, HasLength
36
38
37from unity8 import process_helpers
39from unity8 import process_helpers
@@ -181,6 +183,17 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
181 for expected in expected_applications:
183 for expected in expected_applications:
182 self.assertThat(applications_titles, Contains(expected))
184 self.assertThat(applications_titles, Contains(expected))
183
185
186+ def test_get_applications_list_matches_visible_ordering(self):
187+ category = '2'
188+ expected_apps_count = self._get_number_of_application_slots(category)
189+ expected_application_titles = self.available_applications[
190+ :expected_apps_count]
191+ applications = self.applications_scope.get_applications(category)
192+ for card_num in range(len(applications)):
193+ card_header = applications[card_num].select_single('CardHeader')
194+ self.assertEqual(expected_application_titles[card_num],
195+ card_header.title)
196+
184 def _get_number_of_application_slots(self, category):
197 def _get_number_of_application_slots(self, category):
185 category_element = self.applications_scope._get_category_element(
198 category_element = self.applications_scope._get_category_element(
186 category)
199 category)