Merge lp:~elopio/ubuntu-filemanager-app/clean_places_tests into lp:ubuntu-filemanager-app

Proposed by Leo Arias
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 200
Merged at revision: 200
Proposed branch: lp:~elopio/ubuntu-filemanager-app/clean_places_tests
Merge into: lp:ubuntu-filemanager-app
Diff against target: 423 lines (+149/-83)
7 files modified
src/app/qml/components/PlacesSidebar.qml (+4/-1)
src/app/qml/ui/PlacesPopover.qml (+4/-1)
tests/autopilot/filemanager/_common.py (+21/-0)
tests/autopilot/filemanager/emulators.py (+54/-22)
tests/autopilot/filemanager/tests/__init__.py (+22/-9)
tests/autopilot/filemanager/tests/test_filemanager.py (+2/-50)
tests/autopilot/filemanager/tests/test_places.py (+42/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-filemanager-app/clean_places_tests
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Michael Spencer Pending
Carlos Jose Mazieri Pending
Brendan Donegan Pending
Review via email: mp+222583@code.launchpad.net

Commit message

Cleaned up the places autopilot tests.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Ahh, so you moved the places test to it's own file.. hmm..

Do you plan to break out test_filemanager even more?

Revision history for this message
Leo Arias (elopio) wrote :

yes I do. If I have time to do it.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

17:31:51.289 ERROR testresult:46 - traceback: {{{
Traceback (most recent call last):
File "/home/phablet/autopilot/filemanager/tests/test_places.py", line 37, in test_go_to_root_must_open_the_root_directory
self.main_view.go_to_place('placeRoot')
File "/usr/lib/python3/dist-packages/autopilot/introspection/dbus.py", line 420, in __getattr__
(self.__class__.__name__, name))
AttributeError: Class 'MainView' has no attribute 'go_to_place'.
}}}

http://paste.ubuntu.com/7624597/

review: Needs Fixing
200. By Leo Arias

Fixed tests on mako.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

The current test errors still exist, but this introduces no new errors and cleans the tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/components/PlacesSidebar.qml'
2--- src/app/qml/components/PlacesSidebar.qml 2014-03-29 09:20:11 +0000
3+++ src/app/qml/components/PlacesSidebar.qml 2014-06-10 18:01:55 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013 Canonical Ltd
7+ * Copyright (C) 2013, 2014 Canonical Ltd
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 3 as
11@@ -46,6 +46,7 @@
12 id: places
13
14 ListElement {
15+ objectName: "placeHome"
16 path: "~"
17 }
18
19@@ -70,6 +71,7 @@
20 }
21
22 ListElement {
23+ objectName: "placeRoot"
24 path: "/"
25 }
26 }
27@@ -92,6 +94,7 @@
28 model: places
29
30 delegate: Standard {
31+ objectName: model.objectName
32 text: folderName(path)
33
34 Image {
35
36=== modified file 'src/app/qml/ui/PlacesPopover.qml'
37--- src/app/qml/ui/PlacesPopover.qml 2014-02-19 00:00:15 +0000
38+++ src/app/qml/ui/PlacesPopover.qml 2014-06-10 18:01:55 +0000
39@@ -1,5 +1,5 @@
40 /*
41- * Copyright (C) 2013 Canonical Ltd
42+ * Copyright (C) 2013, 2014 Canonical Ltd
43 *
44 * This program is free software: you can redistribute it and/or modify
45 * it under the terms of the GNU General Public License version 3 as
46@@ -28,6 +28,7 @@
47 id: places
48
49 ListElement {
50+ objectName: 'placeHome'
51 path: "~"
52 }
53
54@@ -52,6 +53,7 @@
55 }
56
57 ListElement {
58+ objectName: "placeRoot"
59 path: "/"
60 }
61 }
62@@ -114,6 +116,7 @@
63 model: places
64
65 delegate: Standard {
66+ objectName: model.objectName
67 property string name: folderName(path)
68
69 Label {
70
71=== added file 'tests/autopilot/filemanager/_common.py'
72--- tests/autopilot/filemanager/_common.py 1970-01-01 00:00:00 +0000
73+++ tests/autopilot/filemanager/_common.py 2014-06-10 18:01:55 +0000
74@@ -0,0 +1,21 @@
75+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
76+#
77+# Copyright (C) 2014 Canonical Ltd.
78+#
79+# This program is free software; you can redistribute it and/or modify
80+# it under the terms of the GNU Lesser General Public License as published by
81+# the Free Software Foundation; version 3.
82+#
83+# This program is distributed in the hope that it will be useful,
84+# but WITHOUT ANY WARRANTY; without even the implied warranty of
85+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86+# GNU Lesser General Public License for more details.
87+#
88+# You should have received a copy of the GNU Lesser General Public License
89+# along with this program. If not, see <http://www.gnu.org/licenses/>.
90+
91+from ubuntuuitoolkit import emulators as toolkit_emulators
92+
93+
94+class FileManagerException(toolkit_emulators.ToolkitEmulatorException):
95+ """Exception raised when there is an error with the File Manager."""
96
97=== modified file 'tests/autopilot/filemanager/emulators.py'
98--- tests/autopilot/filemanager/emulators.py 2014-05-08 23:04:17 +0000
99+++ tests/autopilot/filemanager/emulators.py 2014-06-10 18:01:55 +0000
100@@ -1,6 +1,6 @@
101 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
102 #
103-# Copyright (C) 2013 Canonical Ltd.
104+# Copyright (C) 2013, 2014 Canonical Ltd.
105 #
106 # This program is free software; you can redistribute it and/or modify
107 # it under the terms of the GNU Lesser General Public License as published by
108@@ -16,18 +16,60 @@
109
110 """File Manager app autopilot emulators."""
111
112+import logging
113 import re
114 import time
115
116+import autopilot.logging
117 from autopilot import input
118 from autopilot.introspection import dbus
119-
120 from ubuntuuitoolkit import emulators as toolkit_emulators
121
122+from filemanager import _common
123+
124+logger = logging.getLogger(__name__)
125+
126
127 class MainView(toolkit_emulators.MainView):
128 """File Manager MainView Autopilot emulator."""
129
130+ @autopilot.logging.log_action(logger.info)
131+ def go_to_place(self, object_name):
132+ """Open one of the bookmarked place folders.
133+
134+ :param object_name: The objectName property of the place to open.
135+
136+ """
137+ if self.showSidebar:
138+ self._go_to_place_from_side_bar(object_name)
139+ else:
140+ self._go_to_place_from_popover(object_name)
141+
142+ def _go_to_place_from_side_bar(self, object_name):
143+ side_bar = self.get_folder_list_page().get_sidebar()
144+ side_bar.go_to_place(object_name)
145+
146+ def _go_to_place_from_popover(self, object_name):
147+ popover = self.open_places()
148+ place = popover.select_single('Standard', objectName=object_name)
149+ self.pointing_device.click_object(place)
150+
151+ @autopilot.logging.log_action(logger.info)
152+ def open_places(self):
153+ if not self.showSidebar:
154+ self.open_toolbar().click_button('places')
155+ return self._get_places_popover()
156+ else:
157+ raise _common('The places popover cannot be opened on wide mode.')
158+
159+ def _get_places_popover(self):
160+ """Return the Places popover."""
161+ # XXX It would be easier if the places popover was an object
162+ # that inherits from Popover, like the
163+ # ActionSelectionPopover does.
164+ # --elopio - 2013-07-25
165+ return self.wait_select_single('Popover', objectName='placesPopover')
166+
167 def get_folder_list_page(self):
168 """Return the FolderListPage emulator of the MainView."""
169 page = self.wait_select_single(FolderListPage)
170@@ -60,19 +102,6 @@
171 except:
172 return False
173
174- def get_places_popover(self):
175- """Return the Places popover."""
176- if not self.showSidebar:
177- # XXX It would be easier if the places popover was an object
178- # that inherits from Popover, like the
179- # ActionSelectionPopover does.
180- # --elopio - 2013-07-25
181- return self.wait_select_single('Popover',
182- objectName='placesPopover')
183- else:
184- raise ValueError(
185- 'Places sidebar is hidden in wide mode.')
186-
187 def get_file_details_popover(self):
188 """Return the FileDetailsPopover emulator."""
189 return self.wait_select_single(FileDetailsPopover)
190@@ -117,13 +146,15 @@
191 class PlacesSidebar(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
192 """PlacesSidebar Autopilot emulator."""
193
194- def get_place(self, text):
195- places = self.select_many('Standard')
196- for place in places:
197- if place.text == text:
198- return place
199- raise ValueError(
200- 'Place "{0}" not found.'.format(text))
201+ @autopilot.logging.log_action(logger.info)
202+ def go_to_place(self, object_name):
203+ """Open one of the bookmarked place folders.
204+
205+ :param object_name: The objectName property of the place to open.
206+
207+ """
208+ place = self.select_single('Standard', objectName=object_name)
209+ self.pointing_device.click_object(place)
210
211
212 class FolderListPage(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
213@@ -169,6 +200,7 @@
214 'File with name "{0}" not found.'.format(name))
215
216 def get_current_path(self):
217+ """Get the path of the folder currently displayed."""
218 if self.showingListView:
219 return self.select_single(FolderListView).get_current_path()
220 else:
221
222=== modified file 'tests/autopilot/filemanager/tests/__init__.py'
223--- tests/autopilot/filemanager/tests/__init__.py 2014-05-08 22:18:56 +0000
224+++ tests/autopilot/filemanager/tests/__init__.py 2014-06-10 18:01:55 +0000
225@@ -1,9 +1,18 @@
226 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
227-# Copyright 2013 Canonical
228-#
229-# This program is free software: you can redistribute it and/or modify it
230-# under the terms of the GNU General Public License version 3, as published
231-# by the Free Software Foundation.
232+#
233+# Copyright (C) 2013, 2014 Canonical Ltd.
234+#
235+# This program is free software; you can redistribute it and/or modify
236+# it under the terms of the GNU Lesser General Public License as published by
237+# the Free Software Foundation; version 3.
238+#
239+# This program is distributed in the hope that it will be useful,
240+# but WITHOUT ANY WARRANTY; without even the implied warranty of
241+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
242+# GNU Lesser General Public License for more details.
243+#
244+# You should have received a copy of the GNU Lesser General Public License
245+# along with this program. If not, see <http://www.gnu.org/licenses/>.
246
247 """Filemanager app autopilot tests."""
248
249@@ -12,18 +21,19 @@
250 import logging
251
252 import fixtures
253-from filemanager import emulators
254-
255+from autopilot import logging as autopilot_logging
256 from autopilot.input import Mouse, Touch, Pointer
257+from autopilot.matchers import Eventually
258 from autopilot.platform import model
259 from autopilot.testcase import AutopilotTestCase
260-from autopilot import logging as autopilot_logging
261-
262+from testtools.matchers import Equals
263 from ubuntuuitoolkit import (
264 emulators as toolkit_emulators,
265 fixture_setup as toolkit_fixtures
266 )
267
268+from filemanager import emulators
269+
270 logger = logging.getLogger(__name__)
271
272
273@@ -77,6 +87,9 @@
274
275 self.app = launcher()
276
277+ self.assertThat(
278+ self.main_view.visible, Eventually(Equals(True)))
279+
280 @autopilot_logging.log_action(logger.info)
281 def launch_test_local(self):
282 self.useFixture(fixtures.EnvironmentVariable(
283
284=== modified file 'tests/autopilot/filemanager/tests/test_filemanager.py'
285--- tests/autopilot/filemanager/tests/test_filemanager.py 2014-05-08 23:20:20 +0000
286+++ tests/autopilot/filemanager/tests/test_filemanager.py 2014-06-10 18:01:55 +0000
287@@ -1,6 +1,6 @@
288 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
289 #
290-# Copyright (C) 2013 Canonical Ltd.
291+# Copyright (C) 2013, 2014 Canonical Ltd.
292 #
293 # This program is free software; you can redistribute it and/or modify
294 # it under the terms of the GNU Lesser General Public License as published by
295@@ -35,11 +35,6 @@
296
297 class TestFolderListPage(FileManagerTestCase):
298
299- def setUp(self):
300- super(TestFolderListPage, self).setUp()
301- self.assertThat(
302- self.main_view.visible, Eventually(Equals(True)))
303-
304 def _make_file_in_home(self):
305 return self._make_content_in_home('file')
306
307@@ -92,22 +87,6 @@
308 Eventually(NotEquals(None)))
309 return folder_list_page.get_file_by_index(index)
310
311- def _go_to_place(self, text):
312- # XXX We are receiving the text because there's no way to set the
313- # objectName on the ListElement. This is reported at
314- # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205201
315- # --elopio - 2013-07-25
316- place = None
317- if self.main_view.showSidebar:
318- place = (self.main_view.get_folder_list_page().get_sidebar()
319- .get_place(text))
320- else:
321- open_popover = lambda: \
322- self.main_view.open_toolbar().click_button('places')
323- self._safe_open_popover(open_popover)
324- place = self._get_place(text)
325- self.pointing_device.click_object(place)
326-
327 def _go_to_location(self, location):
328 #go to specified location
329 #on wide UI display, we get the location dialog
330@@ -120,22 +99,11 @@
331 goto_location = self.main_view.get_dialog()
332 else:
333 logger.debug("Using places to goto %s on %s" % (location, device))
334- open_popover = lambda: \
335- self.main_view.open_toolbar().click_button('places')
336- self._safe_open_popover(open_popover)
337+ self._safe_open_popover(self.main_view.open_places)
338 goto_location = self.main_view.get_popover()
339 goto_location.enter_text(location)
340 goto_location.ok()
341
342- def _get_place(self, text):
343- places_popover = self.main_view.get_places_popover()
344- places = places_popover.select_many('Standard')
345- for place in places:
346- if place.name == text:
347- return place
348- raise ValueError(
349- 'Place "{0}" not found.'.format(text))
350-
351 def _make_directory_in_home(self):
352 return self._make_content_in_home('directory')
353
354@@ -627,22 +595,6 @@
355 folder_list_page.get_current_path,
356 Eventually(Equals(self.home_dir)))
357
358- def test_go_home(self):
359- self._go_to_place('Home')
360-
361- folder_list_page = self.main_view.get_folder_list_page()
362- self.assertThat(
363- folder_list_page.get_current_path,
364- Eventually(Equals(self.home_dir)))
365-
366- def test_go_to_root(self):
367- self._go_to_place('File System')
368-
369- folder_list_page = self.main_view.get_folder_list_page()
370- self.assertThat(
371- folder_list_page.get_current_path,
372- Eventually(Equals('/')))
373-
374 def test_file_context_menu_shows(self):
375 """Checks to make sure that the file actions popover is shown."""
376 file_name = os.path.basename(self._make_file_in_home())
377
378=== added file 'tests/autopilot/filemanager/tests/test_places.py'
379--- tests/autopilot/filemanager/tests/test_places.py 1970-01-01 00:00:00 +0000
380+++ tests/autopilot/filemanager/tests/test_places.py 2014-06-10 18:01:55 +0000
381@@ -0,0 +1,42 @@
382+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
383+#
384+# Copyright (C) 2013, 2014 Canonical Ltd.
385+#
386+# This program is free software; you can redistribute it and/or modify
387+# it under the terms of the GNU Lesser General Public License as published by
388+# the Free Software Foundation; version 3.
389+#
390+# This program is distributed in the hope that it will be useful,
391+# but WITHOUT ANY WARRANTY; without even the implied warranty of
392+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
393+# GNU Lesser General Public License for more details.
394+#
395+# You should have received a copy of the GNU Lesser General Public License
396+# along with this program. If not, see <http://www.gnu.org/licenses/>.
397+
398+from autopilot.matchers import Eventually
399+from testtools.matchers import Equals
400+
401+from filemanager import tests
402+
403+
404+class PlacesTestCase(tests.FileManagerTestCase):
405+ """Test cases for the places section of the file manager app."""
406+
407+ def test_go_home_must_open_the_home_directory(self):
408+ """Test that opens the Home bookmark from the places section."""
409+ self.main_view.go_to_place('placeHome')
410+
411+ folder_list_page = self.main_view.get_folder_list_page()
412+ self.assertThat(
413+ folder_list_page.get_current_path,
414+ Eventually(Equals(self.home_dir)))
415+
416+ def test_go_to_root_must_open_the_root_directory(self):
417+ """Test that opens the File System bookmark from the places section."""
418+ self.main_view.go_to_place('placeRoot')
419+
420+ folder_list_page = self.main_view.get_folder_list_page()
421+ self.assertThat(
422+ folder_list_page.get_current_path,
423+ Eventually(Equals('/')))

Subscribers

People subscribed via source and target branches