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

Proposed by Michael Spencer
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 57
Merged at revision: 39
Proposed branch: lp:~ibelieve/ubuntu-filemanager-app/autopilot-tests
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~ibelieve/ubuntu-filemanager-app/improved-toolbar
Diff against target: 352 lines (+205/-16)
6 files modified
ConfirmDialog.qml (+2/-0)
ConfirmDialogWithInput.qml (+4/-0)
FolderListDelegate.qml (+3/-0)
tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py (+11/-4)
tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py (+1/-1)
tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py (+184/-11)
To merge this branch: bzr merge lp:~ibelieve/ubuntu-filemanager-app/autopilot-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Arto Jalkanen Approve
Review via email: mp+172178@code.launchpad.net

Commit message

Added autopilot tests

Description of the change

This adds the following autopilot tests:

* Test going up a directory
* Test create directory
* Test delete directory
* Test delete file
* Test rename directory
* Test rename file

To post a comment you must log in.
55. By Michael Spencer

Added test for deleting a file

56. By Michael Spencer

Added tests for a renaming a directory and for renaming a file

57. By Michael Spencer

Merged in changes from the improved toolbar

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

I'm getting an error running these tests:

Places
Directory: /tmp/
Path: /tmp/
Sub dir: tmpiYvVS6
void DirModel::setPath(const QString&) Ignoring path change request, request already running
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
}}}

Traceback (most recent call last):
  File "/home/arto/coding/merge/autopilot-tests/tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py", line 91, in test_open_directory
    Eventually(Equals(sub_dir)))
MismatchError: After 10.0 seconds test failed: '/tmp/tmpiYvVS6/tmpWSDOar' != String(u'/tmp/tmpiYvVS6')

Ran 10 tests in 93.874s
FAILED (failures=4)

review: Needs Information
Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> I'm getting an error running these tests:

Nevermind, user error - outdated plugin.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Worked fine after updating plugin - ran a little slow (81 seconds on my computer), don't know if that can be improved.

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

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-04-17 17:55:41 +0000
3+++ ConfirmDialog.qml 2013-07-01 13:53:22 +0000
4@@ -26,6 +26,7 @@
5 signal rejected
6
7 Button {
8+ objectName: "okButton"
9 text: i18n.tr("Ok")
10 onClicked: {
11 accepted()
12@@ -34,6 +35,7 @@
13 }
14
15 Button {
16+ objectName: "cancelButton"
17 text: i18n.tr("Cancel")
18 onClicked: {
19 rejected()
20
21=== modified file 'ConfirmDialogWithInput.qml'
22--- ConfirmDialogWithInput.qml 2013-04-17 17:55:41 +0000
23+++ ConfirmDialogWithInput.qml 2013-07-01 13:53:22 +0000
24@@ -23,15 +23,18 @@
25 id: root
26
27 property alias inputText: input.text
28+ property alias placeholderText: input.placeholderText
29 signal accepted
30 signal rejected
31
32 TextField {
33 id: input
34+ objectName: "inputField"
35 focus: true
36 }
37
38 Button {
39+ objectName: "okButton"
40 text: i18n.tr("Ok")
41 onClicked: {
42 accepted()
43@@ -40,6 +43,7 @@
44 }
45
46 Button {
47+ objectName: "cancelButton"
48 text: i18n.tr("Cancel")
49 onClicked: {
50 rejected()
51
52=== modified file 'FolderListDelegate.qml'
53--- FolderListDelegate.qml 2013-07-01 13:53:22 +0000
54+++ FolderListDelegate.qml 2013-07-01 13:53:22 +0000
55@@ -22,6 +22,9 @@
56
57 ListItem.Subtitled {
58 objectName: "folder" + index
59+
60+ property string fileName: model.fileName
61+
62 text: model.fileName
63 subText: Qt.formatDateTime(model.modifiedDate, Qt.DefaultLocaleShortDate) + (!model.isDir ? ", " + fileSize : "")
64
65
66=== modified file 'tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py'
67--- tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py 2013-07-01 13:53:22 +0000
68+++ tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py 2013-07-01 13:53:22 +0000
69@@ -16,12 +16,12 @@
70 def __init__(self, app):
71 self.app = app
72
73- def get_folder(self, index):
74+ def get_file_item(self, index):
75 """Returns the list view folder with index number."""
76- return self.app.select_single('FolderListPage').select_many("Subtitled")[index]
77+ return self.app.select_single('FolderListPage').select_many("FolderListDelegate")[index]
78
79- def get_folder_count(self):
80- return len(self.app.select_single('FolderListPage').select_many("Subtitled"))
81+ def get_file_count(self):
82+ return len(self.app.select_single('FolderListPage').select_many("FolderListDelegate"))
83
84 def get_action_popover(self):
85 # Returns all instances, but with current one as first index
86@@ -30,5 +30,12 @@
87 def get_current_folder_name(self):
88 return self.app.select_single('FolderListView').folderPath
89
90+ def get_filenames(self):
91+ folders = self.app.select_single('FolderListPage').select_many("FolderListDelegate")
92+ names = []
93+ for folder in folders:
94+ names += [folder.fileName]
95+ return names
96+
97 def get_page_title(self):
98 return self.app.select_single('FolderListPage').title
99
100=== modified file 'tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py'
101--- tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py 2013-06-27 14:18:10 +0000
102+++ tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py 2013-07-01 13:53:22 +0000
103@@ -68,7 +68,7 @@
104 toolbar = self.get_toolbar()
105 if not toolbar.opened:
106 self.open_toolbar()
107- row = toolbar.select_single("QQuickRow")
108+ row = toolbar.select_single("ToolbarItems")
109 buttonList = row.select_many("ActionItem")
110 for button in buttonList:
111 if button.text == buttonLabel:
112
113=== modified file 'tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py'
114--- tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-07-01 13:53:22 +0000
115+++ tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-07-01 13:53:22 +0000
116@@ -13,6 +13,7 @@
117
118 import mock
119 import os
120+import os.path
121 import shutil
122
123 from autopilot.matchers import Eventually
124@@ -49,7 +50,7 @@
125 """Checks to make sure that the file actions popover is shown."""
126 self._make_directory_in_home()
127
128- first_folder = self.main_window.get_folder(0)
129+ first_folder = self.main_window.get_file_item(0)
130 self.tap_item(first_folder)
131
132 action_popover = self.main_window.get_action_popover()
133@@ -59,37 +60,209 @@
134 path = tempfile.mkdtemp(dir=os.environ['HOME'])
135 # Currently, we need to open again the home folder to show the newly
136 # created one. See bug #1190676.
137- # TODO when the bug is fixed, remove the following lines up to the assert line
138- home_place = self._get_place("Home")
139- self.pointing_device.click_object(home_place)
140-
141- self.assertThat(self.main_window.get_folder_count, Eventually(Equals(1)))
142+ # TODO when the bug is fixed, remove the following line
143+ self._go_to_place('Home')
144+
145+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
146+
147+ return path
148+
149+ def _make_file_in_home(self):
150+ path = tempfile.mkstemp(dir=os.environ['HOME'])[1]
151+ # Currently, we need to open again the home folder to show the newly
152+ # created one. See bug #1190676.
153+ # TODO when the bug is fixed, remove the following line
154+ self._go_to_place('Home')
155+
156+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
157
158 return path
159
160 def test_open_directory(self):
161 sub_dir = self._make_directory_in_home()
162
163- first_folder = self.main_window.get_folder(0)
164+ first_folder = self.main_window.get_file_item(0)
165+ self.assertThat(first_folder.fileName,
166+ Eventually(Equals(os.path.split(sub_dir)[1])))
167+
168 self.pointing_device.click_object(first_folder)
169 self.assertThat(
170 self.main_window.get_current_folder_name,
171 Eventually(Equals(sub_dir)))
172+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(0)))
173+
174+ def test_rename_directory(self):
175+ sub_dir = self._make_directory_in_home()
176+ dir_name = os.path.split(sub_dir)[1]
177+ new_name = 'New Test Directory'
178+
179+ first_folder = self.main_window.get_file_item(0)
180+
181+ self.tap_item(first_folder)
182+ action_popover = self.main_window.get_action_popover()
183+ self._run_action(action_popover, 'Rename')
184+
185+ self._cancel_action()
186+
187+ self.assertThat(lambda: self.main_window.get_filenames()[0], Eventually(Equals(dir_name)))
188+
189+ self.tap_item(first_folder)
190+ action_popover = self.main_window.get_action_popover()
191+ self._run_action(action_popover, 'Rename')
192+
193+ self._provide_input(new_name)
194+
195+ self.assertThat(lambda: self.main_window.get_filenames()[0], Eventually(Equals(new_name)))
196+
197+ def test_rename_file(self):
198+ path = self._make_file_in_home()
199+ name = os.path.split(path)[1]
200+ new_name = 'New Test File'
201+
202+ first_file = self.main_window.get_file_item(0)
203+
204+ self.tap_item(first_file)
205+ action_popover = self.main_window.get_action_popover()
206+ self._run_action(action_popover, 'Rename')
207+
208+ self._cancel_action()
209+
210+ self.assertThat(lambda: self.main_window.get_filenames()[0], Eventually(Equals(name)))
211+
212+ self.tap_item(first_file)
213+ action_popover = self.main_window.get_action_popover()
214+ self._run_action(action_popover, 'Rename')
215+
216+ self._provide_input(new_name)
217+
218+ self.assertThat(lambda: self.main_window.get_filenames()[0], Eventually(Equals(new_name)))
219+
220+
221+ def test_delete_directory(self):
222+ sub_dir = self._make_directory_in_home()
223+ first_folder = self.main_window.get_file_item(0)
224+
225+ self.tap_item(first_folder)
226+ action_popover = self.main_window.get_action_popover()
227+ self._run_action(action_popover, 'Delete')
228+
229+ self._cancel_action()
230+
231+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
232+
233+ self.tap_item(first_folder)
234+ action_popover = self.main_window.get_action_popover()
235+ self._run_action(action_popover, 'Delete')
236+
237+ self._confirm_action()
238+
239+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(0)))
240+
241+ def test_delete_file(self):
242+ sub_dir = self._make_file_in_home()
243+ first_folder = self.main_window.get_file_item(0)
244+
245+ self.tap_item(first_folder)
246+ action_popover = self.main_window.get_action_popover()
247+ self._run_action(action_popover, 'Delete')
248+
249+ self._cancel_action()
250+
251+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
252+
253+ self.tap_item(first_folder)
254+ action_popover = self.main_window.get_action_popover()
255+ self._run_action(action_popover, 'Delete')
256+
257+ self._confirm_action()
258+
259+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(0)))
260+
261+ def test_create_directory(self):
262+ name = 'Test Directory'
263+
264+ #self._go_to_place('Home')
265+ self.ubuntusdk.click_toolbar_button('Actions')
266+
267+ popover = self.app.select_single("ActionSelectionPopover", objectName='folderActionsPopover')
268+ self._run_action(popover, 'Create New Folder')
269+ self._provide_input(name)
270+
271+ self.assertThat(self.main_window.get_file_count, Eventually(Equals(1)))
272+
273+ self.assertThat(lambda: self.main_window.get_filenames()[0], Eventually(Equals(name)))
274+
275+ def test_going_up(self):
276+ upDir = os.path.split(os.environ['HOME'])[0]
277+ upName = os.path.split(upDir)[1]
278+
279+ #home_place = self._go_to_place("Home")
280+
281+ self._check_location("Home", os.environ['HOME'])
282+
283+ self.ubuntusdk.click_toolbar_button('Up')
284+ self._check_location(upName, upDir)
285
286 def test_going_home(self):
287- home_place = self._get_place("Home")
288- self.pointing_device.click_object(home_place)
289+ self._go_to_place('Home')
290
291 self._check_location("Home", os.environ['HOME'])
292
293 def test_going_to_root(self):
294- root_place = self._get_place("File System")
295- self.pointing_device.click_object(root_place)
296+ self._go_to_place('File System')
297
298 self._check_location("File System", "/")
299
300+ def _go_to_place(self, name):
301+ place = self._get_place(name)
302+ self.pointing_device.click_object(place)
303+
304 def _check_location(self,title,location):
305 self.assertThat(self.main_window.get_page_title, Eventually(Equals(title)))
306
307 self.assertThat(self.main_window.get_current_folder_name,
308 Eventually(Equals(location)))
309+
310+ def _run_action(self, popover, name):
311+ actions = popover.select_many('Empty')
312+ requested = None
313+ for action in actions:
314+ if action.text == name:
315+ requested = action
316+ self.pointing_device.click_object(requested)
317+
318+ def _confirm_action(self):
319+ dialog = self.app.select_single('ConfirmDialog')
320+ if dialog == None:
321+ dialog = self.app.select_single('ConfirmDialogWithInput')
322+ okButton = dialog.select_single('Button',objectName='okButton')
323+ self.pointing_device.click_object(okButton)
324+
325+ def _cancel_action(self):
326+ dialog = self.app.select_single('ConfirmDialog')
327+ if dialog == None:
328+ dialog = self.app.select_single('ConfirmDialogWithInput')
329+ cancelButton = dialog.select_single('Button',objectName='cancelButton')
330+ self.pointing_device.click_object(cancelButton)
331+
332+ def _provide_input(self, text):
333+ """Fill in the input dialog"""
334+ dialog = self.app.select_single('ConfirmDialogWithInput')
335+ field = dialog.select_single('TextField')
336+
337+ self.pointing_device.click_object(field)
338+
339+ clearButton = field.select_single('AbstractButton')
340+ #if clearButton:
341+ self.pointing_device.click_object(clearButton)
342+
343+ self.assertThat(field.text, Eventually(Equals("")))
344+
345+ self.pointing_device.click_object(field)
346+
347+ self.keyboard.type(text)
348+ self.assertThat(field.text,
349+ Eventually(Equals(text)))
350+
351+ okButton = dialog.select_single('Button',objectName='okButton')
352+ self.pointing_device.click_object(okButton)

Subscribers

People subscribed via source and target branches