on xenial help sign in
Fix unity8.shell.tests.test_emulators.DashAppsEmulatorTestCase.test_get_applications_should_return_list_with_names
commit71582d762dded8630b4f95bd8821f10ea260101f authorAlbert Astals <albert.astals@canonical.com> dateMon 10 Mar 2014, 12:47 (13 years ago) parent0dec0b3
5 files changed+21−12
qml/Dash/CardTool.qml+1−1 tests/autopilot/unity8/shell/emulators/dash.py+6−2 tests/autopilot/unity8/shell/tests/test_emulators.py+10−6 tests/mocks/Unity/fake_resultsmodel.cpp+3−2 tests/qmltests/Dash/tst_CardTool.qml+1−1
qml/Dash/CardTool.qml+1−1
@@ -130,7 +130,7 @@ Item {
130130
131131 Card {
132132 id: card
133− objectName: "card"
133+ objectName: "cardToolCard"
134134 template: cardTool.template
135135 components: cardTool.components
136136
tests/autopilot/unity8/shell/emulators/dash.py+6−2
@@ -207,7 +207,11 @@ class DashApps(GenericScopeView):
207207
208208 """
209209 category_element = self._get_category_element(category)
210− application_tiles = category_element.select_many('Tile')
210+ application_tiles = category_element.select_many('Card')
211211 # TODO return them on the same order they are displayed.
212212 # --elopio - 2014-1-15
213− return [tile.text for tile in application_tiles]
213+ result = []
214+ for card in application_tiles:
215+ if card.objectName != 'cardToolCard':
216+ result.append(card)
217+ return result
tests/autopilot/unity8/shell/tests/test_emulators.py+10−6
@@ -158,9 +158,9 @@ class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
158158class DashAppsEmulatorTestCase(DashBaseTestCase):
159159
160160 available_applications = [
161− 'Title.1', 'Title.21', 'Title.41', 'Title.61', 'Title.81',
162− 'Title.101', 'Title.121', 'Title.141', 'Title.161', 'Title.181',
163− 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']
161+ 'Title.2.0', 'Title.2.1', 'Title.2.2', 'Title.2.3', 'Title.2.4',
162+ 'Title.2.5', 'Title.2.6', 'Title.2.7', 'Title.2.8', 'Title.2.9',
163+ 'Title.2.9', 'Title.2.10', 'Title.2.11']
164164
165165 def setUp(self):
166166 # Set up the fake scopes before launching unity.
@@ -178,21 +178,25 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
178178 'No category found with name unexisting category', str(exception))
179179
180180 def test_get_applications_should_return_list_with_names(self):
181− category = 'installed'
181+ category = '2'
182182 expected_apps_count = self._get_number_of_application_slots(category)
183183 expected_applications = self.available_applications[
184184 :expected_apps_count]
185185
186186 applications = self.applications_scope.get_applications(category)
187+ applications_titles = []
188+ for application in applications:
189+ cardHeader = application.select_single('CardHeader')
190+ applications_titles.append(cardHeader.title)
187191
188192 self.assertThat(applications, HasLength(expected_apps_count))
189193 for expected in expected_applications:
190− self.assertThat(applications, Contains(expected))
194+ self.assertThat(applications_titles, Contains(expected))
191195
192196 def _get_number_of_application_slots(self, category):
193197 category_element = self.applications_scope._get_category_element(
194198 category)
195− grid = category_element.select_single('GenericFilterGrid')
199+ grid = category_element.select_single('DashFilterGrid')
196200 return grid.columns * grid.rows
197201
198202 def test_open_preview(self):
tests/mocks/Unity/fake_resultsmodel.cpp+3−2
@@ -90,15 +90,16 @@ QVariant ResultsModel::get(int row) const
9090}
9191
9292QVariant
93−ResultsModel::data(const QModelIndex& /*index*/, int role) const
93+ResultsModel::data(const QModelIndex& index, int role) const
9494{
9595 switch (role) {
9696 case RoleUri:
9797 case RoleCategoryId:
9898 case RoleDndUri:
9999 case RoleResult:
100− case RoleTitle:
101100 return QString();
101+ case RoleTitle:
102+ return QString("Title.%1.%2").arg(m_categoryId).arg(index.row());
102103 case RoleArt:
103104 return qmlDirectory() + "graphics/applicationIcons/dash.png";
104105 case RoleSubtitle:
tests/qmltests/Dash/tst_CardTool.qml+1−1
@@ -256,7 +256,7 @@ Rectangle {
256256 id: testCase
257257 name: "Card"
258258
259− property Card internalCard: findChild(cardTool, "card")
259+ property Card internalCard: findChild(cardTool, "cardToolCard")
260260
261261 when: windowShown
262262