Merge lp:~noskcaj/ubuntu-autopilot-tests/pep8 into lp:ubuntu-autopilot-tests
- pep8
- Merge into trunk
Proposed by
Jackson Doak
Status: | Merged |
---|---|
Approved by: | Dan Chapman |
Approved revision: | 69 |
Merged at revision: | 61 |
Proposed branch: | lp:~noskcaj/ubuntu-autopilot-tests/pep8 |
Merge into: | lp:ubuntu-autopilot-tests |
Diff against target: |
2789 lines (+954/-759) 13 files modified
ubuntu_autopilot_tests/eog/test_eog.py (+58/-52) ubuntu_autopilot_tests/evince/test_evince.py (+43/-45) ubuntu_autopilot_tests/fileroller/test_fileroller.py (+93/-62) ubuntu_autopilot_tests/firefox/test_firefox.py (+72/-64) ubuntu_autopilot_tests/gedit/__init__.py (+112/-81) ubuntu_autopilot_tests/gedit/samples/gedit.py (+2/-2) ubuntu_autopilot_tests/gedit/test_gedit.py (+309/-239) ubuntu_autopilot_tests/nautilus/test_nautilus.py (+21/-17) ubuntu_autopilot_tests/screenshot/test_screenshot.py (+130/-96) ubuntu_autopilot_tests/shotwell/test_shotwell.py (+55/-48) ubuntu_autopilot_tests/terminal/__init__.py (+3/-2) ubuntu_autopilot_tests/terminal/test_terminal.py (+16/-14) ubuntu_autopilot_tests/totem/test_totem.py (+40/-37) |
To merge this branch: | bzr merge lp:~noskcaj/ubuntu-autopilot-tests/pep8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dan Chapman (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Make all tests pep8 compliant
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ubuntu_autopilot_tests/eog/test_eog.py' |
2 | --- ubuntu_autopilot_tests/eog/test_eog.py 2013-07-11 11:23:20 +0000 |
3 | +++ ubuntu_autopilot_tests/eog/test_eog.py 2013-11-23 00:24:47 +0000 |
4 | @@ -5,80 +5,87 @@ |
5 | from autopilot.input import Mouse, Touch, Pointer |
6 | |
7 | |
8 | - |
9 | class EogTests(AutopilotTestCase): |
10 | - |
11 | + |
12 | def setUp(self): |
13 | super(EogTests, self).setUp() |
14 | - |
15 | + |
16 | image_name = 'logo-ubuntu_su-orange-hex.jpg' |
17 | for root, dirs, files in os.walk(os.getcwd()): |
18 | for name in files: |
19 | if name == image_name: |
20 | img_path = os.path.abspath(os.path.join(root, name)) |
21 | - #Lets auto load the image as we dn't have access to the global menu |
22 | + #Lets auto load the image as we dn't have access to the global menu |
23 | self.app = self.launch_test_application('eog', img_path) |
24 | - |
25 | + |
26 | self.pointing_device = Pointer(Mouse.create()) |
27 | self.get_eog_objects() |
28 | - |
29 | + |
30 | def test_display_image(self): |
31 | #check that the image loaded |
32 | self.assertThat(self.eog_window.title, |
33 | Eventually(Contains('logo-ubuntu_su-orange-hex.jpg'))) |
34 | - |
35 | + |
36 | def test_zoom_image(self): |
37 | self.pointing_device.move_to_object(self.normal_size_button) |
38 | self.pointing_device.click() |
39 | self.assertThat(self.status_label.label, Eventually(Contains('100%'))) |
40 | - |
41 | + |
42 | self.pointing_device.move_to_object(self.zoom_in_button) |
43 | self.pointing_device.click() |
44 | self.assertThat(self.status_label.label, Eventually(Contains('200%'))) |
45 | - |
46 | + |
47 | self.pointing_device.move_to_object(self.zoom_out_button) |
48 | self.pointing_device.click() |
49 | self.assertThat(self.status_label.label, Eventually(Contains('100%'))) |
50 | - |
51 | + |
52 | def test_show_prev_and_next_images(self): |
53 | - |
54 | + |
55 | self.pointing_device.move_to_object(self.previous_button) |
56 | self.pointing_device.click() |
57 | self.assertThat(self.eog_window.title, |
58 | - Eventually(Contains('logo-ubuntu_st_no-white_orangecof-hex'))) |
59 | - self.pointing_device.click() |
60 | - self.assertThat(self.eog_window.title, |
61 | - Eventually(Contains('logo-ubuntu_st_no-black_orange-hex'))) |
62 | - |
63 | - self.pointing_device.click() |
64 | - self.assertThat(self.eog_window.title, |
65 | - Eventually(Contains('logo-ubuntu_cof-orange-hex'))) |
66 | + Eventually(Contains( |
67 | + 'logo-ubuntu_st_no-white_orangecof-hex'))) |
68 | + self.pointing_device.click() |
69 | + self.assertThat(self.eog_window.title, |
70 | + Eventually(Contains( |
71 | + 'logo-ubuntu_st_no-black_orange-hex'))) |
72 | + |
73 | + self.pointing_device.click() |
74 | + self.assertThat(self.eog_window.title, |
75 | + Eventually(Contains( |
76 | + 'logo-ubuntu_cof-orange-hex'))) |
77 | #test we can go forward |
78 | self.pointing_device.move_to_object(self.next_button) |
79 | self.pointing_device.click() |
80 | self.assertThat(self.eog_window.title, |
81 | - Eventually(Contains('logo-ubuntu_st_no-black_orange-hex'))) |
82 | - self.pointing_device.click() |
83 | - self.assertThat(self.eog_window.title, |
84 | - Eventually(Contains('logo-ubuntu_st_no-white_orangecof-hex'))) |
85 | - self.pointing_device.click() |
86 | - self.assertThat(self.eog_window.title, |
87 | - Eventually(Contains('logo-ubuntu_su-orange-hex.jpg'))) |
88 | - |
89 | + Eventually(Contains( |
90 | + 'logo-ubuntu_st_no-black_orange-hex'))) |
91 | + self.pointing_device.click() |
92 | + self.assertThat(self.eog_window.title, |
93 | + Eventually(Contains( |
94 | + 'logo-ubuntu_st_no-white_orangecof-hex'))) |
95 | + self.pointing_device.click() |
96 | + self.assertThat(self.eog_window.title, |
97 | + Eventually(Contains( |
98 | + 'logo-ubuntu_su-orange-hex.jpg'))) |
99 | + |
100 | def test_rotate_image(self): |
101 | self.pointing_device.move_to_object(self.normal_size_button) |
102 | self.assertThat(self.status_label.label, Contains('64 pixels')) |
103 | - |
104 | + |
105 | self.pointing_device.move_to_object(self.rotate_left_button) |
106 | self.pointing_device.click() |
107 | - |
108 | - self.assertThat(self.status_label.label, Eventually(Contains('284 pixels'))) |
109 | - |
110 | + |
111 | + self.assertThat(self.status_label.label, |
112 | + Eventually(Contains('284 pixels'))) |
113 | + |
114 | self.pointing_device.move_to_object(self.rotate_right_button) |
115 | self.pointing_device.click() |
116 | - |
117 | - self.assertThat(self.status_label.label, Eventually(Contains('64 pixels'))) |
118 | - |
119 | + |
120 | + self.assertThat(self.status_label.label, |
121 | + Eventually(Contains('64 pixels'))) |
122 | + |
123 | def get_eog_objects(self): |
124 | #----------------------------------------------------------------# |
125 | # EOG WINDOW OBJECT # |
126 | @@ -88,27 +95,26 @@ |
127 | # EOG TOOLBAR OBJECTS # |
128 | # # |
129 | self.eog_toolbar = self.eog_window.select_single('EggEditableToolbar') |
130 | - self.previous_button = self.eog_toolbar.select_single('GtkLabel', |
131 | - label='Previous') |
132 | - self.next_button = self.eog_toolbar.select_single('GtkLabel', |
133 | - label='Next') |
134 | - self.zoom_in_button = self.eog_toolbar.select_single('GtkToolButton', |
135 | - label='In') |
136 | - self.zoom_out_button = self.eog_toolbar.select_single('GtkToolButton', |
137 | - label='Out') |
138 | - self.normal_size_button = self.eog_toolbar.select_single('GtkToolButton', |
139 | - label='Normal') |
140 | - self.fit_window_button = self.eog_toolbar.select_single('GtkToolButton', |
141 | - label='Fit') |
142 | - self.rotate_left_button = self.eog_toolbar.select_single('GtkToolButton', |
143 | - label='Left') |
144 | - self.rotate_right_button = self.eog_toolbar.select_single('GtkToolButton', |
145 | - label='Right') |
146 | - |
147 | + self.previous_button = self.eog_toolbar.select_single( |
148 | + 'GtkLabel', label='Previous') |
149 | + self.next_button = self.eog_toolbar.select_single( |
150 | + 'GtkLabel', label='Next') |
151 | + self.zoom_in_button = self.eog_toolbar.select_single( |
152 | + 'GtkToolButton', label='In') |
153 | + self.zoom_out_button = self.eog_toolbar.select_single( |
154 | + 'GtkToolButton', label='Out') |
155 | + self.normal_size_button = self.eog_toolbar.select_single( |
156 | + 'GtkToolButton', label='Normal') |
157 | + self.fit_window_button = self.eog_toolbar.select_single( |
158 | + 'GtkToolButton', label='Fit') |
159 | + self.rotate_left_button = self.eog_toolbar.select_single( |
160 | + 'GtkToolButton', label='Left') |
161 | + self.rotate_right_button = self.eog_toolbar.select_single( |
162 | + 'GtkToolButton', label='Right') |
163 | + |
164 | #-----------------------------------------------------------------# |
165 | # EOG STATUS BAR OBJECTS # |
166 | # # |
167 | self.eog_statusbar = self.eog_window.select_single('EogStatusbar') |
168 | self.statusbar_frame = self.eog_statusbar.select_single('GtkFrame') |
169 | self.status_label = self.statusbar_frame.select_single('GtkLabel') |
170 | - |
171 | \ No newline at end of file |
172 | |
173 | === modified file 'ubuntu_autopilot_tests/evince/test_evince.py' |
174 | --- ubuntu_autopilot_tests/evince/test_evince.py 2013-07-03 18:56:05 +0000 |
175 | +++ ubuntu_autopilot_tests/evince/test_evince.py 2013-11-23 00:24:47 +0000 |
176 | @@ -7,103 +7,108 @@ |
177 | from time import sleep |
178 | |
179 | import os |
180 | - |
181 | |
182 | - |
183 | |
184 | class EvinceTests(AutopilotTestCase): |
185 | - |
186 | + |
187 | def setUp(self): |
188 | super(EvinceTests, self).setUp() |
189 | self.app = self.launch_test_application('evince') |
190 | |
191 | - self.windowTitle = self.app.select_single('EvWindow') |
192 | - self.prev_button = self.app.select_single('GtkButton', tooltip_text='Go to the previous page') |
193 | - self.next_button = self.app.select_single('GtkButton', tooltip_text='Go to the next page') |
194 | - self.page_num_box = self.app.select_single('GtkBox', tooltip_text='Select Page') |
195 | - self.search_button = self.app.select_single('GtkToggleButton', |
196 | - tooltip_text='Find a word or phrase in the document') |
197 | + self.windowTitle = self.app.select_single( |
198 | + 'EvWindow') |
199 | + self.prev_button = self.app.select_single( |
200 | + 'GtkButton', tooltip_text='Go to the previous page') |
201 | + self.next_button = self.app.select_single( |
202 | + 'GtkButton', tooltip_text='Go to the next page') |
203 | + self.page_num_box = self.app.select_single( |
204 | + 'GtkBox', tooltip_text='Select Page') |
205 | + self.search_button = self.app.select_single( |
206 | + 'GtkToggleButton', |
207 | + tooltip_text='Find a word or phrase in the document') |
208 | self.entry = self.page_num_box.get_children_by_type('GtkEntry')[0] |
209 | self.pointing_device = Pointer(Mouse.create()) |
210 | - |
211 | + |
212 | def test_display_pdf_file(self): |
213 | '''test to view a pdf file''' |
214 | - |
215 | + |
216 | #open the created temp file |
217 | self.open_temp_file() |
218 | - #Grab evince window |
219 | - |
220 | + #Grab evince window |
221 | + |
222 | #test file name is in the window title bar |
223 | - self.assertThat(self.windowTitle.title, Eventually(Contains('EvinceTestPdf.pdf'))) |
224 | + self.assertThat(self.windowTitle.title, |
225 | + Eventually(Contains('EvinceTestPdf.pdf'))) |
226 | # delete the temp file |
227 | - |
228 | + |
229 | def test_changing_pages(self): |
230 | #Lets test we can go up and down the pages |
231 | - |
232 | + |
233 | self.open_temp_file() |
234 | - self.assertThat(self.windowTitle.title, Eventually(Contains('EvinceTestPdf.pdf'))) |
235 | + self.assertThat(self.windowTitle.title, |
236 | + Eventually(Contains('EvinceTestPdf.pdf'))) |
237 | # move to page 2 |
238 | self.pointing_device.move_to_object(self.next_button) |
239 | self.pointing_device.click() |
240 | self.assertThat(self.entry.text, Eventually(Contains('2'))) |
241 | - |
242 | - |
243 | + |
244 | self.pointing_device.move_to_object(self.prev_button) |
245 | self.pointing_device.click() |
246 | - |
247 | + |
248 | self.assertThat(self.entry.text, Eventually(Contains('1'))) |
249 | - |
250 | - |
251 | - |
252 | + |
253 | def test_sidebar_open_close(self): |
254 | #Lets test we can open and close the sidebar |
255 | self.open_temp_file() |
256 | - self.assertThat(self.windowTitle.title, Eventually(Contains('EvinceTestPdf.pdf'))) |
257 | + self.assertThat(self.windowTitle.title, |
258 | + Eventually(Contains('EvinceTestPdf.pdf'))) |
259 | # test opening and closing of sidebar |
260 | self.change_sidebar_state() |
261 | self.change_sidebar_state() |
262 | - |
263 | - |
264 | - |
265 | + |
266 | def test_search_document(self): |
267 | #lets test we can search a document |
268 | self.open_temp_file() |
269 | - self.assertThat(self.windowTitle.title, Eventually(Contains('EvinceTestPdf.pdf'))) |
270 | + self.assertThat(self.windowTitle.title, |
271 | + Eventually(Contains('EvinceTestPdf.pdf'))) |
272 | #click search toggle button |
273 | self.pointing_device.move_to_object(self.search_button) |
274 | self.pointing_device.click() |
275 | # Enter a search query |
276 | self.keyboard.type('Welcome') |
277 | # check it found the the search query |
278 | - self.search_result_label = self.app.select_single('GtkLabel', label='1 found on this page') |
279 | - self.assertThat(self.search_result_label.label, Eventually(Contains('1 found on this page'))) |
280 | - |
281 | - |
282 | - |
283 | + self.search_result_label = self.app.select_single( |
284 | + 'GtkLabel', label='1 found on this page') |
285 | + self.assertThat(self.search_result_label.label, |
286 | + Eventually(Contains('1 found on this page'))) |
287 | + |
288 | def change_sidebar_state(self): |
289 | ''' changes the state of the sidebar and tests that it changed ''' |
290 | # get value of Evsidebar.visible |
291 | self.side_bar = self.app.select_single('EvSidebar') |
292 | visible = self.side_bar.visible |
293 | - # Test and change the side bar, |
294 | + # Test and change the side bar, |
295 | if visible == 1: |
296 | self.keyboard.press_and_release('F9') |
297 | self.assertThat(self.side_bar.visible, Equals(0)) |
298 | else: |
299 | self.keyboard.press_and_release('F9') |
300 | self.assertThat(self.side_bar.visible, Equals(1)) |
301 | - |
302 | + |
303 | def open_temp_file(self): |
304 | '''Opens the EvinceTestPdf.pdf file''' |
305 | # Click on the settings button |
306 | - self.settings_button = self.app.select_single('GtkImage', icon_name='emblem-system-symbolic') |
307 | + self.settings_button = self.app.select_single( |
308 | + 'GtkImage', icon_name='emblem-system-symbolic') |
309 | self.pointing_device.move_to_object(self.settings_button) |
310 | self.pointing_device.click() |
311 | # press 'O' to open the file dialog |
312 | self.keyboard.press_and_release("o") |
313 | - # check the file dialog opened and contains 'Open Document' in the window title |
314 | + # check the file dialog opened and |
315 | + # 'Open Document' is in the window title |
316 | self.open_file_dialog = self.app.select_single('GtkFileChooserDialog') |
317 | - self.assertThat(self.open_file_dialog.title, Eventually(Equals('Open Document'))) |
318 | + self.assertThat(self.open_file_dialog.title, |
319 | + Eventually(Equals('Open Document'))) |
320 | # enter the file name and location |
321 | self.keyboard.press_and_release("Ctrl+a") |
322 | self.keyboard.type('/') |
323 | @@ -117,10 +122,3 @@ |
324 | self.keyboard.type(test_pdf) |
325 | # click on the 'open' button |
326 | self.keyboard.press_and_release('Enter') |
327 | - |
328 | - |
329 | - |
330 | - |
331 | - |
332 | - |
333 | - |
334 | |
335 | === modified file 'ubuntu_autopilot_tests/fileroller/test_fileroller.py' |
336 | --- ubuntu_autopilot_tests/fileroller/test_fileroller.py 2013-05-31 08:54:51 +0000 |
337 | +++ ubuntu_autopilot_tests/fileroller/test_fileroller.py 2013-11-23 00:24:47 +0000 |
338 | @@ -7,6 +7,7 @@ |
339 | import shutil |
340 | import tempfile |
341 | |
342 | + |
343 | class FileRollerTests(AutopilotTestCase): |
344 | '''Collection of autopilot test for file-roller (Archive Manager) ''' |
345 | |
346 | @@ -16,67 +17,78 @@ |
347 | self.app = self.launch_test_application('file-roller') |
348 | |
349 | # only instantiate these once for multiple tests |
350 | - # these can only be instantiated here if you do not need to reload the application during a test |
351 | - # As the Gtk id's change when application is relaunched. and throws error |
352 | - # So for tests that are reloaded also grab new Gtkobject id's after relaunch |
353 | + # these can only be instantiated here if you do not need to reload the |
354 | + # application during a test |
355 | + # As the Gtk ids change when application is relaunched and throws error |
356 | + # So for tests that are reloaded also grab |
357 | + # new Gtkobject id's after relaunch |
358 | self.pointing_device = Pointer(Mouse.create()) |
359 | self.archiveWindow = self.app.select_single('FrWindow') |
360 | - self.add_files_button = self.app.select_single('GtkLabel', label=u'Add Files') |
361 | - self.extract_button = self.app.select_single('GtkLabel', label=u'Extract') |
362 | + self.add_files_button = self.app.select_single('GtkLabel', |
363 | + label=u'Add Files') |
364 | + self.extract_button = self.app.select_single('GtkLabel', |
365 | + label=u'Extract') |
366 | self.open_button = self.app.select_single('GtkLabel', label=u'Open') |
367 | - self.new_archive_button = self.app.select_single('GtkToolButton', name=u'New') |
368 | - |
369 | + self.new_archive_button = self.app.select_single('GtkToolButton', |
370 | + name=u'New') |
371 | + |
372 | def test_create_archive(self): |
373 | - '''Creates an archive and adds sample data, Window title must contain archive name''' |
374 | - |
375 | + '''Creates an archive and adds sample data, |
376 | + Window title must contain archive name''' |
377 | + |
378 | tempArchive = _tempArchiveName() |
379 | #Test: Archive must be created with sample data |
380 | self.create_archive_with_sample_data(tempArchive) |
381 | # If create archive successfull, then check here that the window title |
382 | # is the name of the archive. |
383 | (dirName, fileName) = os.path.split(tempArchive) |
384 | - self.assertThat(self.archiveWindow.title, Eventually(Contains(fileName))) |
385 | - |
386 | + self.assertThat(self.archiveWindow.title, |
387 | + Eventually(Contains(fileName))) |
388 | + |
389 | #Cleanup |
390 | self.delete_temp_archive() |
391 | - |
392 | - |
393 | - |
394 | + |
395 | def test_open_archive(self): |
396 | '''Open archive window title must contains the archive name ''' |
397 | - |
398 | + |
399 | tempArchive = _tempArchiveName() |
400 | - # Call create and relaunch to get a safe way of reloading an application |
401 | + # Call create and relaunch to get |
402 | + # a safe way of reloading an application |
403 | self.create_and_relaunch(tempArchive) |
404 | - |
405 | + |
406 | #Test: Must open archive |
407 | self.open_test_archive(tempArchive) |
408 | # if open archive successful, then check here that the window title |
409 | # is the name of the archive. |
410 | (dirName, fileName) = os.path.split(tempArchive) |
411 | - self.assertThat(self.archiveWindow.title, Eventually(Contains(fileName))) |
412 | + self.assertThat(self.archiveWindow.title, |
413 | + Eventually(Contains(fileName))) |
414 | # Cleanup |
415 | self.delete_temp_archive() |
416 | - |
417 | + |
418 | def test_extract_archive(self): |
419 | '''Open archive and extract file'contents,''' |
420 | - |
421 | + |
422 | tempArchive = _tempArchiveName() |
423 | - # Call create and relaunch to get a safe way of reloading an application |
424 | + # Call create and relaunch to get |
425 | + # a safe way of reloading an application |
426 | self.create_and_relaunch(tempArchive) |
427 | - self.assertThat(self.archiveWindow.title, Eventually(Contains('Archive Manager'))) |
428 | + self.assertThat(self.archiveWindow.title, |
429 | + Eventually(Contains('Archive Manager'))) |
430 | #Test: Open and extract an archive |
431 | self.extract_test_archive(tempArchive) |
432 | ## assert we have come back to main window after extraction |
433 | ## Test Will not get back to mainWindow if extraction failed. |
434 | ## Check window title is same as archive |
435 | (dirName, fileName) = os.path.split(tempArchive) |
436 | - self.assertThat(self.archiveWindow.title, Eventually(Contains(fileName))) |
437 | + self.assertThat(self.archiveWindow.title, |
438 | + Eventually(Contains(fileName))) |
439 | #Cleanup |
440 | self.delete_temp_archive() |
441 | self.delete_temp_directory(fileName) |
442 | - |
443 | - # this method needs some more assertions. At the moment its relying that commands are correct |
444 | + |
445 | + # this method needs some more assertions. |
446 | + # At the moment its relying that commands are correct |
447 | def create_archive_with_sample_data(self, tempArchive): |
448 | ''' Must create archive and add sample data''' |
449 | #Click on the new archive button |
450 | @@ -84,7 +96,8 @@ |
451 | self.pointing_device.click() |
452 | # The new archive dialog window title must have 'New Archive' |
453 | self.new_dialog = self.app.select_single('FrNewArchiveDialog') |
454 | - self.assertThat(self.new_dialog.title, Eventually(Equals(u'New Archive'))) |
455 | + self.assertThat(self.new_dialog.title, |
456 | + Eventually(Equals(u'New Archive'))) |
457 | |
458 | #Enter name of new archive |
459 | self.keyboard.type(tempArchive) |
460 | @@ -92,7 +105,8 @@ |
461 | # TODO: Figure out a gzip commpress, does not have an active Id enabled |
462 | |
463 | # select the create button and check it is clickable |
464 | - self.create_button = self.app.select_single('GtkButton', label=u'create-archive') |
465 | + self.create_button = self.app.select_single('GtkButton', |
466 | + label=u'create-archive') |
467 | self.assertThat(self.create_button.label, Eventually(NotEquals(None))) |
468 | # Click on Create button |
469 | self.pointing_device.move_to_object(self.create_button) |
470 | @@ -102,11 +116,15 @@ |
471 | self.pointing_device.click() |
472 | # The add files dialog title must contain 'Add Files' |
473 | self.add_files_dialog = self.app.select_single('FrFileSelectorDialog') |
474 | - self.assertThat(self.add_files_dialog.title, Eventually(Equals('Add Files'))) |
475 | + self.assertThat(self.add_files_dialog.title, |
476 | + Eventually(Equals('Add Files'))) |
477 | |
478 | - # This is a horrible hacky workaround to add sample files from /usr/share/example-content/* |
479 | - # Need to find a better workaround :S Location GtkEntry doesnt work when entering file path |
480 | - # Maybe add some assertions to check that the Location GTKEntry contains correct path |
481 | + # This is a horrible hacky workaround to add sample |
482 | + # files from /usr/share/example-content/* |
483 | + # Need to find a better workaround :S Location GtkEntry |
484 | + # doesnt work when entering file path |
485 | + # Maybe add some assertions to check that the |
486 | + # Location GTKEntry contains correct path |
487 | self.keyboard.press_and_release("Alt+l") |
488 | self.keyboard.press_and_release("Tab") |
489 | self.keyboard.press_and_release("Tab") |
490 | @@ -125,14 +143,16 @@ |
491 | self.keyboard.press_and_release("Left") |
492 | self.keyboard.press_and_release("Enter") |
493 | # We must be able to click the '_Add' button |
494 | - self.add_folder_button = self.app.select_single('GtkLabel', label=u'_Add') |
495 | - self.assertThat(self.add_folder_button.label, Eventually(NotEquals(None))) |
496 | + self.add_folder_button = self.app.select_single('GtkLabel', |
497 | + label=u'_Add') |
498 | + self.assertThat(self.add_folder_button.label, |
499 | + Eventually(NotEquals(None))) |
500 | #Click the '_Add" button |
501 | self.pointing_device.move_to_object(self.add_folder_button) |
502 | self.pointing_device.click() |
503 | # sleep needed to give sample data enough time to be added |
504 | sleep(10) |
505 | - |
506 | + |
507 | # Method for opening an archive, needs assertions adding |
508 | def open_test_archive(self, tempArchive): |
509 | '''Open the test archive''' |
510 | @@ -142,19 +162,20 @@ |
511 | |
512 | self.keyboard.press_and_release("Alt+l") |
513 | self.keyboard.type(tempArchive) |
514 | - |
515 | |
516 | - self.open_archive_button = self.app.select_single('GtkLabel', label=u'_Open') |
517 | + self.open_archive_button = self.app.select_single( |
518 | + 'GtkLabel', label=u'_Open') |
519 | self.pointing_device.move_to_object(self.open_archive_button) |
520 | self.pointing_device.click() |
521 | |
522 | def extract_test_archive(self, tempArchive): |
523 | '''Open Archive and extract the sample data''' |
524 | - |
525 | + |
526 | self.open_test_archive(tempArchive) |
527 | (dirName, fileName) = os.path.split(tempArchive) |
528 | |
529 | - self.assertThat(self.archiveWindow.title, Eventually(Contains(fileName))) |
530 | + self.assertThat(self.archiveWindow.title, |
531 | + Eventually(Contains(fileName))) |
532 | |
533 | # Check that the Extract button is now clickable |
534 | self.assertThat(self.extract_button.label, Eventually(NotEquals(None))) |
535 | @@ -166,49 +187,60 @@ |
536 | self.keyboard.press_and_release("Alt+l") |
537 | self.keyboard.type(tempArchive) |
538 | |
539 | - self.extract_archive_button = self.app.select_single('GtkLabel', label=u'_Extract') |
540 | - self.assertThat(self.extract_archive_button.label, Eventually(NotEquals(None))) |
541 | + self.extract_archive_button = self.app.select_single( |
542 | + 'GtkLabel', label=u'_Extract') |
543 | + self.assertThat(self.extract_archive_button.label, |
544 | + Eventually(NotEquals(None))) |
545 | |
546 | self.pointing_device.move_to_object(self.extract_archive_button) |
547 | self.pointing_device.click() |
548 | - # need this sleep to give enough time for the GtkDialog time to load before |
549 | - # we can select it |
550 | + # need this sleep to give enough time for the GtkDialog time to load |
551 | + # before we can select it |
552 | sleep(10) |
553 | self.extract_dialog = self.app.select_single('GtkDialog') |
554 | - self.assertThat(self.extract_dialog.title, Eventually(Contains(u""))) |
555 | - self.show_files_button = self.app.select_single('GtkLabel', label=u'_Show the Files') |
556 | - self.assertThat(self.show_files_button.label, Eventually(NotEquals(None))) |
557 | + self.assertThat(self.extract_dialog.title, |
558 | + Eventually(Contains(u""))) |
559 | + self.show_files_button = self.app.select_single( |
560 | + 'GtkLabel', label=u'_Show the Files') |
561 | + self.assertThat(self.show_files_button.label, |
562 | + Eventually(NotEquals(None))) |
563 | |
564 | self.pointing_device.move_to_object(self.show_files_button) |
565 | self.pointing_device.click() |
566 | - # This sleep is needed as we can't introspect nautilus when it shows the files |
567 | + # This sleep is needed as we can't introspect |
568 | + # nautilus when it shows the files |
569 | # TODO: Once nautilus can be introspected we need to lose this sleep |
570 | # and confirm nautilus window title Eventually Contains fileName |
571 | sleep(10) |
572 | |
573 | self.keyboard.press_and_release("Alt+F4") |
574 | - |
575 | + |
576 | def create_and_relaunch(self, tempArchive): |
577 | ''' This method calls create archive_with_sample_data |
578 | - then will close the application and relaunch it |
579 | + then will close the application and relaunch it |
580 | grabbing new Gtk object id's''' |
581 | # Create archive and check window title |
582 | self.create_archive_with_sample_data(tempArchive) |
583 | (dirName, fileName) = os.path.split(tempArchive) |
584 | |
585 | - self.assertThat(self.archiveWindow.title, Eventually(Contains(fileName))) |
586 | + self.assertThat(self.archiveWindow.title, |
587 | + Eventually(Contains(fileName))) |
588 | # Close the Application |
589 | self.keyboard.press_and_release('Ctrl+w') |
590 | # launch a new instance of fire-roller |
591 | self.app = self.launch_test_application('file-roller') |
592 | - # We need to get the new object id's here as we have reloaded the application and |
593 | - # will throw an error unknown id if we don't :) |
594 | + # We need to get the new object id's here as we have reloaded the |
595 | + # application and will throw an error unknown id if we don't :) |
596 | self.archiveWindow = self.app.select_single('FrWindow') |
597 | - self.add_files_button = self.app.select_single('GtkLabel', label=u'Add Files') |
598 | - self.extract_button = self.app.select_single('GtkLabel', label=u'Extract') |
599 | - self.open_button = self.app.select_single('GtkLabel', label=u'Open') |
600 | - self.new_archive_button = self.app.select_single('GtkToolButton', name=u'New') |
601 | - |
602 | + self.add_files_button = self.app.select_single( |
603 | + 'GtkLabel', label=u'Add Files') |
604 | + self.extract_button = self.app.select_single( |
605 | + 'GtkLabel', label=u'Extract') |
606 | + self.open_button = self.app.select_single( |
607 | + 'GtkLabel', label=u'Open') |
608 | + self.new_archive_button = self.app.select_single( |
609 | + 'GtkToolButton', name=u'New') |
610 | + |
611 | def delete_temp_archive(self): |
612 | # Cleanup |
613 | temp = self.archiveWindow.title |
614 | @@ -216,17 +248,16 @@ |
615 | temp = temp.strip() |
616 | path = os.path.join('/tmp/'+temp) |
617 | self.addCleanup(os.unlink, path) |
618 | - |
619 | - def delete_temp_directory(self, fileName ): |
620 | + |
621 | + def delete_temp_directory(self, fileName): |
622 | #Delete the extracted directory |
623 | - extract_path = os.path.join('/tmp/'+ fileName) |
624 | + extract_path = os.path.join('/tmp/' + fileName) |
625 | self.addCleanup(shutil.rmtree, extract_path) |
626 | - |
627 | - |
628 | + |
629 | + |
630 | #hardcoded global archiveName |
631 | def _tempArchiveName(): |
632 | '''Temporary archive name for testing with.''' |
633 | sFile = tempfile.NamedTemporaryFile() |
634 | sFile.close() |
635 | return sFile.name |
636 | - |
637 | |
638 | === modified file 'ubuntu_autopilot_tests/firefox/test_firefox.py' |
639 | --- ubuntu_autopilot_tests/firefox/test_firefox.py 2013-07-17 11:39:59 +0000 |
640 | +++ ubuntu_autopilot_tests/firefox/test_firefox.py 2013-11-23 00:24:47 +0000 |
641 | @@ -1,14 +1,18 @@ |
642 | -#Note: This testcase avoids using introspection because autopilot-gtk fails to introspect firefox properly |
643 | +# Note: This testcase avoids using introspection because autopilot-gtk |
644 | +# fails to introspect firefox properly |
645 | from autopilot.testcase import AutopilotTestCase |
646 | from autopilot.matchers import Eventually |
647 | from testtools.matchers import Equals, Contains |
648 | from autopilot.process import ProcessManager |
649 | |
650 | -#register firefox as an application so we can call it |
651 | -ProcessManager.register_known_application("Firefox", "firefox.desktop", "firefox") |
652 | -#lets force firefox to load jenkins page rather than getting autopilot to type. |
653 | +# register firefox as an application so we can call it |
654 | +ProcessManager.register_known_application( |
655 | + "Firefox", "firefox.desktop", "firefox") |
656 | +# lets force firefox to load jenkins page rather than getting autopilot to |
657 | +# type. |
658 | URLS = ['http://jenkins.qa.ubuntu.com'] |
659 | |
660 | + |
661 | class FirefoxTests(AutopilotTestCase): |
662 | |
663 | def setUp(self): |
664 | @@ -16,81 +20,85 @@ |
665 | self.manager = ProcessManager.create('BAMF') |
666 | self.app = self.manager.start_app_window("Firefox", URLS) |
667 | |
668 | - #make sure firefox is up and loaded |
669 | + # make sure firefox is up and loaded |
670 | self.app.set_focus() |
671 | self.assertTrue(self.app.is_focused) |
672 | |
673 | def test_firefox_works(self): |
674 | - #Test-case name: firefox/fir-001 |
675 | - #This test will check that Firefox can display webpages |
676 | - |
677 | - #check that page title loaded jenkins |
678 | - self.assertThat(lambda: self.app.name, Eventually(Contains("Jenkins"), timeout=30)) |
679 | - |
680 | - #This test will check that Firefox can create tabs and windows |
681 | - self.assertThat(lambda: self.app.name, |
682 | - Eventually(Contains("Jenkins"), timeout=30)) |
683 | - |
684 | - #test fullscreen |
685 | + # Test-case name: firefox/fir-001 |
686 | + # This test will check that Firefox can display webpages |
687 | + |
688 | + # check that page title loaded jenkins |
689 | + self.assertThat(lambda: self.app.name, |
690 | + Eventually(Contains("Jenkins"), timeout=30)) |
691 | + |
692 | + # This test will check that Firefox can create tabs and windows |
693 | + self.assertThat(lambda: self.app.name, |
694 | + Eventually(Contains("Jenkins"), timeout=30)) |
695 | + |
696 | + # test fullscreen |
697 | self.keyboard.press_and_release("F11") |
698 | - |
699 | - #verify fullscreen |
700 | - #Does Firefox enter fullscreen mode? |
701 | + |
702 | + # verify fullscreen |
703 | + # Does Firefox enter fullscreen mode? |
704 | self.assertThat(lambda: self.app._get_window_states(), |
705 | Eventually(Contains("_NET_WM_STATE_FULLSCREEN"))) |
706 | - |
707 | - #go back to normal |
708 | + |
709 | + # go back to normal |
710 | self.keyboard.press_and_release("F11") |
711 | - |
712 | - |
713 | - #open new tab |
714 | + |
715 | + # open new tab |
716 | self.keyboard.press_and_release("Ctrl+t") |
717 | - |
718 | - #check that page title reflects new tab |
719 | - self.assertThat(lambda: self.app.name, Eventually(Equals("Mozilla Firefox"))) |
720 | - |
721 | - #close new tab |
722 | + |
723 | + # check that page title reflects new tab |
724 | + self.assertThat(lambda: self.app.name, |
725 | + Eventually(Equals("Mozilla Firefox"))) |
726 | + |
727 | + # close new tab |
728 | self.keyboard.press_and_release("Ctrl+w") |
729 | - #check we are back to one tab |
730 | - self.assertThat(lambda: self.app.name, Eventually(Contains("Jenkins"))) |
731 | - |
732 | - #open new window |
733 | - originalWindowCount = len(self.manager.get_open_windows_by_application("Firefox")) |
734 | + # check we are back to one tab |
735 | + self.assertThat(lambda: self.app.name, |
736 | + Eventually(Contains("Jenkins"))) |
737 | + |
738 | + # open new window |
739 | + originalWindowCount = len( |
740 | + self.manager.get_open_windows_by_application("Firefox")) |
741 | self.keyboard.press_and_release("Ctrl+n") |
742 | - |
743 | - #check that we spawned a new window; we use window count so this works even if you have firefox already running (shouldn't happen in a sterile labe enviroment however) |
744 | - self.assertThat(lambda: len(self.manager.get_open_windows_by_application("Firefox")), |
745 | - Eventually(Equals(originalWindowCount + 1))) |
746 | - |
747 | - #close window |
748 | + |
749 | + # check that we spawned a new window; we use window count so this works |
750 | + # even if you have firefox already running |
751 | + # (shouldn't happen in a sterile labe enviroment however) |
752 | + self.assertThat( |
753 | + lambda: len( |
754 | + self.manager.get_open_windows_by_application("Firefox")), |
755 | + Eventually(Equals(originalWindowCount + 1))) |
756 | + |
757 | + # close window |
758 | self.keyboard.press_and_release("Ctrl+w") |
759 | - #check we have gone back to one window |
760 | - self.assertThat(lambda: len(self.manager.get_open_windows_by_application("Firefox")), |
761 | - Eventually(Equals(originalWindowCount))) |
762 | - |
763 | - |
764 | - #Test-case name: firefox/fir-002 |
765 | - #This test will check that Firefox can display search suggestions |
766 | - |
767 | - #open search box, switch to google |
768 | + # check we have gone back to one window |
769 | + self.assertThat(lambda: len( |
770 | + self.manager.get_open_windows_by_application("Firefox")), |
771 | + Eventually(Equals(originalWindowCount))) |
772 | + |
773 | + # Test-case name: firefox/fir-002 |
774 | + # This test will check that Firefox can display search suggestions |
775 | + |
776 | + # open search box, switch to google |
777 | self.keyboard.press_and_release("Ctrl+k") |
778 | self.keyboard.press_and_release("F4") |
779 | self.keyboard.press_and_release("g") |
780 | - |
781 | - #search for ubuntu server docs |
782 | + |
783 | + # search for ubuntu server docs |
784 | self.keyboard.type("ubuntu server docs") |
785 | - |
786 | - #ensure we have a generated list of suggestions |
787 | - #WE CAN'T DO THIS :-( |
788 | - |
789 | - #go to results page |
790 | + |
791 | + # ensure we have a generated list of suggestions |
792 | + # WE CAN'T DO THIS :-( |
793 | + |
794 | + # go to results page |
795 | self.keyboard.type("\n") |
796 | - |
797 | - #check results by looking at page title |
798 | + |
799 | + # check results by looking at page title |
800 | self.assertThat(lambda: self.app.name, Eventually(Contains("Google"))) |
801 | - |
802 | - self.assertThat(lambda: self.app.name, Eventually(Contains("server docs"))) |
803 | - |
804 | - |
805 | - |
806 | - |
807 | + |
808 | + self.assertThat(lambda: self.app.name, |
809 | + Eventually(Contains("server docs"))) |
810 | |
811 | === modified file 'ubuntu_autopilot_tests/gedit/__init__.py' |
812 | --- ubuntu_autopilot_tests/gedit/__init__.py 2013-08-13 18:51:02 +0000 |
813 | +++ ubuntu_autopilot_tests/gedit/__init__.py 2013-11-23 00:24:47 +0000 |
814 | @@ -17,7 +17,8 @@ |
815 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
816 | from autopilot.testcase import AutopilotTestCase |
817 | from autopilot.matchers import Eventually |
818 | -from testtools.matchers import Equals, NotEquals, Contains, FileExists, FileContains |
819 | +from testtools.matchers import Equals, NotEquals, Contains, FileExists, \ |
820 | + FileContains |
821 | from autopilot.input import Pointer, Mouse |
822 | import tempfile |
823 | import os |
824 | @@ -29,55 +30,67 @@ |
825 | super(GeditAutopilotTestCase, self).setUp() |
826 | self.app = self.launch_test_application("gedit") |
827 | self.pointing_device = Pointer(Mouse.create()) |
828 | - |
829 | - def setup_test_docs(self,num_of_docs,text=False, |
830 | - tab_num=1,save_dlg=False, |
831 | - opn_dlg=False,replace_dlg=False, |
832 | - print_dlg=False,print_preview=False): |
833 | - """ This function sets up the pre-reqs for a test |
834 | - |
835 | - Using a combination of these params you can set up different |
836 | - situations for testing |
837 | - |
838 | - params: |
839 | - num_of_docs: *Required* an int value of the number of docs |
840 | - needed for the test |
841 | - text=: Set to False by default if set to true will add text |
842 | - to each document. |
843 | - tab_num=: Sets the tab focus to the given tab number on setup. |
844 | - Set to 1 by default |
845 | - save_dlg=: If set to True Sets the save dialog up in the |
846 | - gedit/samples directory for the test |
847 | - opn_dlg=: If set to True sets the open dialog up for test |
848 | - print_dlg=: If set to True sets the print dialog up for printing to a file |
849 | - print_preview=: If set to True sets the Print preview dialog up for testing |
850 | + |
851 | + def setup_test_docs(self, num_of_docs, text=False, |
852 | + tab_num=1, save_dlg=False, |
853 | + opn_dlg=False, replace_dlg=False, |
854 | + print_dlg=False, print_preview=False): |
855 | + """ |
856 | + This function sets up the pre-reqs for a test |
857 | + |
858 | + Using a combination of these params you can set up different |
859 | + situations for testing |
860 | + |
861 | + params: |
862 | + num_of_docs: *Required* an int value of the number of docs |
863 | + needed for the test |
864 | + text=: Set to False by default if set to true will add text |
865 | + to each document. |
866 | + tab_num=: Sets the tab focus to the given tab number on setup. |
867 | + Set to 1 by default |
868 | + save_dlg=: If set to True Sets the save dialog up in the |
869 | + gedit/samples directory for the test |
870 | + opn_dlg=: If set to True sets the open dialog up for test |
871 | + print_dlg=: If set to True sets the print |
872 | + dialog up for printing to a file |
873 | + print_preview=: If set to True sets the Print preview |
874 | + dialog up for testing |
875 | """ |
876 | # gedit by default loads a blank document |
877 | # so start num at 1 |
878 | num = 1 |
879 | txt = text |
880 | - |
881 | - if txt == True: |
882 | + |
883 | + if txt is True: |
884 | view = self.app.select_single('GeditView') |
885 | self.assertThat(view.is_focus, Equals(1)) |
886 | - self.keyboard.type('Document %s: The quick brown fox jumps over the lazy dog' % str(num)) |
887 | - |
888 | - self.assertThat(view.buffer, |
889 | - Equals('Document %s: The quick brown fox jumps over the lazy dog' % str(num)), |
890 | - "Autopilot mis-typed the phrase") |
891 | - |
892 | + self.keyboard.type( |
893 | + 'Document %s: The quick brown fox jumps over the lazy dog' |
894 | + % str(num)) |
895 | + |
896 | + self.assertThat( |
897 | + view.buffer, |
898 | + Equals( |
899 | + 'Document %s: The quick brown fox jumps over the lazy dog' |
900 | + % str(num)), |
901 | + "Autopilot mis-typed the phrase") |
902 | + |
903 | while num < num_of_docs: |
904 | self.keyboard.press_and_release('Ctrl+n') |
905 | - num +=1 |
906 | - if txt == True: |
907 | + num += 1 |
908 | + if txt is True: |
909 | view = self.app.select_many('GeditView')[num - 1] |
910 | self.assertThat(view.is_focus, Equals(1)) |
911 | - self.keyboard.type('Document %s: The quick brown fox jumps over the lazy dog' % str(num)) |
912 | - |
913 | - self.assertThat(view.buffer, |
914 | - Equals('Document %s: The quick brown fox jumps over the lazy dog' % str(num)), |
915 | - "Autopilot mis-typed the phrase") |
916 | - |
917 | + self.keyboard.type( |
918 | + 'Document %s: The quick brown fox jumps over the lazy dog' |
919 | + % str(num)) |
920 | + |
921 | + self.assertThat( |
922 | + view.buffer, |
923 | + Equals( |
924 | + 'Document %s: The quick brown fox jumps \ |
925 | + over the lazy dog' % str(num)), |
926 | + "Autopilot mis-typed the phrase") |
927 | |
928 | # lets just check we have the right amount of tabs |
929 | num_of_tabs = len(self.app.select_many('GeditView')) |
930 | @@ -90,65 +103,83 @@ |
931 | view = self.app.select_many('GeditView')[tab_num - 1] |
932 | self.assertThat(view.is_focus, Eventually(Equals(1)), |
933 | "We are not on the correct tab") |
934 | - if save_dlg == True: |
935 | + if save_dlg is True: |
936 | self.pointing_device.click_object( |
937 | - self.app.select_single('GtkToolButton', |
938 | - name='FileSave')) |
939 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
940 | - Eventually(Equals(1)), "The save dialog did not open") |
941 | + self.app.select_single('GtkToolButton', |
942 | + name='FileSave')) |
943 | + self.assertThat( |
944 | + lambda: self.app.select_single( |
945 | + 'GeditFileChooserDialog').visible, |
946 | + Eventually(Equals(1)), "The save dialog did not open") |
947 | dlg = self.app.select_single('GeditFileChooserDialog') |
948 | - |
949 | - self.pointing_device.click_object(dlg.select_single('GtkFileChooserEntry')) |
950 | - self.assertThat(lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
951 | - Eventually(Equals(1)), |
952 | - "Entry did not get focus after being clicked") |
953 | + |
954 | + self.pointing_device.click_object( |
955 | + dlg.select_single('GtkFileChooserEntry')) |
956 | + self.assertThat( |
957 | + lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
958 | + Eventually(Equals(1)), |
959 | + "Entry did not get focus after being clicked") |
960 | self.keyboard.press_and_release('Ctrl+a') |
961 | self.keyboard.press_and_release('Delete') |
962 | - #lets make sure we always save in /tmp |
963 | + # lets make sure we always save in /tmp |
964 | self.keyboard.type('/tmp/') |
965 | self.keyboard.press_and_release('Enter') |
966 | - |
967 | - if opn_dlg == True: |
968 | + |
969 | + if opn_dlg is True: |
970 | self.pointing_device.click_object( |
971 | self.app.select_single('GeditOpenToolButton')) |
972 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
973 | - Eventually(Equals(1)), "file chooser dialog did not open") |
974 | + self.assertThat( |
975 | + lambda: self.app.select_single( |
976 | + 'GeditFileChooserDialog').visible, |
977 | + Eventually(Equals(1)), "file chooser dialog did not open") |
978 | dlg = self.app.select_single('GeditFileChooserDialog') |
979 | self.keyboard.press_and_release('/') |
980 | - self.assertThat(lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
981 | - Eventually(Equals(1)), |
982 | - "Entry did not get focus after being clicked") |
983 | - #lets make sure we are in our samples dir |
984 | + self.assertThat( |
985 | + lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
986 | + Eventually(Equals(1)), |
987 | + "Entry did not get focus after being clicked") |
988 | + # lets make sure we are in our samples dir |
989 | sample_dir = 'samples' |
990 | for root, dirs, files in os.walk(os.getcwd()): |
991 | for name in dirs: |
992 | if name == sample_dir: |
993 | dir_path = os.path.abspath(os.path.join(root, name)) |
994 | - self.keyboard.type(dir_path+"/") |
995 | - |
996 | - if replace_dlg == True: |
997 | + self.keyboard.type(dir_path + "/") |
998 | + |
999 | + if replace_dlg is True: |
1000 | self.pointing_device.click_object( |
1001 | self.app.select_single('GtkToolButton', |
1002 | name='SearchReplace')) |
1003 | - self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
1004 | - Eventually(Equals(1)), |
1005 | - "Replace dialog did not open") |
1006 | - #lets grab all the objects we might need in the test |
1007 | + self.assertThat( |
1008 | + lambda: self.app.select_single('GeditReplaceDialog').visible, |
1009 | + Eventually(Equals(1)), |
1010 | + "Replace dialog did not open") |
1011 | + # lets grab all the objects we might need in the test |
1012 | self.rep_dialog = self.app.select_single('GeditReplaceDialog') |
1013 | - self.mtch_chkbtn = self.rep_dialog.select_single(BuilderName='match_case_checkbutton') |
1014 | - self.entire_chkbtn = self.rep_dialog.select_single(BuilderName='entire_word_checkbutton') |
1015 | - self.srch_bk_chkbtn = self.rep_dialog.select_single(BuilderName='search_backwards_checkbutton') |
1016 | - self.wrp_chkbtn = self.rep_dialog.select_single(BuilderName='wrap_around_checkbutton') |
1017 | - self.find_button = self.rep_dialog.select_single('GtkLabel', label='_Find') |
1018 | - self.replace_button = self.rep_dialog.select_single('GtkLabel', label='_Replace') |
1019 | - self.replace_all_button = self.rep_dialog.select_single('GtkLabel', label='Replace _All') |
1020 | - self.close_button = self.rep_dialog.select_single('GtkLabel', label='_Close') |
1021 | - self.search_entry = self.rep_dialog.select_single('GeditHistoryEntry', history_id='search-for-entry') |
1022 | - self.search_entry_text = self.search_entry.select_single('GtkEntry') |
1023 | - self.replace_entry = self.rep_dialog.select_single('GeditHistoryEntry', history_id='replace-with-entry') |
1024 | - self.replace_entry_text = self.replace_entry.select_single('GtkEntry') |
1025 | - #now lets select the search entry |
1026 | + self.mtch_chkbtn = self.rep_dialog.select_single( |
1027 | + BuilderName='match_case_checkbutton') |
1028 | + self.entire_chkbtn = self.rep_dialog.select_single( |
1029 | + BuilderName='entire_word_checkbutton') |
1030 | + self.srch_bk_chkbtn = self.rep_dialog.select_single( |
1031 | + BuilderName='search_backwards_checkbutton') |
1032 | + self.wrp_chkbtn = self.rep_dialog.select_single( |
1033 | + BuilderName='wrap_around_checkbutton') |
1034 | + self.find_button = self.rep_dialog.select_single( |
1035 | + 'GtkLabel', label='_Find') |
1036 | + self.replace_button = self.rep_dialog.select_single( |
1037 | + 'GtkLabel', label='_Replace') |
1038 | + self.replace_all_button = self.rep_dialog.select_single( |
1039 | + 'GtkLabel', label='Replace _All') |
1040 | + self.close_button = self.rep_dialog.select_single( |
1041 | + 'GtkLabel', label='_Close') |
1042 | + self.search_entry = self.rep_dialog.select_single( |
1043 | + 'GeditHistoryEntry', history_id='search-for-entry') |
1044 | + self.search_entry_text = self.search_entry.select_single( |
1045 | + 'GtkEntry') |
1046 | + self.replace_entry = self.rep_dialog.select_single( |
1047 | + 'GeditHistoryEntry', history_id='replace-with-entry') |
1048 | + self.replace_entry_text = self.replace_entry.select_single( |
1049 | + 'GtkEntry') |
1050 | + # now lets select the search entry |
1051 | self.pointing_device.click_object(self.search_entry) |
1052 | - #we are all set for the test now |
1053 | - |
1054 | - |
1055 | \ No newline at end of file |
1056 | + # we are all set for the test now |
1057 | |
1058 | === modified file 'ubuntu_autopilot_tests/gedit/samples/gedit.py' |
1059 | --- ubuntu_autopilot_tests/gedit/samples/gedit.py 2013-08-13 08:03:51 +0000 |
1060 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.py 2013-11-23 00:24:47 +0000 |
1061 | @@ -2,5 +2,5 @@ |
1062 | |
1063 | string = "Hello Autopilot\n" |
1064 | if re.search(r"[^abc]", string): |
1065 | - print (string + " contains a character other than " +\ |
1066 | - "a, b, and c") |
1067 | \ No newline at end of file |
1068 | + print (string + " contains a character other than " + |
1069 | + "a, b, and c") |
1070 | |
1071 | === modified file 'ubuntu_autopilot_tests/gedit/test_gedit.py' |
1072 | --- ubuntu_autopilot_tests/gedit/test_gedit.py 2013-08-14 17:03:26 +0000 |
1073 | +++ ubuntu_autopilot_tests/gedit/test_gedit.py 2013-11-23 00:24:47 +0000 |
1074 | @@ -18,7 +18,8 @@ |
1075 | from autopilot.matchers import Eventually |
1076 | from testtools import ExpectedException |
1077 | from testtools.content import Content, ContentType |
1078 | -from testtools.matchers import Equals, NotEquals, Contains, FileExists, FileContains, LessThan, DirExists |
1079 | +from testtools.matchers import Equals, NotEquals, Contains, \ |
1080 | + FileExists, FileContains, LessThan, DirExists |
1081 | from gedit import GeditAutopilotTestCase |
1082 | from autopilot.testcase import AutopilotTestCase |
1083 | import subprocess |
1084 | @@ -27,6 +28,7 @@ |
1085 | import time |
1086 | import shutil |
1087 | |
1088 | + |
1089 | class GeditKeyboardShortcutTests(GeditAutopilotTestCase): |
1090 | |
1091 | def test_close_tab(self, ): |
1092 | @@ -34,51 +36,53 @@ |
1093 | # setup 2 blank documents |
1094 | self.setup_test_docs(2) |
1095 | num_before = len(self.app.select_many('GeditView')) |
1096 | - #close tab |
1097 | + # close tab |
1098 | self.keyboard.press_and_release('Ctrl+w') |
1099 | - #did it close? |
1100 | + # did it close? |
1101 | num_after = len(self.app.select_many('GeditView')) |
1102 | self.assertThat(num_after, |
1103 | Equals(num_before - 1), |
1104 | - "Tab did not close correctly: %s tabs were still open"\ |
1105 | - %str(num_after)) |
1106 | + "Tab did not close correctly: %s tabs were still open" |
1107 | + % str(num_after)) |
1108 | |
1109 | def test_save_all_document_shortcut(self, ): |
1110 | """ Using shortcut Ctrl+Shift+l, test the save dialog appears """ |
1111 | # create a 3 docs with some text so we can save |
1112 | self.setup_test_docs(3, text=True) |
1113 | self.keyboard.press_and_release('Ctrl+s') |
1114 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1115 | - Eventually(Equals(1)), |
1116 | - "Save dialog did not open") |
1117 | + self.assertThat( |
1118 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1119 | + Eventually(Equals(1)), |
1120 | + "Save dialog did not open") |
1121 | |
1122 | def test_close_all_tabs_shortcut(self, ): |
1123 | """ Using shortcut Ctrl+Shift+W """ |
1124 | self.setup_test_docs(3) |
1125 | # close all windows |
1126 | self.keyboard.press_and_release('Ctrl+Shift+w') |
1127 | - #check there are no tabs |
1128 | + # check there are no tabs |
1129 | tabs = len(self.app.select_many('GeditTab')) |
1130 | - self.assertThat(tabs, Equals(0), |
1131 | - "Not all tabs closed: %s tabs were still open"%str(tabs)) |
1132 | + self.assertThat( |
1133 | + tabs, Equals(0), |
1134 | + "Not all tabs closed: %s tabs were still open" % str(tabs)) |
1135 | |
1136 | def test_jump_to_nth_tab_shortcut(self, ): |
1137 | """ Using shortcut Alt+n """ |
1138 | self.setup_test_docs(3) |
1139 | # jump to tab 3 |
1140 | self.keyboard.press_and_release('Alt+3') |
1141 | - #check we are on tab 3 (index 2) |
1142 | + # check we are on tab 3 (index 2) |
1143 | self.assertThat(lambda: self.app.select_many('GeditView')[2].is_focus, |
1144 | Eventually(Equals(1)), "Tab 3 did not get focus") |
1145 | |
1146 | def test_create_new_document_shortcut(self, ): |
1147 | """ Using shortcut Ctrl+N """ |
1148 | - #check that only the default tab is there |
1149 | + # check that only the default tab is there |
1150 | num_tabs = len(self.app.select_many('GeditView')) |
1151 | self.assertThat(num_tabs, Equals(1)) |
1152 | # create new document |
1153 | self.keyboard.press_and_release('Ctrl+n') |
1154 | - #test new document is there and visible |
1155 | + # test new document is there and visible |
1156 | self.assertThat(num_tabs, Equals(1)) |
1157 | self.assertThat(lambda: self.app.select_many('GeditView')[1].is_focus, |
1158 | Eventually(Equals(1)), "New document was not created") |
1159 | @@ -86,119 +90,140 @@ |
1160 | def test_open_file_shortcut(self, ): |
1161 | """ Using shortcut Ctrl+o, test the file chooser dialog appears """ |
1162 | self.keyboard.press_and_release('Ctrl+o') |
1163 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1164 | - Eventually(Equals(1)), "file chooser dialog did not open") |
1165 | + self.assertThat( |
1166 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1167 | + Eventually(Equals(1)), "file chooser dialog did not open") |
1168 | |
1169 | def test_save_document_shortcut(self, ): |
1170 | """ Using shortcut Ctrl+s, test the save dialog appears """ |
1171 | # create a doc with some text so we can save |
1172 | self.setup_test_docs(1, text=True) |
1173 | self.keyboard.press_and_release('Ctrl+s') |
1174 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1175 | - Eventually(Equals(1)), "The save dialog did not open") |
1176 | + self.assertThat( |
1177 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1178 | + Eventually(Equals(1)), "The save dialog did not open") |
1179 | |
1180 | def test_save_as_shortcut(self, ): |
1181 | """ Using shortcut Ctrl+Shift+s, test the save as dialog appears """ |
1182 | self.setup_test_docs(1, text=True) |
1183 | self.keyboard.press_and_release('Ctrl+Shift+s') |
1184 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1185 | - Eventually(Equals(1)), "The save dialog did not open") |
1186 | + self.assertThat( |
1187 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1188 | + Eventually(Equals(1)), "The save dialog did not open") |
1189 | |
1190 | def test_print_document_shortcut(self, ): |
1191 | """ Using shortcut Ctrl+p, test the print dialog appears """ |
1192 | self.setup_test_docs(1, text=True) |
1193 | self.keyboard.press_and_release('Ctrl+p') |
1194 | - self.assertThat(lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
1195 | - Eventually(Equals(1)), "The print dialog did not open") |
1196 | + self.assertThat( |
1197 | + lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
1198 | + Eventually(Equals(1)), "The print dialog did not open") |
1199 | |
1200 | def test_print_preview_shortcut(self, ): |
1201 | """ Using shortcut Ctrl+Shift+p, test the print preview appears """ |
1202 | self.setup_test_docs(1, text=True) |
1203 | self.keyboard.press_and_release('Ctrl+Shift+p') |
1204 | - self.assertThat(lambda: self.app.select_single('GeditPrintPreview').visible, |
1205 | - Eventually(Equals(1)), "The print preview window did not open") |
1206 | + self.assertThat( |
1207 | + lambda: self.app.select_single('GeditPrintPreview').visible, |
1208 | + Eventually(Equals(1)), "The print preview window did not open") |
1209 | |
1210 | def test_home_key_moves_to_beginning_of_line(self, ): |
1211 | """ Using the 'Home' Key test we go to beginning of line """ |
1212 | self.setup_test_docs(1, text=True) |
1213 | self.keyboard.press_and_release('Home') |
1214 | - #lets delete the first letter in the buffer |
1215 | + # lets delete the first letter in the buffer |
1216 | self.keyboard.press_and_release('Delete') |
1217 | - #Lets check we went to beginning and deleted 'D' |
1218 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1219 | - Eventually( |
1220 | - Equals('ocument 1: The quick brown fox jumps over the lazy dog')), |
1221 | - "Home key did not go to beginning of line") |
1222 | + # Lets check we went to beginning and deleted 'D' |
1223 | + self.assertThat( |
1224 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1225 | + Eventually( |
1226 | + Equals( |
1227 | + 'ocument 1: The quick brown fox jumps over the lazy dog')), |
1228 | + "Home key did not go to beginning of line") |
1229 | |
1230 | def test_end_key_goes_to_end_of_line(self, ): |
1231 | """ Using the 'End' Key test we go to end of line """ |
1232 | self.setup_test_docs(1, text=True) |
1233 | self.keyboard.press_and_release('Home') |
1234 | - #lets delete the first letter in the buffer |
1235 | + # lets delete the first letter in the buffer |
1236 | self.keyboard.press_and_release('Delete') |
1237 | - #Lets check we went to beginning and deleted 'T' |
1238 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1239 | - Eventually( |
1240 | - Equals('ocument 1: The quick brown fox jumps over the lazy dog'))) |
1241 | + # Lets check we went to beginning and deleted 'T' |
1242 | + self.assertThat( |
1243 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1244 | + Eventually( |
1245 | + Equals( |
1246 | + 'ocument 1: The quick brown fox jumps over the lazy dog'))) |
1247 | self.keyboard.press_and_release('End') |
1248 | self.keyboard.type('s') |
1249 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1250 | - Eventually( |
1251 | - Equals('ocument 1: The quick brown fox jumps over the lazy dogs')), |
1252 | - "Either the 'End' key did not work or autopilot \ |
1253 | - mis-typed 's': manual compare needed") |
1254 | + self.assertThat( |
1255 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1256 | + Eventually( |
1257 | + Equals( |
1258 | + 'ocument 1: The quick brown fox jumps over the lazy dogs') |
1259 | + ), |
1260 | + "Either the 'End' key did not work or autopilot \ |
1261 | + mis-typed 's': manual compare needed") |
1262 | |
1263 | def test_undo_shortcut(self, ): |
1264 | """ Using shortcut Ctrl+z, test that we undo last action """ |
1265 | self.setup_test_docs(1, text=True) |
1266 | self.keyboard.press_and_release('Ctrl+z') |
1267 | - #Lets check we were able to undo the last word |
1268 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1269 | - Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
1270 | - "Last word in phrase was not undone") |
1271 | + # Lets check we were able to undo the last word |
1272 | + self.assertThat( |
1273 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1274 | + Eventually( |
1275 | + Equals( |
1276 | + 'Document 1: The quick brown fox jumps over the lazy ')), |
1277 | + "Last word in phrase was not undone") |
1278 | |
1279 | def test_redo_shortcut(self, ): |
1280 | - """ Using shortcut Ctrl+Shift+z, test we can redo last undone action """ |
1281 | + """Using shortcut Ctrl+Shift+z, test we can redo last undone action""" |
1282 | self.setup_test_docs(1, text=True) |
1283 | self.keyboard.press_and_release('Ctrl+z') |
1284 | - #Lets undo the last word |
1285 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1286 | - Eventually( |
1287 | - Equals('Document 1: The quick brown fox jumps over the lazy ')), |
1288 | - "Last word in phrase was not undone") |
1289 | + # Lets undo the last word |
1290 | + self.assertThat( |
1291 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1292 | + Eventually( |
1293 | + Equals( |
1294 | + 'Document 1: The quick brown fox jumps over the lazy ')), |
1295 | + "Last word in phrase was not undone") |
1296 | self.keyboard.press_and_release('Ctrl+Shift+z') |
1297 | - #Lets check we were able to redo the last word |
1298 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1299 | - Eventually( |
1300 | - Equals('Document 1: The quick brown fox jumps over the lazy dog')), |
1301 | - "Redo shortcut did not redo the last word in phrase") |
1302 | + # Lets check we were able to redo the last word |
1303 | + self.assertThat( |
1304 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1305 | + Eventually( |
1306 | + Equals( |
1307 | + 'Document 1: The quick brown fox jumps over the lazy dog') |
1308 | + ), "Redo shortcut did not redo the last word in phrase") |
1309 | |
1310 | def test_copy_and_paste_shortcuts(self, ): |
1311 | """ Using shortcuts Ctrl+c & Ctrl+v test we can copy and paste text """ |
1312 | self.setup_test_docs(1, text=True) |
1313 | self.keyboard.press_and_release('Ctrl+a') |
1314 | - #copy text |
1315 | + # copy text |
1316 | self.keyboard.press_and_release('Ctrl+c') |
1317 | self.keyboard.press_and_release('Right') |
1318 | # now paste |
1319 | self.keyboard.press_and_release('Ctrl+v') |
1320 | # did it copy and paste correctly? |
1321 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1322 | - Eventually( |
1323 | - Equals( |
1324 | - 'Document 1: The quick brown fox jumps over the lazy dogDocument 1: The quick brown fox jumps over the lazy dog' |
1325 | - )), |
1326 | - "Three possible reasons for fail: \ |
1327 | - 1) Ctrl+a did not select text, \ |
1328 | - 2) Ctrl+c did not copy text or \ |
1329 | - 3) Ctrl+v did not paste text") |
1330 | + self.assertThat( |
1331 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1332 | + Eventually( |
1333 | + Equals( |
1334 | + 'Document 1: The quick brown fox jumps over the lazy dog\ |
1335 | + Document 1: The quick brown fox jumps over the lazy dog' |
1336 | + )), |
1337 | + "Three possible reasons for fail: \ |
1338 | + 1) Ctrl+a did not select text, \ |
1339 | + 2) Ctrl+c did not copy text or \ |
1340 | + 3) Ctrl+v did not paste text") |
1341 | |
1342 | def test_cut_shortcut(self, ): |
1343 | """ Using shortcut Ctrl+x test we can cut text """ |
1344 | self.setup_test_docs(1, text=True) |
1345 | self.keyboard.press_and_release('Ctrl+a') |
1346 | self.keyboard.press_and_release('Ctrl+x') |
1347 | - #test it cut the selected text |
1348 | + # test it cut the selected text |
1349 | self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1350 | Eventually(Equals('')), |
1351 | "Two possible reasons for fail: \ |
1352 | @@ -211,19 +236,20 @@ |
1353 | # Since this closes the application and we lose the proxy |
1354 | # before we can test its gone, we can expect the exception to |
1355 | # assert gedit quit |
1356 | - with ExpectedException(RuntimeError, |
1357 | - "Application under test exited before the test finished!"): |
1358 | + with ExpectedException( |
1359 | + RuntimeError, |
1360 | + "Application under test exited before the test finished!"): |
1361 | gedit = self.app.select_single('GeditWindow') |
1362 | self.assertTrue(gedit, Equals(None)) |
1363 | |
1364 | def test_sidebar_shortcut(self, ): |
1365 | """ Using F9 key test side panel opens/closes """ |
1366 | - #test opening panel |
1367 | + # test opening panel |
1368 | self.keyboard.press_and_release('F9') |
1369 | self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
1370 | Eventually(Equals(1)), |
1371 | "Side panel did not open after pressing F9") |
1372 | - #and close panel |
1373 | + # and close panel |
1374 | self.keyboard.press_and_release('F9') |
1375 | self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
1376 | Eventually(Equals(0)), |
1377 | @@ -231,51 +257,55 @@ |
1378 | |
1379 | def test_find_a_string_shortcut(self, ): |
1380 | """ Using shortcut Ctrl+f test we can search for string """ |
1381 | - #Ctrl+f |
1382 | + # Ctrl+f |
1383 | self.setup_test_docs(1, text=True) |
1384 | self.keyboard.press_and_release('Ctrl+f') |
1385 | self.keyboard.type('fox\n') |
1386 | - #lets delete the highlighted word |
1387 | + # lets delete the highlighted word |
1388 | self.keyboard.press_and_release('Delete') |
1389 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1390 | - Eventually( |
1391 | - Equals('Document 1: The quick brown jumps over the lazy dog')), |
1392 | - "fox was not highlighted and removed from phrase") |
1393 | + self.assertThat( |
1394 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1395 | + Eventually( |
1396 | + Equals( |
1397 | + 'Document 1: The quick brown jumps over the lazy dog')), |
1398 | + "fox was not highlighted and removed from phrase") |
1399 | |
1400 | - #TODO: |
1401 | - #def test_find_next_instance_of_string_shortcut(self, ): |
1402 | + # TODO: |
1403 | + # def test_find_next_instance_of_string_shortcut(self, ): |
1404 | # pass |
1405 | # |
1406 | - #def test_find_previous_instance_of_string_shortcut(self, ): |
1407 | + # def test_find_previous_instance_of_string_shortcut(self, ): |
1408 | # pass |
1409 | |
1410 | def test_search_and_replace_shortcut(self, ): |
1411 | """ Using shortcut Ctrl+h test the replace dialog opens """ |
1412 | self.keyboard.press_and_release('Ctrl+h') |
1413 | - self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
1414 | - Eventually(Equals(1)), |
1415 | - "Replace dialog did not open") |
1416 | - #TODO: |
1417 | - #def test_clear_highlighted_text_shortcut(self, ): |
1418 | - # #Ctrl+Shift+k |
1419 | + self.assertThat( |
1420 | + lambda: self.app.select_single('GeditReplaceDialog').visible, |
1421 | + Eventually(Equals(1)), |
1422 | + "Replace dialog did not open") |
1423 | + # TODO: |
1424 | + # def test_clear_highlighted_text_shortcut(self, ): |
1425 | + # Ctrl+Shift+k |
1426 | # pass |
1427 | # |
1428 | - #def test_go_to_line_shortcut(self, ): |
1429 | - # #Ctrl+i |
1430 | + # def test_go_to_line_shortcut(self, ): |
1431 | + # Ctrl+i |
1432 | # pass |
1433 | |
1434 | -class GeditWindowTests(GeditAutopilotTestCase): |
1435 | + |
1436 | +class GeditWindowTests(GeditAutopilotTestCase): |
1437 | |
1438 | def test_new_document_button(self, ): |
1439 | """ Test new doc button creates a new document """ |
1440 | - #check that only the default tab is there |
1441 | + # check that only the default tab is there |
1442 | num_tabs = len(self.app.select_many('GeditView')) |
1443 | self.assertThat(num_tabs, Equals(1)) |
1444 | # create new document |
1445 | self.pointing_device.click_object( |
1446 | self.app.select_single('GtkToolButton', |
1447 | name='FileNew')) |
1448 | - #test new document is there and visible |
1449 | + # test new document is there and visible |
1450 | self.assertThat(num_tabs, Equals(1)) |
1451 | self.assertThat(lambda: self.app.select_many('GeditView')[1].is_focus, |
1452 | Eventually(Equals(1)), "New document was not created") |
1453 | @@ -284,8 +314,9 @@ |
1454 | """ Using open button, test the file chooser dialog appears """ |
1455 | self.pointing_device.click_object( |
1456 | self.app.select_single('GeditOpenToolButton')) |
1457 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1458 | - Eventually(Equals(1)), "file chooser dialog did not open") |
1459 | + self.assertThat( |
1460 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1461 | + Eventually(Equals(1)), "file chooser dialog did not open") |
1462 | |
1463 | def test_save_document_button(self, ): |
1464 | """ Using save button, test the save dialog appears """ |
1465 | @@ -294,8 +325,9 @@ |
1466 | self.pointing_device.click_object( |
1467 | self.app.select_single('GtkToolButton', |
1468 | name='FileSave')) |
1469 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1470 | - Eventually(Equals(1)), "The save dialog did not open") |
1471 | + self.assertThat( |
1472 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1473 | + Eventually(Equals(1)), "The save dialog did not open") |
1474 | |
1475 | def test_print_document_button(self, ): |
1476 | """ Using print button, test the print dialog opens """ |
1477 | @@ -303,8 +335,9 @@ |
1478 | self.pointing_device.click_object( |
1479 | self.app.select_single('GtkToolButton', |
1480 | name='FilePrint')) |
1481 | - self.assertThat(lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
1482 | - Eventually(Equals(1)), "The print dialog did not open") |
1483 | + self.assertThat( |
1484 | + lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
1485 | + Eventually(Equals(1)), "The print dialog did not open") |
1486 | |
1487 | def test_undo_button(self, ): |
1488 | """ Test undo button, undoes last action """ |
1489 | @@ -312,10 +345,13 @@ |
1490 | self.pointing_device.click_object( |
1491 | self.app.select_single('GtkToolButton', |
1492 | name='EditUndo')) |
1493 | - #Lets check we were able to undo the last word |
1494 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1495 | - Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
1496 | - "Last word in phrase was not undone") |
1497 | + # Lets check we were able to undo the last word |
1498 | + self.assertThat( |
1499 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1500 | + Eventually( |
1501 | + Equals( |
1502 | + 'Document 1: The quick brown fox jumps over the lazy ')), |
1503 | + "Last word in phrase was not undone") |
1504 | |
1505 | def test_redo_button(self, ): |
1506 | """ Test redo button, redoes the last undo action """ |
1507 | @@ -323,17 +359,23 @@ |
1508 | self.pointing_device.click_object( |
1509 | self.app.select_single('GtkToolButton', |
1510 | name='EditUndo')) |
1511 | - #Lets check we were able to undo the last word |
1512 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1513 | - Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
1514 | - "Last word in phrase was not undone") |
1515 | - self.pointing_device.click_object(self.app.select_single('GtkToolButton', |
1516 | - name='EditRedo')) |
1517 | - #Lets check we were able to redo the last word |
1518 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1519 | - Eventually( |
1520 | - Equals('Document 1: The quick brown fox jumps over the lazy dog')), |
1521 | - "Redo shortcut did not redo the last word in phrase") |
1522 | + # Lets check we were able to undo the last word |
1523 | + self.assertThat( |
1524 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1525 | + Eventually( |
1526 | + Equals( |
1527 | + 'Document 1: The quick brown fox jumps over the lazy ')), |
1528 | + "Last word in phrase was not undone") |
1529 | + self.pointing_device.click_object( |
1530 | + self.app.select_single('GtkToolButton', |
1531 | + name='EditRedo')) |
1532 | + # Lets check we were able to redo the last word |
1533 | + self.assertThat( |
1534 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1535 | + Eventually( |
1536 | + Equals( |
1537 | + 'Document 1: The quick brown fox jumps over the lazy dog') |
1538 | + ), "Redo shortcut did not redo the last word in phrase") |
1539 | |
1540 | def test_cut_button(self, ): |
1541 | """ Test the cut button cuts the selected text """ |
1542 | @@ -342,7 +384,7 @@ |
1543 | self.pointing_device.click_object( |
1544 | self.app.select_single('GtkToolButton', |
1545 | name='EditCut')) |
1546 | - #test it cut the selected text |
1547 | + # test it cut the selected text |
1548 | self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1549 | Eventually(Equals('')), |
1550 | "Two possible reasons for fail: \ |
1551 | @@ -353,7 +395,7 @@ |
1552 | """ test we can copy and paste using buttons """ |
1553 | self.setup_test_docs(1, text=True) |
1554 | self.keyboard.press_and_release('Ctrl+a') |
1555 | - #copy text |
1556 | + # copy text |
1557 | self.pointing_device.click_object( |
1558 | self.app.select_single('GtkToolButton', |
1559 | name='EditCopy')) |
1560 | @@ -363,15 +405,17 @@ |
1561 | self.app.select_single('GtkToolButton', |
1562 | name='EditPaste')) |
1563 | # did it copy and paste correctly? |
1564 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1565 | - Eventually( |
1566 | - Equals( |
1567 | - 'Document 1: The quick brown fox jumps over the lazy dogDocument 1: The quick brown fox jumps over the lazy dog' |
1568 | - )), |
1569 | - "Three possible reasons for fail: \ |
1570 | - 1) Ctrl+a did not select text, \ |
1571 | - 2) Copy button did not work or \ |
1572 | - 3) Paste button did not work") |
1573 | + self.assertThat( |
1574 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1575 | + Eventually( |
1576 | + Equals( |
1577 | + 'Document 1: The quick brown fox jumps over the lazy dog\ |
1578 | + Document 1: The quick brown fox jumps over the lazy dog' |
1579 | + )), |
1580 | + "Three possible reasons for fail: \ |
1581 | + 1) Ctrl+a did not select text, \ |
1582 | + 2) Copy button did not work or \ |
1583 | + 3) Paste button did not work") |
1584 | |
1585 | def test_search_button(self, ): |
1586 | """ Test the search button opens the search box """ |
1587 | @@ -380,21 +424,24 @@ |
1588 | self.app.select_single('GtkToolButton', |
1589 | name='SearchFind')) |
1590 | self.keyboard.type('fox\n') |
1591 | - #lets delete the highlighted word |
1592 | + # lets delete the highlighted word |
1593 | self.keyboard.press_and_release('Delete') |
1594 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1595 | - Eventually( |
1596 | - Equals('Document 1: The quick brown jumps over the lazy dog')), |
1597 | - "fox was not highlighted and removed from phrase") |
1598 | + self.assertThat( |
1599 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1600 | + Eventually( |
1601 | + Equals( |
1602 | + 'Document 1: The quick brown jumps over the lazy dog')), |
1603 | + "fox was not highlighted and removed from phrase") |
1604 | |
1605 | def test_search_and_replace_button(self, ): |
1606 | """ Test the replace button opens the replace dialog """ |
1607 | self.pointing_device.click_object( |
1608 | self.app.select_single('GtkToolButton', |
1609 | name='SearchReplace')) |
1610 | - self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
1611 | - Eventually(Equals(1)), |
1612 | - "Replace dialog did not open") |
1613 | + self.assertThat( |
1614 | + lambda: self.app.select_single('GeditReplaceDialog').visible, |
1615 | + Eventually(Equals(1)), |
1616 | + "Replace dialog did not open") |
1617 | |
1618 | def test_window_visible(self, ): |
1619 | """ Test the window loads """ |
1620 | @@ -415,65 +462,66 @@ |
1621 | |
1622 | # CAN WE ACCESS THE BOTTOM COMBOBOX'S???????????? |
1623 | |
1624 | + |
1625 | class GeditSidebarTests(GeditAutopilotTestCase): |
1626 | |
1627 | def test_close_sidebar_button(self, ): |
1628 | - #open panel |
1629 | + # open panel |
1630 | self.keyboard.press_and_release('F9') |
1631 | self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
1632 | Eventually(Equals(1)), |
1633 | "Side panel did not open after pressing F9") |
1634 | - #and close panel using button |
1635 | + # and close panel using button |
1636 | self.pointing_device.click_object( |
1637 | self.app.select_many('GeditCloseButton')[0]) |
1638 | self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
1639 | Eventually(Equals(0)), |
1640 | "Side panel did not close after clicking close button") |
1641 | |
1642 | - #TODO: add more maybe test file browser tab and its button objects |
1643 | + # TODO: add more maybe test file browser tab and its button objects |
1644 | |
1645 | |
1646 | class GeditSaveFileTypeTests(GeditAutopilotTestCase): |
1647 | - |
1648 | + |
1649 | scenarios = [ |
1650 | - ('single_char', {'input': "a"}), |
1651 | - ('short_name', {'input': "test"}), |
1652 | - ('long_name', {'input': "testfilenameforgedit"}), |
1653 | - ('extra_long_name', {'input': "autopilotlongfilenamefortesting"}), |
1654 | - ('python_file', {'input': "gedit.py"}), |
1655 | - ('C_file', {'input': "gedit.c"}), |
1656 | - ('cpp_file', {'input': "gedit.cpp"}), |
1657 | - ('xml_file', {'input': "gedit.xml"}), |
1658 | - ('vala_file', {'input': "gedit.vala"}), |
1659 | - ('html_file', {'input': "gedit.html"}), |
1660 | - ] |
1661 | - |
1662 | + ('single_char', {'input': "a"}), |
1663 | + ('short_name', {'input': "test"}), |
1664 | + ('long_name', {'input': "testfilenameforgedit"}), |
1665 | + ('extra_long_name', {'input': "autopilotlongfilenamefortesting"}), |
1666 | + ('python_file', {'input': "gedit.py"}), |
1667 | + ('C_file', {'input': "gedit.c"}), |
1668 | + ('cpp_file', {'input': "gedit.cpp"}), |
1669 | + ('xml_file', {'input': "gedit.xml"}), |
1670 | + ('vala_file', {'input': "gedit.vala"}), |
1671 | + ('html_file', {'input': "gedit.html"}), |
1672 | + ] |
1673 | + |
1674 | def test_save_file_type_tests(self, ): |
1675 | - #setup test with empty doc and save dialog opened |
1676 | + # setup test with empty doc and save dialog opened |
1677 | self.setup_test_docs(1, save_dlg=True) |
1678 | save_dlg = self.app.select_single('GeditFileChooserDialog') |
1679 | self.pointing_device.move_to_object( |
1680 | save_dlg.select_single('GtkLabel', |
1681 | label='_Cancel')) |
1682 | - #for each scenario enter filename |
1683 | + # for each scenario enter filename |
1684 | self.keyboard.type(self.input) |
1685 | - #click save |
1686 | - |
1687 | + # click save |
1688 | + |
1689 | self.pointing_device.click_object( |
1690 | save_dlg.select_single('GtkLabel', label='_Save')) |
1691 | - #check dialog closed before checking for file |
1692 | + # check dialog closed before checking for file |
1693 | self.assertThat(lambda: self.app.select_many('GeditTab')[0].name, |
1694 | Eventually(Equals(self.input)), |
1695 | - "Tab did not contain filename "+self.input) |
1696 | + "Tab did not contain filename " + self.input) |
1697 | filename = self.input |
1698 | - |
1699 | - self.assertThat('/tmp/'+filename, FileExists()) |
1700 | - #add cleanup |
1701 | + |
1702 | + self.assertThat('/tmp/' + filename, FileExists()) |
1703 | + # add cleanup |
1704 | self.addCleanup(os.remove, '/tmp/%s' % self.input) |
1705 | - |
1706 | - |
1707 | + |
1708 | + |
1709 | class GeditSaveDialogTests(GeditAutopilotTestCase): |
1710 | - |
1711 | + |
1712 | def test_esc_key_closes_dialog(self, ): |
1713 | self.setup_test_docs(1, save_dlg=True) |
1714 | self.keyboard.press_and_release('Escape') |
1715 | @@ -482,9 +530,9 @@ |
1716 | "'NoneType' object has no attribute 'visible'"): |
1717 | self.assertThat(lambda: self.app.select_single( |
1718 | 'GeditFileChooserDialog').visible, |
1719 | - Eventually(Equals(0)), |
1720 | - "Dialog didn't close") |
1721 | - |
1722 | + Eventually(Equals(0)), |
1723 | + "Dialog didn't close") |
1724 | + |
1725 | def test_cancel_button_closes_dialog(self, ): |
1726 | self.setup_test_docs(1, save_dlg=True) |
1727 | save_dialog = self.app.select_single('GeditFileChooserDialog') |
1728 | @@ -496,9 +544,9 @@ |
1729 | "'NoneType' object has no attribute 'visible'"): |
1730 | self.assertThat(lambda: self.app.select_single( |
1731 | 'GeditFileChooserDialog').visible, |
1732 | - Eventually(Equals(0)), |
1733 | - "Dialog didn't close") |
1734 | - |
1735 | + Eventually(Equals(0)), |
1736 | + "Dialog didn't close") |
1737 | + |
1738 | def test_new_folder_button(self, ): |
1739 | self.setup_test_docs(1, save_dlg=True) |
1740 | save_dialog = self.app.select_single('GeditFileChooserDialog') |
1741 | @@ -509,6 +557,7 @@ |
1742 | self.assertThat('/tmp/test_folder', DirExists()) |
1743 | self.addCleanup(os.rmdir, '/tmp/test_folder') |
1744 | |
1745 | + |
1746 | class GeditOpenFileTypesTests(GeditAutopilotTestCase): |
1747 | scenarios = [ |
1748 | ('test_file', {'input': "test"}), |
1749 | @@ -518,7 +567,7 @@ |
1750 | ('vala_file', {'input': "gedit.vala"}), |
1751 | ('xml_file', {'input': "gedit.xml"}), |
1752 | ] |
1753 | - |
1754 | + |
1755 | def test_open_file_type_tests(self, ): |
1756 | self.setup_test_docs(1, opn_dlg=True) |
1757 | self.keyboard.type(self.input) |
1758 | @@ -527,29 +576,31 @@ |
1759 | label='_Open')) |
1760 | self.assertThat(lambda: self.app.select_single('GeditWindow').title, |
1761 | Eventually(Contains(self.input))) |
1762 | - |
1763 | - |
1764 | + |
1765 | + |
1766 | class GeditOpenDialogTests(GeditAutopilotTestCase): |
1767 | - |
1768 | + |
1769 | def test_esc_key_closes_dialog(self, ): |
1770 | self.pointing_device.click_object( |
1771 | self.app.select_single('GeditOpenToolButton')) |
1772 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1773 | - Eventually(Equals(1)), "file chooser dialog did not open") |
1774 | + self.assertThat( |
1775 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1776 | + Eventually(Equals(1)), "file chooser dialog did not open") |
1777 | self.keyboard.press_and_release('Escape') |
1778 | # The fact we can't select dialog shows it closed |
1779 | with ExpectedException(AttributeError, |
1780 | "'NoneType' object has no attribute 'visible'"): |
1781 | self.assertThat(lambda: self.app.select_single( |
1782 | 'GeditFileChooserDialog').visible, |
1783 | - Eventually(Equals(0)), |
1784 | - "Dialog didn't close") |
1785 | - |
1786 | + Eventually(Equals(0)), |
1787 | + "Dialog didn't close") |
1788 | + |
1789 | def test_cancel_button_closes_dialog(self, ): |
1790 | self.pointing_device.click_object( |
1791 | self.app.select_single('GeditOpenToolButton')) |
1792 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1793 | - Eventually(Equals(1)), "file chooser dialog did not open") |
1794 | + self.assertThat( |
1795 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1796 | + Eventually(Equals(1)), "file chooser dialog did not open") |
1797 | open_dialog = self.app.select_single('GeditFileChooserDialog') |
1798 | self.pointing_device.click_object( |
1799 | open_dialog.select_single('GtkLabel', |
1800 | @@ -559,19 +610,20 @@ |
1801 | "'NoneType' object has no attribute 'visible'"): |
1802 | self.assertThat(lambda: self.app.select_single( |
1803 | 'GeditFileChooserDialog').visible, |
1804 | - Eventually(Equals(0)), |
1805 | - "Dialog didn't close") |
1806 | - |
1807 | + Eventually(Equals(0)), |
1808 | + "Dialog didn't close") |
1809 | + |
1810 | def test_recent_docs_displayed_on_load(self, ): |
1811 | self.pointing_device.click_object( |
1812 | self.app.select_single('GeditOpenToolButton')) |
1813 | - self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1814 | - Eventually(Equals(1)), "file chooser dialog did not open") |
1815 | + self.assertThat( |
1816 | + lambda: self.app.select_single('GeditFileChooserDialog').visible, |
1817 | + Eventually(Equals(1)), "file chooser dialog did not open") |
1818 | open_dialog = self.app.select_single('GeditFileChooserDialog') |
1819 | - self.assertThat(lambda: open_dialog.select_single('GtkLabel', |
1820 | - label='<b>Recently Used</b>').visible, |
1821 | - Eventually(Equals(1)), "Recently used not visible") |
1822 | - |
1823 | + self.assertThat(lambda: open_dialog.select_single( |
1824 | + 'GtkLabel', label='<b>Recently Used</b>').visible, |
1825 | + Eventually(Equals(1)), "Recently used not visible") |
1826 | + |
1827 | |
1828 | class GeditReplaceDialogTests(GeditAutopilotTestCase): |
1829 | |
1830 | @@ -583,78 +635,93 @@ |
1831 | self.keyboard.type('foxes') |
1832 | self.assertTrue(self.replace_entry_text.text, Equals('foxes')) |
1833 | self.pointing_device.click_object(self.find_button) |
1834 | - #lets check replace button is now clickable |
1835 | + # lets check replace button is now clickable |
1836 | self.assertThat(self.replace_button.sensitive, Eventually(Equals(1))) |
1837 | self.pointing_device.click_object(self.replace_button) |
1838 | - #test text was replaced |
1839 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1840 | - Eventually(Equals('Document 1: The quick brown foxes jumps over the lazy dog'))) |
1841 | - |
1842 | + # test text was replaced |
1843 | + self.assertThat( |
1844 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1845 | + Eventually(Equals( |
1846 | + 'Document 1: The quick brown foxes jumps over the lazy dog'))) |
1847 | + |
1848 | def test_match_case_option(self, ): |
1849 | # test doesnt match |
1850 | self.setup_test_docs(1, text=True, replace_dlg=True) |
1851 | self.keyboard.type('Fox') |
1852 | self.assertTrue(self.search_entry_text.text, Equals('Fox')) |
1853 | self.pointing_device.click_object(self.mtch_chkbtn) |
1854 | - #check its selected |
1855 | + # check its selected |
1856 | self.assertTrue(self.mtch_chkbtn.active, Equals(1)) |
1857 | self.pointing_device.click_object(self.replace_all_button) |
1858 | - #FIXME: |
1859 | - #the replace button should stay inactive as it doesn't match case |
1860 | - #for some reason it says the sensitive property is 1 but in vis shows 0 |
1861 | - #self.assertThat(self.replace_button.sensitive, Equals(0)) |
1862 | - #instead click replace all and check fox was not replaced in the buffer |
1863 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1864 | - Eventually(Equals('Document 1: The quick brown fox jumps over the lazy dog'))) |
1865 | - #test does match |
1866 | + # FIXME: |
1867 | + # the replace button should stay inactive as it doesn't match entire |
1868 | + # word for some reason it says the sensitive property is 1 but in vis |
1869 | + # shows 0 |
1870 | + # self.pointing_device.click_object(self.find_button) |
1871 | + # self.assertThat(self.replace_button.sensitive, Equals(0)) |
1872 | + # instead click replace all and check fox was not replaced in the |
1873 | + # buffer |
1874 | + self.assertThat( |
1875 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1876 | + Eventually(Equals( |
1877 | + 'Document 1: The quick brown fox jumps over the lazy dog'))) |
1878 | + # test does match |
1879 | self.pointing_device.click_object(self.search_entry) |
1880 | self.keyboard.press_and_release('Ctrl+a') |
1881 | self.keyboard.type('fox') |
1882 | self.pointing_device.click_object(self.replace_all_button) |
1883 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1884 | - Eventually(Equals('Document 1: The quick brown jumps over the lazy dog'))) |
1885 | - |
1886 | + self.assertThat( |
1887 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1888 | + Eventually(Equals( |
1889 | + 'Document 1: The quick brown jumps over the lazy dog'))) |
1890 | + |
1891 | def test_match_entire_word_option(self, ): |
1892 | self.setup_test_docs(1, text=True, replace_dlg=True) |
1893 | self.keyboard.type('fo') |
1894 | self.assertTrue(self.search_entry_text.text, Equals('fo')) |
1895 | self.pointing_device.click_object(self.entire_chkbtn) |
1896 | - #check its selected |
1897 | + # check its selected |
1898 | self.assertTrue(self.entire_chkbtn.active, Equals(1)) |
1899 | - #FIXME: |
1900 | - #the replace button should stay inactive as it doesn't match entire word |
1901 | - #for some reason it says the sensitive property is 1 but in vis shows 0 |
1902 | - #self.pointing_device.click_object(self.find_button) |
1903 | - #self.assertThat(self.replace_button.sensitive, Equals(0)) |
1904 | - #instead click replace all and check fox was not replaced in the buffer |
1905 | + # FIXME: |
1906 | + # the replace button should stay inactive as it doesn't match entire |
1907 | + # word for some reason it says the sensitive property is 1 but in vis |
1908 | + # shows 0 |
1909 | + # self.pointing_device.click_object(self.find_button) |
1910 | + # self.assertThat(self.replace_button.sensitive, Equals(0)) |
1911 | + # instead click replace all and check fox was not replaced in the |
1912 | + # buffer |
1913 | self.pointing_device.click_object(self.replace_all_button) |
1914 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1915 | - Eventually(Equals('Document 1: The quick brown fox jumps over the lazy dog'))) |
1916 | - #test does match |
1917 | + self.assertThat( |
1918 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1919 | + Eventually(Equals( |
1920 | + 'Document 1: The quick brown fox jumps over the lazy dog'))) |
1921 | + # test does match |
1922 | self.pointing_device.click_object(self.search_entry) |
1923 | self.keyboard.press_and_release('Ctrl+a') |
1924 | self.keyboard.type('fox') |
1925 | self.pointing_device.click_object(self.replace_all_button) |
1926 | - self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
1927 | - Eventually(Equals('Document 1: The quick brown jumps over the lazy dog'))) |
1928 | - |
1929 | + self.assertThat( |
1930 | + lambda: self.app.select_many('GeditView')[0].buffer, |
1931 | + Eventually(Equals( |
1932 | + 'Document 1: The quick brown jumps over the lazy dog'))) |
1933 | + |
1934 | def test_esc_key_closes_dialog(self, ): |
1935 | self.setup_test_docs(1, replace_dlg=True) |
1936 | self.keyboard.press_and_release('Escape') |
1937 | self.assertThat(lambda: self.app.select_single( |
1938 | 'GeditReplaceDialog').visible, |
1939 | - Eventually(Equals(0)),"Dialog didn't close") |
1940 | - |
1941 | + Eventually(Equals(0)), "Dialog didn't close") |
1942 | + |
1943 | def test_close_button_closes_dialog(self, ): |
1944 | self.setup_test_docs(1, replace_dlg=True) |
1945 | self.pointing_device.click_object(self.close_button) |
1946 | self.assertThat(lambda: self.app.select_single( |
1947 | 'GeditReplaceDialog').visible, |
1948 | - Eventually(Equals(0)),"Dialog didn't close") |
1949 | - |
1950 | + Eventually(Equals(0)), "Dialog didn't close") |
1951 | + |
1952 | |
1953 | class GeditSingleFileCommandLineTest(AutopilotTestCase): |
1954 | - |
1955 | + |
1956 | def setUp(self): |
1957 | super(GeditSingleFileCommandLineTest, self).setUp() |
1958 | sample_file = 'test' |
1959 | @@ -663,15 +730,15 @@ |
1960 | if name == sample_file: |
1961 | file_path = os.path.abspath(os.path.join(root, name)) |
1962 | self.gedit = self.launch_test_application("gedit", file_path) |
1963 | - |
1964 | - #can we open files in gedit from terminal |
1965 | + |
1966 | + # can we open files in gedit from terminal |
1967 | def test_open_single_file(self, ): |
1968 | self.assertThat(lambda: self.gedit.select_single('GeditWindow').title, |
1969 | Eventually(Contains('test'))) |
1970 | |
1971 | |
1972 | class GeditMultiFileCommandLineTest(AutopilotTestCase): |
1973 | - |
1974 | + |
1975 | def setUp(self): |
1976 | super(GeditMultiFileCommandLineTest, self).setUp() |
1977 | sample_dir = 'samples' |
1978 | @@ -680,45 +747,48 @@ |
1979 | if name == sample_dir: |
1980 | file_path = os.path.abspath(os.path.join(root, name)) |
1981 | self.gedit = self.launch_test_application("gedit", |
1982 | - file_path+'/test', |
1983 | - file_path+'/gedit.py', |
1984 | - file_path+'/gedit.c', |
1985 | - file_path+'/gedit.vala') |
1986 | - |
1987 | + file_path + '/test', |
1988 | + file_path + '/gedit.py', |
1989 | + file_path + '/gedit.c', |
1990 | + file_path + '/gedit.vala') |
1991 | + |
1992 | def test_open_multi_files(self, ): |
1993 | - |
1994 | - #the first opened doc 'tab 1' should be in the title |
1995 | + |
1996 | + # the first opened doc 'tab 1' should be in the title |
1997 | self.assertThat(lambda: self.gedit.select_single('GeditWindow').title, |
1998 | Eventually(Contains('test'))) |
1999 | - #check 4 tabs are there |
2000 | + # check 4 tabs are there |
2001 | self.assertThat(len(self.gedit.select_many('GeditTab')), Equals(4)) |
2002 | - #TODO: test the contents of the files are diplayed |
2003 | + # TODO: test the contents of the files are diplayed |
2004 | # but is this needed? as tab title is covered by |
2005 | # another test and so is file contents displayed |
2006 | |
2007 | + |
2008 | class GeditCommandLineTests(AutopilotTestCase): |
2009 | - |
2010 | + |
2011 | def setUp(self): |
2012 | super(GeditCommandLineTests, self).setUp() |
2013 | self.app = self.launch_test_application("gedit") |
2014 | - |
2015 | - |
2016 | + |
2017 | def test_new_doc_arg(self, ): |
2018 | - #check window open with one tab |
2019 | + # check window open with one tab |
2020 | self.assertThat(lambda: self.app.select_single('GeditWindow').visible, |
2021 | Eventually(Equals(1))) |
2022 | self.assertThat(len(self.app.select_many('GeditTab')), Equals(1)) |
2023 | - #now lets use the --new-document argument and we should get another tab |
2024 | + # now lets use the --new-document argument and we should get another |
2025 | + # tab |
2026 | subprocess.check_call(["gedit", "--new-document"]) |
2027 | - self.assertThat(lambda: self.app.select_many('GeditTab')[1].visible, Eventually(Equals(1))) |
2028 | + self.assertThat(lambda: self.app.select_many( |
2029 | + 'GeditTab')[1].visible, Eventually(Equals(1))) |
2030 | |
2031 | def test_new_window_arg(self, ): |
2032 | self.assertThat(lambda: self.app.select_single('GeditWindow').visible, |
2033 | Eventually(Equals(1))) |
2034 | - #now lets use the --new-window argument and we should get another window |
2035 | + # now lets use the --new-window argument and we should get another |
2036 | + # window |
2037 | |
2038 | subprocess.check_call(["gedit", "--new-window"]) |
2039 | self.assertThat(lambda: self.app.select_many('GeditWindow')[1].visible, |
2040 | Eventually(Equals(1))) |
2041 | - #lets just confirm we have 2 windows |
2042 | + # lets just confirm we have 2 windows |
2043 | self.assertThat(len(self.app.select_many('GeditWindow')), Equals(2)) |
2044 | |
2045 | === modified file 'ubuntu_autopilot_tests/nautilus/test_nautilus.py' |
2046 | --- ubuntu_autopilot_tests/nautilus/test_nautilus.py 2013-05-27 11:24:25 +0000 |
2047 | +++ ubuntu_autopilot_tests/nautilus/test_nautilus.py 2013-11-23 00:24:47 +0000 |
2048 | @@ -6,10 +6,13 @@ |
2049 | import os |
2050 | from time import sleep |
2051 | |
2052 | -#Register Nautilus as an application so we can call it |
2053 | -ProcessManager.register_known_application("File Browser", "nautilus.desktop", "nautilus") |
2054 | - |
2055 | -#http://packages.qa.ubuntu.com/qatracker/testcases/1424/info |
2056 | +# Register Nautilus as an application so we can call it |
2057 | +ProcessManager.register_known_application( |
2058 | + "File Browser", "nautilus.desktop", "nautilus") |
2059 | + |
2060 | +# http://packages.qa.ubuntu.com/qatracker/testcases/1424/info |
2061 | + |
2062 | + |
2063 | class NautilusTests(AutopilotTestCase): |
2064 | |
2065 | def setUp(self): |
2066 | @@ -17,37 +20,38 @@ |
2067 | self.proc_manager = ProcessManager.create('BAMF') |
2068 | self.app = self.proc_manager.start_app_window("File Browser") |
2069 | |
2070 | - #This will make sure nautilus window you launched is focused and ready to accept your keyboard input |
2071 | + # This will make sure nautilus window you launched is focused and ready |
2072 | + # to accept your keyboard input |
2073 | self.app.set_focus() |
2074 | - #We need to assert the window title = Home here to keep focus of nautilus. # |
2075 | - #It fails with assertTrue(self.app.is_focused) |
2076 | + # We must assert the window title = Home here to keep focus of nautilus |
2077 | + # It fails with assertTrue(self.app.is_focused) |
2078 | self.assertThat(lambda: self.app.title, Eventually(Contains('Home'))) |
2079 | |
2080 | - |
2081 | def test_create_a_folder(self): |
2082 | - #Test-case name: nautilus/TC-NFM-002 |
2083 | - #This test will check that user can create folders in Nautilus |
2084 | + # Test-case name: nautilus/TC-NFM-002 |
2085 | + # This test will check that user can create folders in Nautilus |
2086 | |
2087 | - #Select tmp folder |
2088 | + # Select tmp folder |
2089 | self.keyboard.press_and_release("Ctrl+l") |
2090 | self.keyboard.type('/tmp/') |
2091 | self.keyboard.press_and_release('Enter') |
2092 | - #make new folder |
2093 | - tempName=_generateTempFileName() |
2094 | + # make new folder |
2095 | + tempName = _generateTempFileName() |
2096 | (dirName, fileName) = os.path.split(tempName) |
2097 | self.keyboard.press_and_release("Ctrl+Shift+n") |
2098 | - #use the generated filename as folder name in this case |
2099 | + # use the generated filename as folder name in this case |
2100 | self.keyboard.type(fileName) |
2101 | self.keyboard.press_and_release('Enter') |
2102 | self.keyboard.press_and_release('Enter') |
2103 | - #verify folder |
2104 | + # verify folder |
2105 | self.assertThat(lambda: self.app.title, Eventually(Contains(fileName))) |
2106 | |
2107 | - #delete folder |
2108 | + # delete folder |
2109 | self.addCleanup(os.rmdir, tempName) |
2110 | |
2111 | + |
2112 | def _generateTempFileName(): |
2113 | - #Create temporary file, then close it, so we can re-use the file name |
2114 | + # Create temporary file, then close it, so we can re-use the file name |
2115 | sFile = tempfile.NamedTemporaryFile() |
2116 | sFile.close() |
2117 | return sFile.name |
2118 | |
2119 | === modified file 'ubuntu_autopilot_tests/screenshot/test_screenshot.py' |
2120 | --- ubuntu_autopilot_tests/screenshot/test_screenshot.py 2013-06-07 19:03:36 +0000 |
2121 | +++ ubuntu_autopilot_tests/screenshot/test_screenshot.py 2013-11-23 00:24:47 +0000 |
2122 | @@ -9,7 +9,9 @@ |
2123 | import os |
2124 | import shutil |
2125 | |
2126 | -#http://packages.qa.ubuntu.com/qatracker/testcases/1421/info |
2127 | +# http://packages.qa.ubuntu.com/qatracker/testcases/1421/info |
2128 | + |
2129 | + |
2130 | class ScreenshotTests(AutopilotTestCase): |
2131 | |
2132 | def setUp(self): |
2133 | @@ -20,160 +22,192 @@ |
2134 | self.pointing_device = Pointer(Mouse.create()) |
2135 | self.archiveWindow = self.app.select_single('GtkDialog') |
2136 | |
2137 | - #verify window title: Take Screenshot to verify Screenshot is correclty opened |
2138 | - self.assertThat(self.archiveWindow.title, Eventually(Contains('Take Screenshot'))) |
2139 | - |
2140 | - self.take_screenshot_button = self.app.select_single('GtkLabel', label='Take _Screenshot') |
2141 | - self.grab_whole_screen_rb = self.app.select_single('GtkRadioButton', label='Grab the whole sc_reen') |
2142 | - self.grab_curr_window_rb = self.app.select_single('GtkRadioButton', label='Grab the current _window') |
2143 | - self.select_grab_area_rb=self.app.select_single('GtkRadioButton', label='Select _area to grab') |
2144 | - self.incl_win_border=self.app.select_single('GtkCheckButton', label='Include the window _border') |
2145 | -## self.drop_shadow_effect_shadow=self.app.select_single('GtkComboBoxAccessible', accessible_name='shadow') |
2146 | -## self.drop_shadow_effect_none=self.app.select_single('GtkComboBoxAccessible', accessible_name='none') |
2147 | -## self.drop_shadow_effect_border=self.app.select_single('GtkComboBoxAccessible', accessible_name='border') |
2148 | - |
2149 | - #potentially useful objects |
2150 | - #self.border_effect=self.app.select_single('GtkComboBoxAccessible', accessible_name='border') |
2151 | - #self.no_effect=self.app.select_single('GtkComboBoxAccessible', accessible_name='none') |
2152 | - #self.app.select_single('GtkLabel', label='Grab after a _delay of') |
2153 | - #self.app.select_single('GtkCheckButton', label='Include _pointer') |
2154 | - #self.app.select_single('GtkToggleButtonAccessible', accessible_name='Include pointer') |
2155 | - #self.app.select_single('GtkToggleButtonAccessible', accessible_name='Include the window border') |
2156 | - #self.app.select_single('GtkMenuItemAccessible', accessible_name='Drop shadow') |
2157 | - #self.app.select_single('GtkLabel', label='Apply _effect:') |
2158 | - #self.app.select_single('GtkLabelAccessible', accessible_name='Apply effect:') |
2159 | - |
2160 | + # verify window title: Take Screenshot to verify Screenshot is |
2161 | + # correclty opened |
2162 | + self.assertThat(self.archiveWindow.title, |
2163 | + Eventually(Contains('Take Screenshot'))) |
2164 | + |
2165 | + self.take_screenshot_button = self.app.select_single( |
2166 | + 'GtkLabel', label='Take _Screenshot') |
2167 | + self.grab_whole_screen_rb = self.app.select_single( |
2168 | + 'GtkRadioButton', label='Grab the whole sc_reen') |
2169 | + self.grab_curr_window_rb = self.app.select_single( |
2170 | + 'GtkRadioButton', label='Grab the current _window') |
2171 | + self.select_grab_area_rb = self.app.select_single( |
2172 | + 'GtkRadioButton', label='Select _area to grab') |
2173 | + self.incl_win_border = self.app.select_single( |
2174 | + 'GtkCheckButton', label='Include the window _border') |
2175 | +# self.drop_shadow_effect_shadow=self.app.select_single( |
2176 | +# 'GtkComboBoxAccessible', accessible_name='shadow') |
2177 | +# self.drop_shadow_effect_none=self.app.select_single( |
2178 | +# 'GtkComboBoxAccessible', accessible_name='none') |
2179 | +# self.drop_shadow_effect_border=self.app.select_single( |
2180 | +# 'GtkComboBoxAccessible', accessible_name='border') |
2181 | + |
2182 | + # potentially useful objects |
2183 | + # self.border_effect=self.app.select_single('GtkComboBoxAccessible', |
2184 | + # accessible_name='border') |
2185 | + # self.no_effect=self.app.select_single('GtkComboBoxAccessible', |
2186 | + # accessible_name='none') |
2187 | + # self.app.select_single('GtkLabel', label='Grab after a _delay of') |
2188 | + # self.app.select_single('GtkCheckButton', label='Include _pointer') |
2189 | + # self.app.select_single('GtkToggleButtonAccessible', |
2190 | + # accessible_name='Include pointer') |
2191 | + # self.app.select_single('GtkToggleButtonAccessible', |
2192 | + # accessible_name='Include the window border') |
2193 | + # self.app.select_single('GtkMenuItemAccessible', |
2194 | + # accessible_name='Drop shadow') |
2195 | + # self.app.select_single('GtkLabel', label='Apply _effect:') |
2196 | + # self.app.select_single('GtkLabelAccessible', accessible_name='Apply |
2197 | + # effect:') |
2198 | + |
2199 | def test_whole_screen(self): |
2200 | - #Test-case name: gnomescreenshot/gns-001 |
2201 | - #This test will check that Gnome Screenshot can save screenshot of the whole screen |
2202 | + # Test-case name: gnomescreenshot/gns-001 |
2203 | + # This test will check that Gnome Screenshot can save screenshot of the |
2204 | + # whole screen |
2205 | |
2206 | - #Grab the whole desktop |
2207 | - #Select Grab Whole Screen radio button and click on it |
2208 | + # Grab the whole desktop |
2209 | + # Select Grab Whole Screen radio button and click on it |
2210 | self.pointing_device.move_to_object(self.grab_whole_screen_rb) |
2211 | self.pointing_device.click() |
2212 | |
2213 | - #Select Take screenshot button and click it |
2214 | + # Select Take screenshot button and click it |
2215 | self.click_take_screenshot() |
2216 | |
2217 | - #verify take screenshot window opens |
2218 | + # verify take screenshot window opens |
2219 | tempArchive = _tempArchiveName() |
2220 | (dirName, fileName) = os.path.split(tempArchive) |
2221 | self.save_screenshot_file(fileName) |
2222 | |
2223 | - #Is the screenshot image saved to the /tmp directory? Is it a valid image file containing your screen? |
2224 | - #verify it's a non-zero file |
2225 | + # Is the screenshot image saved to the /tmp directory? |
2226 | + # Is it a valid image file containing your screen? |
2227 | + # verify it's a non-zero file |
2228 | self.verify_non_zero_file(fileName) |
2229 | - |
2230 | - #Cleanup |
2231 | + |
2232 | + # Cleanup |
2233 | self.delete_temp_file(tempArchive) |
2234 | |
2235 | def test_selected_window(self): |
2236 | - #Test-case name: gnomescreenshot/gns-002 |
2237 | - #This test will check that Gnome Screenshot can save screenshot of selected window |
2238 | + # Test-case name: gnomescreenshot/gns-002 |
2239 | + # This test will check that Gnome Screenshot can save screenshot of |
2240 | + # selected window |
2241 | |
2242 | - #Select Grab the current window |
2243 | + # Select Grab the current window |
2244 | self.pointing_device.move_to_object(self.grab_curr_window_rb) |
2245 | self.pointing_device.click() |
2246 | - #Select Take screenshot button and click it |
2247 | + # Select Take screenshot button and click it |
2248 | self.click_take_screenshot() |
2249 | |
2250 | - #verify take screenshot window opens |
2251 | + # verify take screenshot window opens |
2252 | tempArchive = _tempArchiveName() |
2253 | (dirName, fileName) = os.path.split(tempArchive) |
2254 | self.save_screenshot_file(fileName) |
2255 | |
2256 | - #Is the screenshot image saved to the /tmp directory? Is it a valid image file containing your screen? |
2257 | - #verify it's a non-zero file |
2258 | + # Is the screenshot image saved to the /tmp directory? |
2259 | + # Is it a valid image file containing your screen? |
2260 | + # verify it's a non-zero file |
2261 | self.verify_non_zero_file(fileName) |
2262 | - |
2263 | - #Cleanup |
2264 | + |
2265 | + # Cleanup |
2266 | self.delete_temp_file(tempArchive) |
2267 | |
2268 | def test_drop_shadow_effect(self): |
2269 | - #Test-case name: gnomescreenshot/gns-003 |
2270 | - #This test will check that Gnome Screenshot can save screenshot of selected window |
2271 | - |
2272 | - #Select Grab the current window |
2273 | + # Test-case name: gnomescreenshot/gns-003 |
2274 | + # This test will check that Gnome Screenshot can save screenshot of |
2275 | + # selected window |
2276 | + |
2277 | + # Select Grab the current window |
2278 | self.pointing_device.move_to_object(self.grab_curr_window_rb) |
2279 | self.pointing_device.click() |
2280 | - |
2281 | - #Verify the "Include the window border" box is selected |
2282 | + |
2283 | + # Verify the "Include the window border" box is selected |
2284 | if self.incl_win_border.active == 0: |
2285 | self.pointing_device.move_to_object(self.incl_win_border) |
2286 | self.pointing_device.click() |
2287 | - self.assertThat(lambda: self.incl_win_border.active, Eventually(Equals(1))) |
2288 | - |
2289 | -## #Select Drop shadow from the Apply effect drop down menu |
2290 | -## if self.drop_shadow_effect_none.enabled == 'True': |
2291 | -## self.pointing_device.move_to_object(self.drop_shadow_effect_none) |
2292 | -## elif self.drop_shadow_effect_shadow.enabled == 'True': |
2293 | -## self.pointing_device.move_to_object(self.drop_shadow_effect_shadow) |
2294 | -## else: |
2295 | -## self.pointing_device.move_to_object(self.drop_shadow_effect_border) |
2296 | -## self.pointing_device.click() |
2297 | -## self.keyboard.press_and_release('Down') |
2298 | -## self.keyboard.type('\n') |
2299 | -## self.pointing_device.click() |
2300 | -## self.pointing_device.click() |
2301 | - |
2302 | -## #Verify the "Drop shadow" is selected |
2303 | -### don't use these assertions |
2304 | -### self.assertThat(lambda: self.drop_shadow_effect.selected, Eventually(Equals(True))) |
2305 | -### self.assertThat(lambda: self.drop_shadow_effect.focused, Eventually(Equals(True))) |
2306 | -## self.assertThat(lambda: self.drop_shadow_effect.enabled, Eventually(Equals(True))) |
2307 | - |
2308 | - #Select Take screenshot button and click it |
2309 | + self.assertThat( |
2310 | + lambda: self.incl_win_border.active, Eventually(Equals(1))) |
2311 | + |
2312 | +# Select Drop shadow from the Apply effect drop down menu |
2313 | +# if self.drop_shadow_effect_none.enabled == 'True': |
2314 | +# self.pointing_device.move_to_object(self.drop_shadow_effect_none) |
2315 | +# elif self.drop_shadow_effect_shadow.enabled == 'True': |
2316 | +# self.pointing_device.move_to_object(self.drop_shadow_effect_shadow) |
2317 | +# else: |
2318 | +# self.pointing_device.move_to_object(self.drop_shadow_effect_border) |
2319 | +# self.pointing_device.click() |
2320 | +# self.keyboard.press_and_release('Down') |
2321 | +# self.keyboard.type('\n') |
2322 | +# self.pointing_device.click() |
2323 | +# self.pointing_device.click() |
2324 | + |
2325 | +# Verify the "Drop shadow" is selected |
2326 | +# don't use these assertions |
2327 | +# self.assertThat(lambda: self.drop_shadow_effect.selected, |
2328 | +# Eventually(Equals(True))) |
2329 | +# self.assertThat(lambda: self.drop_shadow_effect.focused, |
2330 | +# Eventually(Equals(True))) |
2331 | +# self.assertThat(lambda: self.drop_shadow_effect.enabled, |
2332 | +# Eventually(Equals(True))) |
2333 | + |
2334 | + # Select Take screenshot button and click it |
2335 | self.click_take_screenshot() |
2336 | - |
2337 | - #Make sure screenshot window you launched is focused and ready to accept your keyboard input |
2338 | + |
2339 | + # Make sure screenshot window you launched is focused and ready to |
2340 | + # accept your keyboard input |
2341 | tempArchive = _tempArchiveName() |
2342 | (dirName, fileName) = os.path.split(tempArchive) |
2343 | self.save_screenshot_file(fileName) |
2344 | |
2345 | - #Is the screenshot image saved to the /tmp directory? Is it a valid image file containing your screen? |
2346 | - #verify it's a non-zero file |
2347 | + # Is the screenshot image saved to the /tmp directory? |
2348 | + # Is it a valid image file containing your screen? |
2349 | + # verify it's a non-zero file |
2350 | self.verify_non_zero_file(fileName) |
2351 | |
2352 | - #Cleanup |
2353 | + # Cleanup |
2354 | self.delete_temp_file(tempArchive) |
2355 | |
2356 | def save_screenshot_file(self, fileName): |
2357 | - check_fn = lambda: self.app.select_single('GtkDialog', title='Save Screenshot') |
2358 | + check_fn = lambda: self.app.select_single( |
2359 | + 'GtkDialog', title='Save Screenshot') |
2360 | self.assertThat(check_fn, Eventually(NotEquals(None))) |
2361 | - #select everything so to cancel old file name |
2362 | + # select everything so to cancel old file name |
2363 | self.keyboard.press_and_release('Ctrl+a') |
2364 | self.keyboard.type(fileName) |
2365 | self.keyboard.type('.png') |
2366 | - #select /tmp folder |
2367 | - self.save_in_folder_button=self.app.select_single('GtkFileChooserButton', title='Select a folder') |
2368 | + # select /tmp folder |
2369 | + self.save_in_folder_button = self.app.select_single( |
2370 | + 'GtkFileChooserButton', title='Select a folder') |
2371 | self.pointing_device.move_to_object(self.save_in_folder_button) |
2372 | self.pointing_device.click() |
2373 | - #get to "other" |
2374 | + # get to "other" |
2375 | self.keyboard.press_and_release('End') |
2376 | - #save in the tmp folder |
2377 | + # save in the tmp folder |
2378 | self.keyboard.type("\n/tmp\n") |
2379 | - #Save screenshot |
2380 | - self.save_button=self.app.select_single('GtkLabel', label='_Save') |
2381 | + # Save screenshot |
2382 | + self.save_button = self.app.select_single('GtkLabel', label='_Save') |
2383 | self.pointing_device.move_to_object(self.save_button) |
2384 | self.pointing_device.click() |
2385 | - |
2386 | - def verify_non_zero_file(self,fileName): |
2387 | - self.assertThat(lambda: os.path.isfile('/tmp/'+fileName+'.png'), Eventually(Equals(True))) |
2388 | - self.assertThat(lambda: os.stat('/tmp/'+ fileName+'.png').st_size, Eventually(NotEquals(0))) |
2389 | + |
2390 | + def verify_non_zero_file(self, fileName): |
2391 | + self.assertThat(lambda: os.path.isfile( |
2392 | + '/tmp/' + fileName + '.png'), Eventually(Equals(True))) |
2393 | + self.assertThat( |
2394 | + lambda: os.stat('/tmp/' + fileName + '.png').st_size, |
2395 | + Eventually(NotEquals(0))) |
2396 | |
2397 | def delete_temp_file(self, tempArchive): |
2398 | - #Delete the screenshot file |
2399 | - self.addCleanup(os.unlink, tempArchive+'.png') |
2400 | + # Delete the screenshot file |
2401 | + self.addCleanup(os.unlink, tempArchive + '.png') |
2402 | |
2403 | def click_take_screenshot(self): |
2404 | - #click on take screenshot button |
2405 | + # click on take screenshot button |
2406 | self.pointing_device.move_to_object(self.take_screenshot_button) |
2407 | - self.pointing_device.click() |
2408 | - |
2409 | - |
2410 | -#Create temporary file name |
2411 | + self.pointing_device.click() |
2412 | + |
2413 | + |
2414 | +# Create temporary file name |
2415 | def _tempArchiveName(): |
2416 | '''Temporary archive name.''' |
2417 | sFile = tempfile.NamedTemporaryFile() |
2418 | sFile.close() |
2419 | - return sFile.name |
2420 | \ No newline at end of file |
2421 | + return sFile.name |
2422 | |
2423 | === modified file 'ubuntu_autopilot_tests/shotwell/test_shotwell.py' |
2424 | --- ubuntu_autopilot_tests/shotwell/test_shotwell.py 2013-03-04 21:53:25 +0000 |
2425 | +++ ubuntu_autopilot_tests/shotwell/test_shotwell.py 2013-11-23 00:24:47 +0000 |
2426 | @@ -1,85 +1,92 @@ |
2427 | from autopilot.testcase import AutopilotTestCase |
2428 | from autopilot.introspection.gtk import GtkIntrospectionTestMixin |
2429 | from autopilot.matchers import Eventually |
2430 | -from testtools.matchers import Equals, NotEquals, GreaterThan, LessThan, Contains |
2431 | +from testtools.matchers import Equals, NotEquals, \ |
2432 | + GreaterThan, LessThan, Contains |
2433 | |
2434 | from time import sleep |
2435 | import tempfile |
2436 | import os |
2437 | |
2438 | -#Register Shotwell as an application so we can call it |
2439 | -AutopilotTestCase.register_known_application("Shotwell", "shotwell.desktop", "shotwell") |
2440 | - |
2441 | -#http://packages.qa.ubuntu.com/qatracker/testcases/1428/info |
2442 | +# Register Shotwell as an application so we can call it |
2443 | +AutopilotTestCase.register_known_application( |
2444 | + "Shotwell", "shotwell.desktop", "shotwell") |
2445 | + |
2446 | +# http://packages.qa.ubuntu.com/qatracker/testcases/1428/info |
2447 | + |
2448 | |
2449 | class GtkToolbarTests(AutopilotTestCase, GtkIntrospectionTestMixin): |
2450 | - |
2451 | + |
2452 | def setUp(self): |
2453 | - #Open Shotwell |
2454 | + # Open Shotwell |
2455 | super(GtkToolbarTests, self).setUp() |
2456 | self.app = self.launch_test_application('shotwell') |
2457 | |
2458 | def test_import_pictures(self): |
2459 | - #Test-case name: shotwell/swp-001 |
2460 | - #This test will check that Shotwell can import pictures from camera |
2461 | - |
2462 | - # Plug in your camera using a USB cable. Your camera may need to be switched on, check the camera manual |
2463 | + # Test-case name: shotwell/swp-001 |
2464 | + # This test will check that Shotwell can import pictures from camera |
2465 | + |
2466 | + # Plug in your camera using a USB cable. Your camera may need to be |
2467 | + # switched on, check the camera manual |
2468 | _pluginCamera() |
2469 | - sleep(15) |
2470 | - |
2471 | - #Select 'shotwell' in the dropdown and click ok |
2472 | - |
2473 | - #TODO this does not work as the window is not always focused |
2474 | - #if I can focus the window then I can close it |
2475 | - #self.keyboard.press_and_release("Alt+o") |
2476 | - |
2477 | - #Verify that Shotwell is open |
2478 | - #LibraryWindow |
2479 | + sleep(15) |
2480 | + |
2481 | + # Select 'shotwell' in the dropdown and click ok |
2482 | + |
2483 | + # TODO this does not work as the window is not always focused |
2484 | + # if I can focus the window then I can close it |
2485 | + # self.keyboard.press_and_release("Alt+o") |
2486 | + |
2487 | + # Verify that Shotwell is open |
2488 | + # LibraryWindow |
2489 | windowTitle = self.app.select_single('LibraryWindow', title='Shotwell') |
2490 | self.assertThat(windowTitle.title, Eventually(Equals('Shotwell'))) |
2491 | - |
2492 | - #Shotwell loads and displays thumbnails of the photos on your camera |
2493 | - #LibraryWindow, GtkBox, GtkPaned, GtkFrame, GtkAlignment, BasicProperties |
2494 | + |
2495 | + # Shotwell loads and displays thumbnails of the photos on your camera |
2496 | + # LibraryWindow, GtkBox, GtkPaned, GtkFrame, GtkAlignment, |
2497 | + # BasicProperties |
2498 | rowsCols = self.app.select_single('BasicProperties') |
2499 | self.assertThat(rowsCols.n_rows, Eventually(GreaterThan(1))) |
2500 | self.assertThat(rowsCols.n_columns, Eventually(GreaterThan(1))) |
2501 | |
2502 | - # Select a single photo and click Import Selected (to make it simple I import all the photos) |
2503 | - #self.keyboard.press_and_release("Alt+f") |
2504 | - #sleep(1) |
2505 | - #self.keyboard.press_and_release("a") |
2506 | - #sleep(1) |
2507 | - #self.keyboard.type("\n") |
2508 | - #sleep(5) |
2509 | - |
2510 | - #Library, GtkBox, GtkPaned, GtkFrame, Gtkbox, GtkToolbar, GtkToolButton |
2511 | + # Select a single photo and click Import Selected |
2512 | + # (to make it simple I import all the photos) |
2513 | + # self.keyboard.press_and_release("Alt+f") |
2514 | + # sleep(1) |
2515 | + # self.keyboard.press_and_release("a") |
2516 | + # sleep(1) |
2517 | + # self.keyboard.type("\n") |
2518 | + # sleep(5) |
2519 | + |
2520 | + # Library, GtkBox, GtkPaned, GtkFrame, Gtkbox, GtkToolbar, |
2521 | + # GtkToolButton |
2522 | btn = self.app.select_single('GtkToolButton', label='Import_All') |
2523 | - #does it exist? |
2524 | + # does it exist? |
2525 | self.assertThat(btn, NotEquals(None)) |
2526 | - #let's click it |
2527 | + # let's click it |
2528 | self.mouse.move_to_object(btn) |
2529 | self.mouse.click() |
2530 | - |
2531 | - #Shotwell imports the photo and displays a prompt asking you if you wish to delete the photos from the camera |
2532 | - #Select no. |
2533 | + |
2534 | + # Shotwell imports the photo and displays a prompt asking you if you |
2535 | + # wish to delete the photos from the camera |
2536 | + # Select no. |
2537 | # press Alt+k to keep photos on camera |
2538 | self.keyboard.press_and_release("Alt+k") |
2539 | - |
2540 | - #Select 'last import' in the left hand pane |
2541 | - |
2542 | - |
2543 | - #Close Shotwell and exit |
2544 | + |
2545 | + # Select 'last import' in the left hand pane |
2546 | + |
2547 | + # Close Shotwell and exit |
2548 | _closeAndExit() |
2549 | sleep(5) |
2550 | |
2551 | |
2552 | def _pluginCamera(): |
2553 | # display message to warn tester to plugin an switch on camera |
2554 | - os.system("zenity --info --text 'Close this window, plug in and switch on your camera '") |
2555 | - |
2556 | + os.system( |
2557 | + "zenity --info --text 'Close this window, \ |
2558 | + plug in and switch on your camera '") |
2559 | |
2560 | |
2561 | def _closeAndExit(): |
2562 | - #Close open window gvfs-udisks2-volume-monitor |
2563 | - os.system("zenity --info --text 'Swtich off camera '") |
2564 | - |
2565 | + # Close open window gvfs-udisks2-volume-monitor |
2566 | + os.system("zenity --info --text 'Swtich off camera '") |
2567 | |
2568 | === modified file 'ubuntu_autopilot_tests/terminal/__init__.py' |
2569 | --- ubuntu_autopilot_tests/terminal/__init__.py 2013-08-02 10:04:08 +0000 |
2570 | +++ ubuntu_autopilot_tests/terminal/__init__.py 2013-11-23 00:24:47 +0000 |
2571 | @@ -29,9 +29,10 @@ |
2572 | |
2573 | def setUp(self): |
2574 | super(TerminalAutopilotTestCase, self).setUp() |
2575 | - #print(HOME_DIR) |
2576 | + # print(HOME_DIR) |
2577 | self.app = self.launch_test_application('gnome-terminal', |
2578 | - '--working-directory=' + HOME_DIR, |
2579 | + '--working-directory=' + |
2580 | + HOME_DIR, |
2581 | '--disable-factory' |
2582 | ) |
2583 | |
2584 | |
2585 | === modified file 'ubuntu_autopilot_tests/terminal/test_terminal.py' |
2586 | --- ubuntu_autopilot_tests/terminal/test_terminal.py 2013-07-30 17:29:08 +0000 |
2587 | +++ ubuntu_autopilot_tests/terminal/test_terminal.py 2013-11-23 00:24:47 +0000 |
2588 | @@ -19,7 +19,8 @@ |
2589 | import shutil |
2590 | import tempfile |
2591 | from autopilot.matchers import Eventually |
2592 | -from testtools.matchers import Equals, Contains, FileExists, DirExists, DirContains |
2593 | +from testtools.matchers import Equals, Contains, FileExists, DirExists, \ |
2594 | + DirContains |
2595 | from terminal import TerminalAutopilotTestCase |
2596 | |
2597 | |
2598 | @@ -27,9 +28,9 @@ |
2599 | |
2600 | def test_save_a_file(self): |
2601 | self.keyboard.type("touch /tmp/test-file\n") |
2602 | - #Verify that test-file has been created |
2603 | + # Verify that test-file has been created |
2604 | self.assertTrue('/tmp/testfile', FileExists()) |
2605 | - #Delete the file we created |
2606 | + # Delete the file we created |
2607 | self.addCleanup(os.remove, "/tmp/test-file") |
2608 | |
2609 | def test_create_directory(self): |
2610 | @@ -44,24 +45,25 @@ |
2611 | |
2612 | def test_move_directory_with_files(self): |
2613 | self.create_temp_directory_with_temp_files() |
2614 | - #create directory to move to |
2615 | + # create directory to move to |
2616 | self.keyboard.type('mkdir /tmp/temp-dir2\n') |
2617 | - #move temp-dir to temp-dir2 |
2618 | + # move temp-dir to temp-dir2 |
2619 | self.keyboard.type('mv /tmp/temp-dir/ /tmp/temp-dir2/\n') |
2620 | - #assert dir moved |
2621 | + # assert dir moved |
2622 | self.assertTrue('/tmp/temp-dir2/temp-dir/', DirExists()) |
2623 | - ##assert files moved |
2624 | - self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c'])) |
2625 | + # assert files moved |
2626 | + self.assertTrue( |
2627 | + '/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c'])) |
2628 | |
2629 | self.addCleanup(shutil.rmtree, '/tmp/temp-dir2') |
2630 | |
2631 | def test_copying_file(self): |
2632 | self.create_temp_directory_with_temp_files() |
2633 | - #create directory to move to |
2634 | + # create directory to move to |
2635 | self.keyboard.type('mkdir /tmp/temp-dir2\n') |
2636 | - #move file 'a' to temp-dir2 |
2637 | + # move file 'a' to temp-dir2 |
2638 | self.keyboard.type('cp /tmp/temp-dir/a /tmp/temp-dir2/\n') |
2639 | - ##assert file moved |
2640 | + # assert file moved |
2641 | self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a'])) |
2642 | self.addCleanup(shutil.rmtree, '/tmp/temp-dir') |
2643 | self.addCleanup(shutil.rmtree, '/tmp/temp-dir2') |
2644 | @@ -81,12 +83,12 @@ |
2645 | terminal_window = self.app.select_single('TerminalWindow') |
2646 | self.keyboard.type('cd\n') |
2647 | self.keyboard.type('cd Documents\n') |
2648 | - self.assertThat(terminal_window.title, Eventually(Contains('~/Documents'))) |
2649 | + self.assertThat( |
2650 | + terminal_window.title, Eventually(Contains('~/Documents'))) |
2651 | |
2652 | def test_open_new_tab(self, ): |
2653 | - #open a new tab |
2654 | + # open a new tab |
2655 | self.keyboard.press_and_release('Ctrl+Shift+t') |
2656 | # test number of tabs(containers) equals 2 |
2657 | tabs = self.app.select_many('TerminalScreenContainer') |
2658 | self.assertThat(len(tabs), Equals(2)) |
2659 | - |
2660 | |
2661 | === modified file 'ubuntu_autopilot_tests/totem/test_totem.py' |
2662 | --- ubuntu_autopilot_tests/totem/test_totem.py 2013-06-04 20:17:41 +0000 |
2663 | +++ ubuntu_autopilot_tests/totem/test_totem.py 2013-11-23 00:24:47 +0000 |
2664 | @@ -1,6 +1,7 @@ |
2665 | from autopilot.testcase import AutopilotTestCase |
2666 | from autopilot.matchers import Eventually |
2667 | -from testtools.matchers import Equals, NotEquals, GreaterThan, LessThan, Contains |
2668 | +from testtools.matchers import Equals, NotEquals, GreaterThan, LessThan, \ |
2669 | + Contains |
2670 | from autopilot.input import Mouse, Touch, Pointer |
2671 | |
2672 | from time import sleep |
2673 | @@ -8,52 +9,54 @@ |
2674 | import os |
2675 | |
2676 | |
2677 | - |
2678 | -#http://packages.qa.ubuntu.com/qatracker/testcases/1429/info |
2679 | +# http://packages.qa.ubuntu.com/qatracker/testcases/1429/info |
2680 | class TotemTests(AutopilotTestCase): |
2681 | |
2682 | def setUp(self): |
2683 | - #Open Totem |
2684 | + # Open Totem |
2685 | super(TotemTests, self).setUp() |
2686 | self.app = self.launch_test_application('totem') |
2687 | - |
2688 | - |
2689 | + |
2690 | self.windowTitle = self.app.select_single('GtkWindow', title='Videos') |
2691 | self.pointing_device = Pointer(Mouse.create()) |
2692 | - |
2693 | - |
2694 | + |
2695 | def test_play_and_pause_video(self): |
2696 | # check the window loaded |
2697 | self.assertThat(self.windowTitle.title, Eventually(Contains('Videos'))) |
2698 | self.status_label = self.app.select_single('GtkLabel', label='Stopped') |
2699 | - |
2700 | + |
2701 | # add content to playlist and auto starts |
2702 | self.setup_video() |
2703 | - ## TODO assert playing label |
2704 | - |
2705 | - self.assertThat(self.status_label.label, Eventually(Contains('Playing'))) |
2706 | + # TODO assert playing label |
2707 | + |
2708 | + self.assertThat( |
2709 | + self.status_label.label, Eventually(Contains('Playing'))) |
2710 | # press pause button |
2711 | - ## currently not working |
2712 | - #self.pause_button = self.app.select_single('GtkButton', tooltip_text='Pause') |
2713 | - #self.pointing_device.move_to_object(self.pause_button) |
2714 | - #self.pointing_device.click() |
2715 | + # currently not working |
2716 | + # self.pause_button = self.app.select_single('GtkButton', |
2717 | + # tooltip_text='Pause') |
2718 | + # self.pointing_device.move_to_object(self.pause_button) |
2719 | + # self.pointing_device.click() |
2720 | self.keyboard.press_and_release('Ctrl+Space') |
2721 | - |
2722 | - self.assertThat(self.status_label.label, Eventually(Contains('Paused'))) |
2723 | + |
2724 | + self.assertThat( |
2725 | + self.status_label.label, Eventually(Contains('Paused'))) |
2726 | # check we can start it playing again |
2727 | self.keyboard.press_and_release('Ctrl+Space') |
2728 | - self.assertThat(self.status_label.label, Eventually(Contains('Playing'))) |
2729 | - |
2730 | + self.assertThat( |
2731 | + self.status_label.label, Eventually(Contains('Playing'))) |
2732 | + |
2733 | def setup_video(self, ): |
2734 | ''' select and add content to the playlist ''' |
2735 | - #get the sidebar button |
2736 | - self.sidebar_button = self.app.select_single('GtkToggleButton', label='S_idebar') |
2737 | - #make sure playlist window is displayed |
2738 | + # get the sidebar button |
2739 | + self.sidebar_button = self.app.select_single( |
2740 | + 'GtkToggleButton', label='S_idebar') |
2741 | + # make sure playlist window is displayed |
2742 | self.keyboard.press_and_release('Alt+v') |
2743 | self.keyboard.press_and_release('Up') |
2744 | self.keyboard.press_and_release('Up') |
2745 | self.keyboard.press_and_release('Enter') |
2746 | - #check if sidebar is already open, if not then open it |
2747 | + # check if sidebar is already open, if not then open it |
2748 | sideIsActive = self.sidebar_button.active |
2749 | if sideIsActive == 0: |
2750 | self.pointing_device.move_to_object(self.sidebar_button) |
2751 | @@ -61,24 +64,24 @@ |
2752 | sideIsActive = self.sidebar_button.active |
2753 | # check it is open |
2754 | self.assertThat(sideIsActive, Equals(1)) |
2755 | - |
2756 | - #select the + button |
2757 | - self.add_button = self.app.select_single('GtkToolButton', tooltip_text='Add...') |
2758 | - #click on + button |
2759 | + |
2760 | + # select the + button |
2761 | + self.add_button = self.app.select_single( |
2762 | + 'GtkToolButton', tooltip_text='Add...') |
2763 | + # click on + button |
2764 | self.pointing_device.move_to_object(self.add_button) |
2765 | self.pointing_device.click() |
2766 | # check the file chooser dialog loaded |
2767 | - self.file_chooser_dialog = self.app.select_single('GtkFileChooserDialog') |
2768 | - self.assertThat(self.file_chooser_dialog.title, Eventually(Contains('Select Movies or Playlists'))) |
2769 | + self.file_chooser_dialog = self.app.select_single( |
2770 | + 'GtkFileChooserDialog') |
2771 | + self.assertThat(self.file_chooser_dialog.title, |
2772 | + Eventually(Contains('Select Movies or Playlists'))) |
2773 | # enter content path |
2774 | self.keyboard.press_and_release('Alt+d') |
2775 | - self.keyboard.type('/usr/share/example-content/Ubuntu_Free_Culture_Showcase') |
2776 | + self.keyboard.type( |
2777 | + '/usr/share/example-content/Ubuntu_Free_Culture_Showcase') |
2778 | # add the directory to the playlist |
2779 | - self.add_dir_button = self.app.select_single('GtkLabel', label='Add Directory') |
2780 | + self.add_dir_button = self.app.select_single( |
2781 | + 'GtkLabel', label='Add Directory') |
2782 | self.pointing_device.move_to_object(self.add_dir_button) |
2783 | self.pointing_device.click() |
2784 | - |
2785 | - |
2786 | - |
2787 | - |
2788 | - |
2789 | \ No newline at end of file |
Nice one Jackson!, looks good to me :-) Thanks :-)