Merge lp:~ibelieve/ubuntu-filemanager-app/more-autopilot-tests into lp:ubuntu-filemanager-app

Proposed by Michael Spencer
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 50
Merged at revision: 49
Proposed branch: lp:~ibelieve/ubuntu-filemanager-app/more-autopilot-tests
Merge into: lp:ubuntu-filemanager-app
Diff against target: 398 lines (+253/-20)
5 files modified
ConfirmDialog.qml (+2/-0)
FileActionDialog.qml (+15/-1)
FileDetailsPopover.qml (+1/-0)
FolderListView.qml (+1/-1)
tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py (+234/-18)
To merge this branch: bzr merge lp:~ibelieve/ubuntu-filemanager-app/more-autopilot-tests
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+174858@code.launchpad.net

Commit message

Added more autopilot tests

Description of the change

Added more 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: Needs Fixing (continuous-integration)
49. By Michael Spencer

Fixed pep8 errors

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
50. By Michael Spencer

Fixed pyflake errors

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 :

I think this closes out the remaining bugs, awesome work Michael!

I added this bug as it appears to be fixed in this commit also:
https://bugs.launchpad.net/ubuntu-filemanager-app/+bug/1188746

review: Approve
Revision history for this message
Michael Spencer (ibelieve) wrote :

That bug is the one that I am stuck on that throws DBus exceptions. The only thing I have in the branch related to that is the pseudo code for that test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ConfirmDialog.qml'
2--- ConfirmDialog.qml 2013-07-04 20:33:07 +0000
3+++ ConfirmDialog.qml 2013-07-16 01:09:24 +0000
4@@ -26,6 +26,7 @@
5 signal rejected
6
7 Button {
8+ id: okButton
9 objectName: "okButton"
10 text: i18n.tr("Ok")
11 onClicked: {
12@@ -35,6 +36,7 @@
13 }
14
15 Button {
16+ id: cancelButton
17 objectName: "cancelButton"
18 text: i18n.tr("Cancel")
19
20
21=== modified file 'FileActionDialog.qml'
22--- FileActionDialog.qml 2013-05-16 16:14:35 +0000
23+++ FileActionDialog.qml 2013-07-16 01:09:24 +0000
24@@ -28,9 +28,10 @@
25 property FolderListModel folderListModel
26
27 title: i18n.tr("Choose action")
28- text: i18n.tr("For file: ") + fileName
29+ text: i18n.tr("For file: %1").arg(fileName)
30
31 Button {
32+ objectName: "openButton"
33 text: i18n.tr("Open")
34 onClicked: {
35 console.log("Opening file", filePath)
36@@ -40,7 +41,20 @@
37 }
38
39 Button {
40+ objectName: "cancelButton"
41 text: i18n.tr("Cancel")
42 onClicked: PopupUtils.close(root)
43+
44+ gradient: Gradient {
45+ GradientStop {
46+ position: 0
47+ color: "gray"
48+ }
49+
50+ GradientStop {
51+ position: 1
52+ color: "lightgray"
53+ }
54+ }
55 }
56 }
57
58=== modified file 'FileDetailsPopover.qml'
59--- FileDetailsPopover.qml 2013-07-08 12:46:19 +0000
60+++ FileDetailsPopover.qml 2013-07-16 01:09:24 +0000
61@@ -91,6 +91,7 @@
62 }
63
64 Label {
65+ objectName: "pathLabel"
66 text: root.path
67 }
68
69
70=== modified file 'FolderListView.qml'
71--- FolderListView.qml 2013-06-30 02:06:29 +0000
72+++ FolderListView.qml 2013-07-16 01:09:24 +0000
73@@ -195,7 +195,7 @@
74 fileName: model.fileName,
75 filePath: model.filePath,
76 folderListModel: root.folderListModel
77- })
78+ })
79 }
80 }
81
82
83=== modified file 'tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py'
84--- tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-07-15 16:38:00 +0000
85+++ tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-07-16 01:09:24 +0000
86@@ -18,6 +18,7 @@
87
88 from autopilot.matchers import Eventually
89 from testtools.matchers import Equals
90+#from testtools.matchers import NotEquals
91
92 from ubuntu_filemanager_app.tests import FileManagerTestCase
93
94@@ -47,7 +48,7 @@
95 if place.text == name:
96 return place
97
98- def test_file_actions_shows(self):
99+ def test_file_context_menu_shows(self):
100 """Checks to make sure that the file actions popover is shown."""
101 self._make_file_in_home()
102
103@@ -57,7 +58,7 @@
104 action_popover = self.main_window.get_action_popover()
105 self.assertThat(lambda: action_popover.opacity, Eventually(Equals(1)))
106
107- def test_folder_actions_shows(self):
108+ def test_folder_context_menu_shows(self):
109 """Checks to make sure that the folder actions popover is shown."""
110 self._make_directory_in_home()
111
112@@ -67,28 +68,63 @@
113 action_popover = self.main_window.get_action_popover()
114 self.assertThat(lambda: action_popover.opacity, Eventually(Equals(1)))
115
116+ def test_list_folder_contents(self):
117+ sub_dir = self._make_directory_in_home()
118+ fileName = self._make_file_in_home()
119+
120+ first_folder = self.main_window.get_file_item(0)
121+ self.assertThat(first_folder.fileName,
122+ Eventually(Equals(os.path.split(sub_dir)[1])))
123+
124+ first_file = self.main_window.get_file_item(1)
125+ self.assertThat(first_file.fileName,
126+ Eventually(Equals(os.path.split(fileName)[1])))
127+
128 def _make_directory_in_home(self):
129+ count = self.main_window.get_file_count()
130 path = tempfile.mkdtemp(dir=os.environ['HOME'])
131- # Currently, we need to open again the home folder to show the newly
132- # created one. See bug #1190676.
133- # TODO when the bug is fixed, remove the following line
134- self._go_to_place('Home')
135
136- self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
137+ self.assertThat(self.main_window.get_file_count,
138+ Eventually(Equals(count + 1)))
139
140 return path
141
142 def _make_file_in_home(self):
143+ count = self.main_window.get_file_count()
144 path = tempfile.mkstemp(dir=os.environ['HOME'])[1]
145- # Currently, we need to open again the home folder to show the newly
146- # created one. See bug #1190676.
147- # TODO when the bug is fixed, remove the following line
148- self._go_to_place('Home')
149
150- self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
151+ self.assertThat(self.main_window.get_file_count,
152+ Eventually(Equals(count + 1)))
153
154 return path
155
156+ def test_file_action_dialog(self):
157+ file_name = self._make_file_in_home()
158+
159+ first_file = self.main_window.get_file_item(0)
160+ self.assertThat(first_file.fileName,
161+ Eventually(Equals(os.path.split(file_name)[1])))
162+
163+ self.pointing_device.click_object(first_file)
164+
165+ dialog = self.app.select_single('FileActionDialog')
166+ cancelButton = dialog.select_single(
167+ 'Button',
168+ objectName='cancelButton')
169+ self.pointing_device.click_object(cancelButton)
170+
171+ first_file = self.main_window.get_file_item(0)
172+ self.assertThat(first_file.fileName,
173+ Eventually(Equals(os.path.split(file_name)[1])))
174+
175+ self.pointing_device.click_object(first_file)
176+
177+ dialog = self.app.select_single('FileActionDialog')
178+
179+ openButton = dialog.select_single(
180+ 'Button', objectName='openButton')
181+ self.pointing_device.click_object(openButton)
182+
183 def test_open_directory(self):
184 sub_dir = self._make_directory_in_home()
185
186@@ -200,12 +236,7 @@
187 def test_create_directory(self):
188 name = 'Test Directory'
189
190- #self._go_to_place('Home')
191- self.ubuntusdk.click_toolbar_button('Actions')
192-
193- popover = self.app.select_single(
194- "ActionSelectionPopover", objectName='folderActionsPopover')
195- self._run_action(popover, 'Create New Folder')
196+ self._run_folder_action('Create New Folder')
197 self._provide_input(name)
198
199 self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
200@@ -214,6 +245,178 @@
201 lambda: self.main_window.get_filenames()[0], Eventually(
202 Equals(name)))
203
204+ def test_showing_directory_properties(self):
205+ path = self._make_directory_in_home()
206+
207+ first_folder = self.main_window.get_file_item(0)
208+ self.tap_item(first_folder)
209+
210+ popover = self.main_window.get_action_popover()
211+ self._run_action(popover, 'Properties')
212+
213+ properties_popover = self.app.select_single('FileDetailsPopover')
214+ self.assertThat(lambda: properties_popover.opacity,
215+ Eventually(Equals(1)))
216+ path_label = properties_popover.select_single(
217+ 'Label', objectName='pathLabel')
218+ self.assertThat(lambda: path_label.text,
219+ Eventually(Equals(path)))
220+
221+ def test_showing_file_properties(self):
222+ path = self._make_file_in_home()
223+
224+ first_file = self.main_window.get_file_item(0)
225+ self.tap_item(first_file)
226+
227+ popover = self.app.select_single(
228+ "ActionSelectionPopover", objectName='fileActionsPopover')
229+ self._run_action(popover, 'Properties')
230+
231+ properties_popover = self.app.select_single(
232+ 'FileDetailsPopover')
233+ self.assertThat(lambda: properties_popover.opacity,
234+ Eventually(Equals(1)))
235+ path_label = properties_popover.select_single(
236+ 'Label', objectName='pathLabel')
237+ self.assertThat(lambda: path_label.text, Eventually(Equals(path)))
238+
239+ def test_copy_folder(self):
240+ # Set up a folder to copy and a folder to copy it into
241+ sub_dir = os.environ['HOME'] + '/Destination'
242+ os.mkdir(sub_dir)
243+ copy_dir = os.environ['HOME'] + '/Folder to Copy'
244+ os.mkdir(copy_dir)
245+
246+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(2)))
247+
248+ # Copy the folder
249+ first_file = self.main_window.get_file_item(1)
250+ self.assertThat(
251+ first_file.fileName,
252+ Eventually(Equals(os.path.split(copy_dir)[1])))
253+ self._run_file_action(first_file, 'Copy')
254+
255+ # Go to the destination folder
256+ first_folder = self.main_window.get_file_item(0)
257+ self.assertThat(
258+ first_folder.fileName,
259+ Eventually(Equals(os.path.split(sub_dir)[1])))
260+
261+ self.pointing_device.click_object(first_folder)
262+
263+ # Paste it in
264+ self._run_folder_action('Paste 1 File')
265+
266+ # Check that the folder is there
267+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
268+ first_file = self.main_window.get_file_item(0)
269+ self.assertThat(
270+ first_file.fileName,
271+ Eventually(Equals(os.path.split(copy_dir)[1])))
272+
273+ # Go back
274+ self._go_up()
275+
276+ # Check that the file is still there
277+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(2)))
278+ first_file = self.main_window.get_file_item(1)
279+ self.assertThat(
280+ first_file.fileName,
281+ Eventually(Equals(os.path.split(copy_dir)[1])))
282+
283+ def test_cut_folder(self):
284+ # Set up a folder to cut and a folder to move it into
285+ sub_dir = os.environ['HOME'] + '/Destination'
286+ os.mkdir(sub_dir)
287+ copy_dir = os.environ['HOME'] + '/Folder to Cut'
288+ os.mkdir(copy_dir)
289+
290+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(2)))
291+
292+ # Cut the folder
293+ first_file = self.main_window.get_file_item(1)
294+ self.assertThat(
295+ first_file.fileName,
296+ Eventually(Equals(os.path.split(copy_dir)[1])))
297+ self._run_file_action(first_file, 'Cut')
298+
299+ # Go to the destination folder
300+ first_folder = self.main_window.get_file_item(0)
301+ self.assertThat(
302+ first_folder.fileName,
303+ Eventually(Equals(os.path.split(sub_dir)[1])))
304+
305+ self.pointing_device.click_object(first_folder)
306+
307+ # Paste it in
308+ self._run_folder_action('Paste 1 File')
309+
310+ # Check that the folder is there
311+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
312+ first_file = self.main_window.get_file_item(0)
313+ self.assertThat(
314+ first_file.fileName,
315+ Eventually(Equals(os.path.split(copy_dir)[1])))
316+
317+ # Go back
318+ self._go_up()
319+
320+ # Check that the folder is not there
321+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
322+
323+ def test_copy_file(self):
324+ pass
325+ # Set up a file to copy and a folder to copy it into
326+ # Copy the file
327+ # Go to the destination folder
328+ # Paste it in
329+ # Check that the file is there
330+ # Go back
331+ # Check that the folder is not there
332+
333+ def test_cut_file(self):
334+ # Set up a file to cut and a folder to copy it into
335+ sub_dir = self._make_directory_in_home()
336+ fileName = self._make_file_in_home()
337+
338+ # Cut the file
339+ first_file = self.main_window.get_file_item(1)
340+ self.assertThat(
341+ first_file.fileName,
342+ Eventually(Equals(os.path.split(fileName)[1])))
343+ self.tap_item(first_file)
344+
345+ popover = self.app.select_single(
346+ "ActionSelectionPopover", objectName='fileActionsPopover')
347+ self._run_action(popover, 'Cut')
348+
349+ # Go to the folder
350+ first_folder = self.main_window.get_file_item(0)
351+ self.assertThat(
352+ first_folder.fileName,
353+ Eventually(Equals(os.path.split(sub_dir)[1])))
354+
355+ self.pointing_device.click_object(first_folder)
356+
357+ # Paste it in
358+ self._run_folder_action('Paste 1 File')
359+
360+ # Check that the file is there
361+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
362+ first_file = self.main_window.get_file_item(0)
363+ self.assertThat(
364+ first_file.fileName,
365+ Eventually(Equals(os.path.split(fileName)[1])))
366+
367+ # Go back
368+ self._go_up()
369+
370+ # Check that the file is not there
371+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
372+
373+ def _go_up(self):
374+ self.ubuntusdk.click_toolbar_button('Up')
375+
376 def test_going_up(self):
377 upDir = os.path.split(os.environ['HOME'])[0]
378 upName = os.path.split(upDir)[1]
379@@ -247,6 +450,19 @@
380 self.main_window.get_current_folder_name,
381 Eventually(Equals(location)))
382
383+ def _run_file_action(self, item, name):
384+ self.tap_item(item)
385+
386+ popover = self.app.select_single(
387+ "ActionSelectionPopover", objectName='fileActionsPopover')
388+ self._run_action(popover, name)
389+
390+ def _run_folder_action(self, name):
391+ self.ubuntusdk.click_toolbar_button('Actions')
392+ popover = self.app.select_single(
393+ "ActionSelectionPopover", objectName='folderActionsPopover')
394+ self._run_action(popover, name)
395+
396 def _run_action(self, popover, name):
397 actions = popover.select_many('Empty')
398 requested = None

Subscribers

People subscribed via source and target branches