Merge lp:~carla-sella/ubuntu-autopilot-tests/carlas-tests into lp:ubuntu-autopilot-tests

Proposed by Carla Sella
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 15
Merged at revision: 14
Proposed branch: lp:~carla-sella/ubuntu-autopilot-tests/carlas-tests
Merge into: lp:ubuntu-autopilot-tests
Diff against target: 610 lines (+590/-0)
3 files modified
gedit/test_gedit.py (+249/-0)
screenshot/test_screenshot.py (+114/-0)
terminal/test_terminal.py (+227/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-autopilot-tests/carlas-tests
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+141416@code.launchpad.net

Description of the change

Terminal, Gedit and Screenshot tests

To post a comment you must log in.
15. By Carla Sella

fixed some things on gedit test

Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'gedit'
2=== added file 'gedit/__init__.py'
3=== added file 'gedit/test_gedit.py'
4--- gedit/test_gedit.py 1970-01-01 00:00:00 +0000
5+++ gedit/test_gedit.py 2012-12-28 15:44:21 +0000
6@@ -0,0 +1,249 @@
7+from autopilot.testcase import AutopilotTestCase
8+from autopilot.matchers import Eventually
9+from testtools.matchers import Equals, Contains
10+
11+#had to add this to make "self.addCleanup(remove, tempFile.name)" work without errors
12+from os import remove
13+
14+from time import sleep
15+
16+import tempfile
17+import os
18+
19+
20+#http://packages.qa.ubuntu.com/qatracker/testcases/1420/info
21+class GeditTests(AutopilotTestCase):
22+
23+ def setUp(self):
24+ super(GeditTests, self).setUp()
25+ self.app = self.start_app_window("Text Editor")
26+
27+ #This will make sure gedit window you launched is focused and ready to accept your keyboard input
28+ self.app.set_focus()
29+ self.assertTrue(self.app.is_focused)
30+
31+
32+ def test_save_a_file(self):
33+ #Test-case name: gedit/ged-001
34+ #This test will check that GEdit can save and open saved files
35+ self.keyboard.type("The quick brown foxes jump over the lazy dog")
36+
37+ #Create temporary file, then close it so our save works properly
38+ tempFile = open(_saveFile(self).name, 'r')
39+
40+ #Close the open file
41+ self.keyboard.press_and_release("Ctrl+w")
42+
43+ #Make sure it closed
44+ self.assertThat(lambda: self.app.name, Eventually(Equals("gedit")))
45+
46+ #Open the file we made
47+ self.keyboard.press_and_release("Ctrl+o")
48+
49+ #Manually type location
50+ self.keyboard.type(tempFile.name + "\n")
51+
52+ #Check to see that the title reflects our filename
53+ (dirName, fileName) = os.path.split(tempFile.name)
54+ self.assertThat(lambda: self.app.name, Eventually(Contains(fileName)))
55+
56+ #Check that the file contains the phrase "The quick brown foxes jump over the lazy dog"
57+ filePhrase = tempFile.read()
58+ self.assertThat(filePhrase, Contains("The quick brown foxes jump over the lazy dog\n"))
59+
60+ #Close the open file
61+ self.keyboard.press_and_release("Ctrl+w")
62+
63+ #Delete the file we made
64+ #Added sleep so file does not get removed too soon
65+ sleep(3)
66+ self.addCleanup(remove, tempFile.name)
67+
68+
69+
70+ def test_save_html_file(self):
71+ #Test-case name: gedit/ged-002
72+ #This test will check that GEdit can save HTML files correctly
73+
74+ #Type in link to Ubuntu
75+ self.keyboard.type("http://www.ubuntu.com")
76+
77+ #Save file as gedit.html
78+ self.keyboard.press_and_release("Ctrl+Shift+s")
79+ self.keyboard.type("/tmp/gedit.html")
80+ self.keyboard.press_and_release("Alt+s")
81+
82+ #Close file
83+ self.keyboard.press_and_release("Ctrl+w")
84+
85+ #Open file
86+ self.keyboard.press_and_release("Ctrl+o")
87+ self.keyboard.type("/tmp/gedit.html")
88+ self.keyboard.press_and_release("Alt+o")
89+
90+ #Verify contents has link
91+ htmlFile = open("/tmp/gedit.html", "r")
92+ filePhrase = htmlFile.read()
93+ self.assertThat(filePhrase, Contains("http://www.ubuntu.com\n"))
94+
95+ #Close file
96+ self.keyboard.press_and_release("Ctrl+q")
97+
98+ #Open html file with firefox
99+ self.keyboard.press_and_release("Ctrl+Alt+t")
100+ self.keyboard.type("firefox /tmp/gedit.html\n")
101+
102+ #Close firefox window
103+ sleep(1)
104+ self.keyboard.press_and_release("Ctrl+q")
105+
106+ #Close terminal window
107+ #self.keyboard.press_and_release("Alt+Tab")
108+ self.keyboard.type("exit\n")
109+
110+ #Remove "/tmp/gedit.html" file
111+ sleep(3)
112+ self.addCleanup(remove, "/tmp/gedit.html")
113+
114+
115+
116+ def test_replace_test(self):
117+ #Test-case name: gedit/ged-003
118+ #This test will check that GEdit can replace text
119+
120+ #Type in phrase
121+ self.keyboard.type("The quick brown foxes jump over the lazy dog")
122+
123+ #Create temporary file, then close it so our save works properly
124+ tempFile = open(_saveFile(self).name, 'r')
125+
126+ #Press ctrl+h to open replace dialog
127+ self.keyboard.press_and_release("Ctrl+h")
128+
129+ #Verify replace dialog appears
130+
131+ #Replace foxes with fox
132+ self.keyboard.type("foxes\t\tfox")
133+ self.keyboard.press_and_release("Alt+a")
134+
135+ #Verify replace dialog stays open
136+
137+ #Close replace dialog
138+ self.keyboard.press_and_release("Escape")
139+
140+ #Save file so that when test ends it does not ask to save the modifed content
141+ self.keyboard.press_and_release("Ctrl+s")
142+
143+ #Verify text now reads 'The quick brown fox jump over the lazy dog'
144+ savedFile = open(tempFile.name, "r")
145+ filePhrase = savedFile.read()
146+ self.assertThat(filePhrase, Contains("The quick brown fox jump over the lazy dog\n"))
147+
148+ #Close the open file
149+ self.keyboard.press_and_release("Ctrl+w")
150+
151+ #Delete the file we made
152+ sleep(3)
153+ self.addCleanup(remove, tempFile.name)
154+
155+
156+
157+ def test_highlight_searched_text(self):
158+ #Test-case name: gedit/ged-004
159+ #This test will check that GEdit can find and hightlight searched text
160+
161+ #Type in phrase
162+ self.keyboard.type("The quick brown foxes jump over the lazy dog")
163+
164+ #Create temporary file, then close it so our save works properly
165+ tempFile = open(_saveFile(self).name, 'r')
166+
167+ #Press Ctrl+f to open search box
168+ self.keyboard.press_and_release("Ctrl+f")
169+
170+ #Verify search box appears
171+
172+ #Type in "T"
173+ self.keyboard.type("T")
174+ sleep(5)
175+
176+ #Verify all the "T" letters in the document are highlited
177+
178+ #Type in "he"
179+ self.keyboard.type("he")
180+
181+ #Verify all the "The" words in the document are highlited
182+
183+ #Press Ctrl+g to go to the next searched word
184+ self.keyboard.press_and_release("Ctrl+g")
185+
186+ #Verify that text cursor moves to grey-highlighted 'the' in 'over the lazy dog'
187+
188+ #Press Shift+Ctrl+g to go to the previous searched word
189+ self.keyboard.press_and_release("Shift+Ctrl+g")
190+
191+ #Verify that text cursor moves to grey-highlighted 'The' in 'The quick brown'
192+
193+ #Close search box
194+ self.keyboard.press_and_release("Escape")
195+
196+ #Verify that the seach box is closed
197+
198+ #Verify all the "The" words in the document are highlited
199+
200+ #Close the open file
201+ self.keyboard.press_and_release("Ctrl+w")
202+
203+ #Delete the file we made
204+ sleep(3)
205+ self.addCleanup(remove, tempFile.name)
206+
207+
208+ def test_display_file_browser_panel(self):
209+ #Test-case name: gedit/ged-005
210+ #This test will check that GEdit can display File Browser panel
211+
212+ #Press Alt+e to open "Edit" menu
213+ self.keyboard.press_and_release("Alt+e", delay=0.5)
214+
215+ #Press "e" to open "Preferences"
216+ self.keyboard.press_and_release("e")
217+
218+ #Press left arrow "Plugins" tab
219+ self.keyboard.press_and_release("Left")
220+
221+ #Verify the "File Browser Panel" plugin is checked
222+
223+ #Press Escape to close preferences window
224+ self.keyboard.press_and_release("Escape")
225+
226+ #Press F9
227+ self.keyboard.press_and_release("F9")
228+
229+ #Verify the The side panel appears with the file browser panel included
230+
231+ #Press F9
232+ self.keyboard.press_and_release("F9")
233+
234+ #Verify the The side panel close properly
235+
236+
237+
238+
239+def _saveFile(self):
240+ #Create temporary file, then close it so our save works properly
241+ saveFile = tempfile.NamedTemporaryFile()
242+ saveName = saveFile.name
243+ (dirName, fileName) = os.path.split(saveFile.name)
244+ saveFile.close()
245+ self.keyboard.press_and_release("Ctrl+s")
246+ self.keyboard.type(saveName)
247+ self.keyboard.press_and_release("Alt+s")
248+
249+ #Check to see that the title reflects our filename
250+ self.assertThat(lambda: self.app.name, Eventually(Contains(fileName)))
251+
252+ #An asterisk in a gedit title means an unsaved document
253+ self.assertNotIn(self.app.name, "*")
254+ return saveFile
255+
256
257=== added directory 'screenshot'
258=== added file 'screenshot/__init__.py'
259=== added file 'screenshot/test_screenshot.py'
260--- screenshot/test_screenshot.py 1970-01-01 00:00:00 +0000
261+++ screenshot/test_screenshot.py 2012-12-28 15:44:21 +0000
262@@ -0,0 +1,114 @@
263+from autopilot.testcase import AutopilotTestCase
264+from autopilot.matchers import Eventually
265+from testtools.matchers import Equals, Contains
266+
267+#had to add this to make "self.addCleanup(remove, tempFile.name)" work without errors
268+from os import remove
269+
270+import tempfile
271+import os
272+
273+
274+#Register Screenshot as an application so we can call it
275+AutopilotTestCase.register_known_application("Screenshot", "gnome-screenshot.desktop", "gnome-screenshot")
276+
277+#http://packages.qa.ubuntu.com/qatracker/testcases/1421/info
278+class ScreenshotTests(AutopilotTestCase):
279+
280+ def setUp(self):
281+ super(ScreenshotTests, self).setUp()
282+ self.app = self.start_app_window("Screenshot")
283+
284+ #Make sure screenshot window you launched is focused and ready to accept your keyboard input
285+ self.app.set_focus()
286+ self.assertTrue(self.app.is_focused)
287+
288+
289+ def test_whole_screen(self):
290+ #Test-case name: gnomescreenshot/gns-001
291+ #This test will check that Gnome Screenshot can save screenshot of the whole screen
292+
293+ #Press Alt+s to Grab the whole desktop
294+ self.keyboard.press_and_release("Alt+s")
295+
296+ #Make sure screenshot window you launched is focused and ready to accept your keyboard input
297+ self.app.set_focus()
298+ self.assertTrue(self.app.is_focused)
299+
300+ #Press Alt+n to focus on Name field
301+ self.keyboard.press_and_release("Alt+n")
302+
303+ #Name it shot1.png
304+ self.keyboard.type("/tmp/shot1.png")
305+
306+ #Press Alt+s to save image
307+ self.keyboard.press_and_release("Alt+s")
308+
309+ #Is the screenshot image saved to your home directory? Is it a valid image file containing your screen?
310+
311+ #Remove created file
312+ self.addCleanup(remove, "/tmp/shot1.png")
313+
314+
315+ def test_selected_window(self):
316+ #Test-case name: gnomescreenshot/gns-002
317+ #This test will check that Gnome Screenshot can save screenshot of selected window
318+
319+ #Select Grab the current window
320+ self.keyboard.press_and_release("Alt+w")
321+
322+ #Make sure screenshot window you launched is focused and ready to accept your keyboard input
323+ self.app.set_focus()
324+ self.assertTrue(self.app.is_focused)
325+
326+ #Press Alt+n to focus on Name field
327+ self.keyboard.press_and_release("Alt+n")
328+
329+
330+ #Name it shot2.png
331+ self.keyboard.type("/tmp/shot2.png")
332+
333+
334+ #Is the screenshot image saved to your home directory? Is it a valid image file containing your selected window?
335+
336+ #Remove created file
337+ self.addCleanup(remove, "/tmp/shot2.png")
338+
339+
340+ def test_drop_shadow(self):
341+ #Test-case name: gnomescreenshot/gns-003
342+ #This test will check that Gnome Screenshot can save screenshot of selected window
343+
344+
345+ #Select Grab the current window
346+ self.keyboard.press_and_release("Alt+w")
347+
348+
349+ #Select Drop shadow from the Apply effect drop down menu
350+ self.keyboard.press_and_release("Alt+b")
351+
352+ #Verify the "Include the window border" box is selected
353+
354+ self.keyboard.press_and_release("Down")
355+ self.keyboard.press_and_release("Down")
356+
357+ #Verify the "Drop shadow" is selected
358+
359+ self.keyboard.press_and_release("Alt+s")
360+
361+ #Make sure screenshot window you launched is focused and ready to accept your keyboard input
362+ self.app.set_focus()
363+ self.assertTrue(self.app.is_focused)
364+
365+ #Press Alt+n to focus on Name field
366+ self.keyboard.press_and_release("Alt+n")
367+
368+ #Name it shot2.png
369+ self.keyboard.type("/tmp/shot2.png")
370+
371+ #Is the screenshot image saved to your home directory? Is it a valid image file containing your selected window, with the drop shadow effect?
372+
373+
374+ #Remove created file
375+ self.addCleanup(remove, "/tmp/shot2.png")
376+
377
378=== added directory 'terminal'
379=== added file 'terminal/__init__.py'
380=== added file 'terminal/test_terminal.py'
381--- terminal/test_terminal.py 1970-01-01 00:00:00 +0000
382+++ terminal/test_terminal.py 2012-12-28 15:44:21 +0000
383@@ -0,0 +1,227 @@
384+from autopilot.testcase import AutopilotTestCase
385+from autopilot.matchers import Eventually
386+from testtools.matchers import Equals, Contains
387+
388+#had to add this to make "self.addCleanup(remove, tempFile.name)" work without errors
389+from os import remove
390+
391+import tempfile
392+import os
393+import os.path
394+
395+#http://packages.qa.ubuntu.com/qatracker/testcases/1422/info
396+class TerminalTests(AutopilotTestCase):
397+
398+ def setUp(self):
399+ super(TerminalTests, self).setUp()
400+ self.app = self.start_app_window("Terminal")
401+
402+ #Make sure terminal window you launched is focused and ready to accept your keyboard input
403+ self.app.set_focus()
404+ self.assertTrue(self.app.is_focused)
405+
406+
407+ def test_save_a_file(self):
408+ #Test-case name: gnometerminal/ter-001
409+ #This test will check that basic terminal commands work in Gnome Terminal
410+
411+ #Type a command
412+ self.keyboard.type("touch /tmp/test-file\n")
413+
414+ #Verify that test-file has been created
415+
416+
417+ #Enter ls -al
418+ self.keyboard.type("ls -al /tmp\n")
419+
420+ #Verify output
421+
422+
423+ #Press up arrow
424+ self.keyboard.press_and_release("Up")
425+
426+ #Verify output you ran the same command you ran previously
427+
428+ #Delete the file we created
429+ self.addCleanup(remove, "/tmp/test-file")
430+
431+
432+
433+ def test_change_colors(self):
434+ #Test-case name: gnometerminal/ter-002
435+ #This test will check that terminal colors and zoom level can be changed
436+
437+ #Make sure terminal window you launched is focused and ready to accept your keyboard input
438+ self.app.set_focus()
439+ self.assertTrue(self.app.is_focused)
440+
441+ #Press Alt+e to open "Edit" menu
442+ self.keyboard.press_and_release("Alt+e", delay=0.5)
443+
444+ #Press "o" to open "Profiles"
445+ self.keyboard.press_and_release("o")
446+
447+ #Press right arrow twice for "colors" tab
448+ self.keyboard.press_and_release("Right")
449+ self.keyboard.press_and_release("Right")
450+
451+ #Change built in themes
452+ self.keyboard.press_and_release("Tab")
453+ self.keyboard.type("\n", delay=1)
454+ self.keyboard.press_and_release("Tab")
455+ self.keyboard.press_and_release("Down")
456+ self.keyboard.press_and_release("Down")
457+ self.keyboard.press_and_release("Down")
458+ self.keyboard.press_and_release("Down")
459+ self.keyboard.press_and_release("Down", delay=0.3)
460+
461+ #Verify colors have changed
462+
463+ #Put configuration back as it was
464+ self.keyboard.press_and_release("Up")
465+ self.keyboard.press_and_release("Up")
466+ self.keyboard.press_and_release("Up")
467+ self.keyboard.press_and_release("Up")
468+ self.keyboard.press_and_release("Up")
469+
470+
471+ #Change text color
472+ self.keyboard.press_and_release("Tab")
473+ self.keyboard.type("\n")
474+ self.keyboard.type("\n")
475+ self.keyboard.press_and_release("Alt+s")
476+
477+ #Verify text color has changed
478+
479+
480+ #Put text color back as it was
481+ self.keyboard.type("\n", delay=1)
482+ self.keyboard.press_and_release("Down")
483+ self.keyboard.press_and_release("Down")
484+ self.keyboard.press_and_release("Down")
485+ self.keyboard.type("\n")
486+ self.keyboard.press_and_release("Alt+s")
487+ self.keyboard.press_and_release("Shift+Tab")
488+ self.keyboard.press_and_release("Shift+Tab")
489+ self.keyboard.type("\n")
490+
491+ #Set a Background Image
492+ self.keyboard.press_and_release("Shift+Tab")
493+ self.keyboard.press_and_release("Right")
494+ self.keyboard.press_and_release("Alt+b")
495+ self.keyboard.press_and_release("Alt+f")
496+ self.keyboard.press_and_release("Space")
497+ self.keyboard.type("/usr/share/backgrounds/Gran_Canaria_by_ALF.jpg")
498+ self.keyboard.press_and_release("Alt+o")
499+ self.keyboard.press_and_release("Tab")
500+ self.keyboard.press_and_release("Tab")
501+ self.keyboard.press_and_release("Space")
502+
503+ #Verify Terminal background changes
504+
505+
506+ #Put Terminal background back as it was
507+ self.keyboard.press_and_release("Alt+s")
508+ self.keyboard.press_and_release("Space", delay=0.2)
509+
510+ #Close Profile preferences window
511+ self.keyboard.press_and_release("Alt+c")
512+
513+ #Change the Zoom Level
514+ self.keyboard.press_and_release("Ctrl+plus")
515+ self.keyboard.press_and_release("Ctrl+plus")
516+ self.keyboard.press_and_release("Ctrl+plus")
517+ self.keyboard.press_and_release("Ctrl+plus")
518+ self.keyboard.press_and_release("Ctrl+-")
519+ self.keyboard.press_and_release("Ctrl+-")
520+
521+ #Verify zoom level has changed
522+
523+
524+ #Put Zoom level back as it was
525+ self.keyboard.press_and_release("Ctrl+0")
526+
527+
528+ def test_terminal_coloring(self):
529+ #Test-case name: gnometerminal/ter-003
530+ #This test will check that terminal coloring is active
531+
532+ #Make sure terminal window you launched is focused and ready to accept your keyboard input
533+ self.app.set_focus()
534+ self.assertTrue(self.app.is_focused)
535+
536+ #Type in touch /tmp/text1.txt
537+ self.keyboard.type("touch /tmp/text1.txt\n")
538+
539+ #Type in ls
540+ self.keyboard.type("ls /tmp\n")
541+
542+ #Verify txt is in black
543+
544+
545+ #Type in chmod 777 text1.txt
546+ self.keyboard.type("chmod 777 /tmp/text1.txt\n")
547+
548+ #Type in ls
549+ self.keyboard.type("ls /tmp\n")
550+
551+
552+ #Verify txt should now be green
553+
554+ #Delete the file we created
555+ self.addCleanup(remove, "/tmp/text1.txt")
556+
557+
558+ def test_launch_terminal(self):
559+ #Test-case name: gnometerminal/ter-004
560+ #This test will check that the terminal tab launches succesfully
561+
562+
563+ #Open Terminal using the dash, and typing 'terminal'
564+ self.keyboard.press_and_release("Super")
565+ self.keyboard.type("terminal\n")
566+
567+ #Is an instance of gnome-terminal with the title '@: ~' opened, with the current directory set to the users home directory?
568+
569+
570+ #Close opened terminal
571+ self.keyboard.press_and_release("Ctrl+d", delay=0.2)
572+
573+ #Press Ctrl+Alt+T
574+ self.keyboard.press_and_release("Ctrl+Alt+t")
575+
576+ #Is an instance of gnome-terminal with the title '@: ~' opened, with the current directory set to the users home directory?
577+
578+
579+ #Close opened terminal
580+ self.keyboard.press_and_release("Ctrl+d")
581+ self.keyboard.press_and_release("Ctrl+d")
582+ #Had to put two Ctrl+d's as the first one closes the terminal that opens with the launch of this test
583+
584+
585+ def test_new_title(self):
586+ #Test-case name: gnometerminal/ter-005
587+ #This test will check that the terminal can be given a new title
588+
589+ #Make sure terminal window you launched is focused and ready to accept your keyboard input
590+ self.app.set_focus()
591+ self.assertTrue(self.app.is_focused)
592+
593+ #From the main menu select 'Terminal > Set Title...'
594+ self.keyboard.press_and_release("Alt+t", delay=0.5)
595+ self.keyboard.press_and_release("s", delay=0.5)
596+
597+ #Verify the Set Title dialog appears
598+ #Check to see that the title of the window is "Set Title"
599+ #self.assertThat(lambda: self.app.name, Eventually(Contains("Set Title")))
600+ #Commented it as it does not work
601+
602+ #Enter 'Test Title' and click OK
603+ self.keyboard.type("Test Title")
604+ self.keyboard.press_and_release("Alt+o")
605+
606+ #Is the title of the window now 'Test Title'?
607+ #Check to see that the title reflects our 'Test Title'
608+ self.assertThat(lambda: self.app.name, Eventually(Contains("Test Title")))
609+
610+

Subscribers

People subscribed via source and target branches