on xenial help sign in
DashApps emulator get_applications should return a list ordered by visible y, x.
commit2f2698da40429a043c0bf44231ca94c15bb174ba authorAllan LeSage <allan.lesage@canonical.com> dateWed 16 Apr 2014, 13:43 (13 years ago) parent2395135ff6c939
2 files changed+9−10
tests/autopilot/unity8/shell/emulators/dash.py+6−3 tests/autopilot/unity8/shell/tests/test_emulators.py+3−7
tests/autopilot/unity8/shell/emulators/dash.py+6−3
@@ -192,14 +192,17 @@ class DashApps(GenericScopeView):
192192 """
193193 category_element = self._get_category_element(category)
194194 application_cards = category_element.select_many('Card')
195− # TODO return them on the same order they are displayed.
196− # --elopio - 2014-1-15
195+
196+ # sort by y, x
197+ application_cards = sorted(
198+ application_cards,
199+ key=lambda card: (card.globalRect.y, card.globalRect.x))
200+
197201 result = []
198202 for card in application_cards:
199203 if card.objectName != 'cardToolCard':
200204 card_header = card.select_single('CardHeader')
201205 result.append(card_header.title)
202−
203206 return result
204207
205208
tests/autopilot/unity8/shell/tests/test_emulators.py+3−7
@@ -166,7 +166,7 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
166166 available_applications = [
167167 'Title.2.0', 'Title.2.1', 'Title.2.2', 'Title.2.3', 'Title.2.4',
168168 'Title.2.5', 'Title.2.6', 'Title.2.7', 'Title.2.8', 'Title.2.9',
169− 'Title.2.9', 'Title.2.10', 'Title.2.11']
169+ 'Title.2.10', 'Title.2.11', 'Title.2.12']
170170
171171 def setUp(self):
172172 # Set up the fake scopes before launching unity.
@@ -183,17 +183,13 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
183183 self.assertEqual(
184184 'No category found with name unexisting category', str(exception))
185185
186− def test_get_applications_should_return_list_with_names(self):
186+ def test_get_applications_should_return_correct_applications(self):
187187 category = '2'
188188 expected_apps_count = self._get_number_of_application_slots(category)
189189 expected_applications = self.available_applications[
190190 :expected_apps_count]
191−
192191 applications = self.applications_scope.get_applications(category)
193−
194− self.assertThat(applications, HasLength(expected_apps_count))
195− for expected in expected_applications:
196− self.assertThat(applications, Contains(expected))
192+ self.assertEqual(expected_applications, applications)
197193
198194 def _get_number_of_application_slots(self, category):
199195 category_element = self.applications_scope._get_category_element(