on xenial help sign in
DashApps emulator get_applications should return a list ordered by visible y, x.
2f2698dAllan LeSage
tests/autopilot/unity8/shell/emulators/dash.py+6−3
@@ -192,14 +192,17 @@ class DashApps(GenericScopeView):
192 """
192 """
193 category_element = self._get_category_element(category)
193 category_element = self._get_category_element(category)
194 application_cards = category_element.select_many('Card')
194 application_cards = category_element.select_many('Card')
195− # TODO return them on the same order they are displayed.
195+
196− # --elopio - 2014-1-15
196+ # sort by y, x
197+ application_cards = sorted(
198+ application_cards,
199+ key=lambda card: (card.globalRect.y, card.globalRect.x))
200+
197 result = []
201 result = []
198 for card in application_cards:
202 for card in application_cards:
199 if card.objectName != 'cardToolCard':
203 if card.objectName != 'cardToolCard':
200 card_header = card.select_single('CardHeader')
204 card_header = card.select_single('CardHeader')
201 result.append(card_header.title)
205 result.append(card_header.title)
202−
203 return result
206 return result
204
207
205
208
tests/autopilot/unity8/shell/tests/test_emulators.py+3−7
@@ -166,7 +166,7 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
166 available_applications = [
166 available_applications = [
167 'Title.2.0', 'Title.2.1', 'Title.2.2', 'Title.2.3', 'Title.2.4',
167 'Title.2.0', 'Title.2.1', 'Title.2.2', 'Title.2.3', 'Title.2.4',
168 'Title.2.5', 'Title.2.6', 'Title.2.7', 'Title.2.8', 'Title.2.9',
168 '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']
170
170
171 def setUp(self):
171 def setUp(self):
172 # Set up the fake scopes before launching unity.
172 # Set up the fake scopes before launching unity.
@@ -183,17 +183,13 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
183 self.assertEqual(
183 self.assertEqual(
184 'No category found with name unexisting category', str(exception))
184 'No category found with name unexisting category', str(exception))
185
185
186− def test_get_applications_should_return_list_with_names(self):
186+ def test_get_applications_should_return_correct_applications(self):
187 category = '2'
187 category = '2'
188 expected_apps_count = self._get_number_of_application_slots(category)
188 expected_apps_count = self._get_number_of_application_slots(category)
189 expected_applications = self.available_applications[
189 expected_applications = self.available_applications[
190 :expected_apps_count]
190 :expected_apps_count]
191−
192 applications = self.applications_scope.get_applications(category)
191 applications = self.applications_scope.get_applications(category)
193−
194− self.assertThat(applications, HasLength(expected_apps_count))
195− for expected in expected_applications:
192+ self.assertEqual(expected_applications, applications)
196− self.assertThat(applications, Contains(expected))
197
193
198 def _get_number_of_application_slots(self, category):
194 def _get_number_of_application_slots(self, category):
199 category_element = self.applications_scope._get_category_element(
195 category_element = self.applications_scope._get_category_element(