on xenial help sign in
Visible ordering for dash_apps.
commit83742ab8713aa3e91f9635696de9073e42d156c0 authorAllan LeSage <allan.lesage@canonical.com> dateWed 26 Mar 2014, 10:09 (13 years ago) parent05d4a33
2 files changed+21−4
tests/autopilot/unity8/shell/emulators/dash.py+8−4 tests/autopilot/unity8/shell/tests/test_emulators.py+13
tests/autopilot/unity8/shell/emulators/dash.py+8−4
@@ -159,7 +159,7 @@ class GenericScopeView(emulators.UnityEmulatorBase):
159159 def _get_category_element(self, category):
160160 try:
161161 return self.wait_select_single(
162− 'Base', objectName='dashCategory{}'.format(category))
162+ 'Base', objectName='dashSectionHeader{}'.format(category))
163163 except dbus.StateNotFoundError:
164164 raise emulators.UnityEmulatorException(
165165 'No category found with name {}'.format(category))
@@ -176,10 +176,14 @@ class DashApps(GenericScopeView):
176176 """
177177 category_element = self._get_category_element(category)
178178 application_tiles = category_element.select_many('Card')
179− # TODO return them on the same order they are displayed.
180− # --elopio - 2014-1-15
181179 result = []
182180 for card in application_tiles:
183181 if card.objectName != 'cardToolCard':
184182 result.append(card)
185− return result
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+
189+ return sorted(result, key=visible_order)
tests/autopilot/unity8/shell/tests/test_emulators.py+13
@@ -32,6 +32,8 @@ try:
3232except ImportError:
3333 import mock
3434
35+from time import sleep
36+
3537from testtools.matchers import Contains, HasLength
3638
3739from unity8 import process_helpers
@@ -181,6 +183,17 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
181183 for expected in expected_applications:
182184 self.assertThat(applications_titles, Contains(expected))
183185
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+
184197 def _get_number_of_application_slots(self, category):
185198 category_element = self.applications_scope._get_category_element(
186199 category)