Merge lp:~dpniel/ubuntu-autopilot-tests/terminal into lp:ubuntu-autopilot-tests
- terminal
- Merge into trunk
Proposed by
Dan Chapman
Status: | Merged |
---|---|
Merged at revision: | 57 |
Proposed branch: | lp:~dpniel/ubuntu-autopilot-tests/terminal |
Merge into: | lp:ubuntu-autopilot-tests |
Diff against target: |
347 lines (+119/-211) 2 files modified
ubuntu_autopilot_tests/terminal/__init__.py (+36/-0) ubuntu_autopilot_tests/terminal/test_terminal.py (+83/-211) |
To merge this branch: | bzr merge lp:~dpniel/ubuntu-autopilot-tests/terminal |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Review via email: mp+177433@code.launchpad.net |
Commit message
Description of the change
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ubuntu_autopilot_tests/terminal/__init__.py' |
2 | --- ubuntu_autopilot_tests/terminal/__init__.py 2012-12-28 14:02:50 +0000 |
3 | +++ ubuntu_autopilot_tests/terminal/__init__.py 2013-07-30 17:31:29 +0000 |
4 | @@ -0,0 +1,36 @@ |
5 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
6 | +# |
7 | +# Copyright (C) 2013 |
8 | +# |
9 | +# Author: Daniel Chapman daniel@chapman-mail.com |
10 | +# |
11 | +# This program is free software; you can redistribute it and/or modify |
12 | +# it under the terms of the GNU Lesser General Public License as published by |
13 | +# the Free Software Foundation; version 3. |
14 | +# |
15 | +# This program is distributed in the hope that it will be useful, |
16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | +# GNU Lesser General Public License for more details. |
19 | +# |
20 | +# You should have received a copy of the GNU Lesser General Public License |
21 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | +from autopilot.testcase import AutopilotTestCase |
23 | +from autopilot.matchers import Eventually |
24 | +from testtools.matchers import Equals, Contains, FileExists, DirExists |
25 | +import tempfile |
26 | +import os |
27 | + |
28 | + |
29 | +class TerminalAutopilotTestCase(AutopilotTestCase): |
30 | + |
31 | + def setUp(self): |
32 | + super(TerminalAutopilotTestCase, self).setUp() |
33 | + self.app = self.launch_test_application('gnome-terminal', '--disable-factory') |
34 | + |
35 | + def create_temp_directory_with_temp_files(self): |
36 | + """ Creates a temp directory with temp files 'a' 'b' and 'c' """ |
37 | + self.keyboard.type('mkdir /tmp/temp-dir\n') |
38 | + self.keyboard.type('touch /tmp/temp-dir/a\n') |
39 | + self.keyboard.type('touch /tmp/temp-dir/b\n') |
40 | + self.keyboard.type('touch /tmp/temp-dir/c\n') |
41 | |
42 | === modified file 'ubuntu_autopilot_tests/terminal/test_terminal.py' |
43 | --- ubuntu_autopilot_tests/terminal/test_terminal.py 2013-05-27 13:42:21 +0000 |
44 | +++ ubuntu_autopilot_tests/terminal/test_terminal.py 2013-07-30 17:31:29 +0000 |
45 | @@ -1,220 +1,92 @@ |
46 | -from autopilot.testcase import AutopilotTestCase |
47 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
48 | +# |
49 | +# Copyright (C) 2013 |
50 | +# |
51 | +# Author: Daniel Chapman daniel@chapman-mail.com |
52 | +# |
53 | +# This program is free software; you can redistribute it and/or modify |
54 | +# it under the terms of the GNU Lesser General Public License as published by |
55 | +# the Free Software Foundation; version 3. |
56 | +# |
57 | +# This program is distributed in the hope that it will be useful, |
58 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
59 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
60 | +# GNU Lesser General Public License for more details. |
61 | +# |
62 | +# You should have received a copy of the GNU Lesser General Public License |
63 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
64 | +import os |
65 | +import shutil |
66 | +import tempfile |
67 | from autopilot.matchers import Eventually |
68 | -from testtools.matchers import Equals, Contains |
69 | -from autopilot.process import ProcessManager |
70 | - |
71 | -import tempfile |
72 | -import os |
73 | - |
74 | -#http://packages.qa.ubuntu.com/qatracker/testcases/1422/info |
75 | -class TerminalTests(AutopilotTestCase): |
76 | - |
77 | - def setUp(self): |
78 | - super(TerminalTests, self).setUp() |
79 | - self.proc_manager = ProcessManager.create('BAMF') |
80 | - self.app = self.proc_manager.start_app_window("Terminal") |
81 | - |
82 | - #Make sure terminal window you launched is focused and ready to accept your keyboard input |
83 | - self.app.set_focus() |
84 | - self.assertTrue(self.app.is_focused) |
85 | - |
86 | +from testtools.matchers import Equals, Contains, FileExists, DirExists, DirContains |
87 | +from terminal import TerminalAutopilotTestCase |
88 | + |
89 | + |
90 | +class TerminalFileSystemTests(TerminalAutopilotTestCase): |
91 | |
92 | def test_save_a_file(self): |
93 | - #Test-case name: gnometerminal/ter-001 |
94 | - #This test will check that basic terminal commands work in Gnome Terminal |
95 | - |
96 | - #Type a command |
97 | self.keyboard.type("touch /tmp/test-file\n") |
98 | - |
99 | #Verify that test-file has been created |
100 | - |
101 | - |
102 | - #Enter ls -al |
103 | - self.keyboard.type("ls -al /tmp\n") |
104 | - |
105 | - #Verify output |
106 | - |
107 | - |
108 | - #Press up arrow |
109 | - self.keyboard.press_and_release("Up") |
110 | - |
111 | - #Verify output you ran the same command you ran previously |
112 | - |
113 | + self.assertTrue('/tmp/testfile', FileExists()) |
114 | #Delete the file we created |
115 | self.addCleanup(os.remove, "/tmp/test-file") |
116 | |
117 | - |
118 | - |
119 | - def test_change_colors(self): |
120 | - #Test-case name: gnometerminal/ter-002 |
121 | - #This test will check that terminal colors and zoom level can be changed |
122 | - |
123 | - #Press Alt+e to open "Edit" menu |
124 | - self.keyboard.press_and_release("Alt+e", delay=0.5) |
125 | - |
126 | - #Press "o" to open "Profiles" |
127 | - self.keyboard.press_and_release("o") |
128 | - |
129 | - #Press right arrow twice for "colors" tab |
130 | - self.keyboard.press_and_release("Right") |
131 | - self.keyboard.press_and_release("Right") |
132 | - |
133 | - #Change built in themes |
134 | - self.keyboard.press_and_release("Tab") |
135 | - self.keyboard.type("\n", delay=1) |
136 | - self.keyboard.press_and_release("Tab") |
137 | - self.keyboard.press_and_release("Down") |
138 | - self.keyboard.press_and_release("Down") |
139 | - self.keyboard.press_and_release("Down") |
140 | - self.keyboard.press_and_release("Down") |
141 | - self.keyboard.press_and_release("Down", delay=0.3) |
142 | - |
143 | - #Verify colors have changed |
144 | - |
145 | - #Put configuration back as it was |
146 | - self.keyboard.press_and_release("Up") |
147 | - self.keyboard.press_and_release("Up") |
148 | - self.keyboard.press_and_release("Up") |
149 | - self.keyboard.press_and_release("Up") |
150 | - self.keyboard.press_and_release("Up") |
151 | - |
152 | - |
153 | - #Change text color |
154 | - self.keyboard.press_and_release("Tab") |
155 | - self.keyboard.type("\n") |
156 | - self.keyboard.type("\n") |
157 | - self.keyboard.press_and_release("Alt+s") |
158 | - |
159 | - #Verify text color has changed |
160 | - |
161 | - |
162 | - #Put text color back as it was |
163 | - self.keyboard.type("\n", delay=1) |
164 | - self.keyboard.press_and_release("Down") |
165 | - self.keyboard.press_and_release("Down") |
166 | - self.keyboard.press_and_release("Down") |
167 | - self.keyboard.type("\n") |
168 | - self.keyboard.press_and_release("Alt+s") |
169 | - self.keyboard.press_and_release("Shift+Tab") |
170 | - self.keyboard.press_and_release("Shift+Tab") |
171 | - self.keyboard.type("\n") |
172 | - |
173 | - #Set a Background Image |
174 | - self.keyboard.press_and_release("Shift+Tab") |
175 | - self.keyboard.press_and_release("Right") |
176 | - self.keyboard.press_and_release("Alt+b") |
177 | - self.keyboard.press_and_release("Alt+f") |
178 | - self.keyboard.press_and_release("Space") |
179 | - self.keyboard.type("/usr/share/backgrounds/Leftover_by_Sagar_Jain.jpg") |
180 | - self.keyboard.press_and_release("Alt+o") |
181 | - self.keyboard.press_and_release("Tab") |
182 | - self.keyboard.press_and_release("Tab") |
183 | - self.keyboard.press_and_release("Space") |
184 | - |
185 | - #Verify Terminal background changes |
186 | - |
187 | - |
188 | - #Put Terminal background back as it was |
189 | - self.keyboard.press_and_release("Alt+s") |
190 | - self.keyboard.press_and_release("Space", delay=0.2) |
191 | - |
192 | - #Close Profile preferences window |
193 | - self.keyboard.press_and_release("Alt+c") |
194 | - |
195 | - #Change the Zoom Level |
196 | - self.keyboard.press_and_release("Ctrl+plus") |
197 | - self.keyboard.press_and_release("Ctrl+plus") |
198 | - self.keyboard.press_and_release("Ctrl+plus") |
199 | - self.keyboard.press_and_release("Ctrl+plus") |
200 | - self.keyboard.press_and_release("Ctrl+-") |
201 | - self.keyboard.press_and_release("Ctrl+-") |
202 | - |
203 | - #Verify zoom level has changed |
204 | - |
205 | - |
206 | - #Put Zoom level back as it was |
207 | - self.keyboard.press_and_release("Ctrl+0") |
208 | - |
209 | - |
210 | - def test_terminal_coloring(self): |
211 | - #Test-case name: gnometerminal/ter-003 |
212 | - #This test will check that terminal coloring is active |
213 | - |
214 | - #Type in touch /tmp/text1.txt |
215 | - self.keyboard.type("touch /tmp/text1.txt\n") |
216 | - |
217 | - #Type in ls |
218 | - self.keyboard.type("ls /tmp\n") |
219 | - |
220 | - #Verify txt is in black |
221 | - |
222 | - |
223 | - #Type in chmod 777 text1.txt |
224 | - self.keyboard.type("chmod 777 /tmp/text1.txt\n") |
225 | - |
226 | - #Type in ls |
227 | - self.keyboard.type("ls /tmp\n") |
228 | - |
229 | - |
230 | - #Verify txt should now be green |
231 | - |
232 | - #Delete the file we created |
233 | - self.addCleanup(os.remove, "/tmp/text1.txt") |
234 | - |
235 | - |
236 | - def test_launch_terminal(self): |
237 | - #Test-case name: gnometerminal/ter-004 |
238 | - #This test will check that the terminal tab launches succesfully |
239 | - |
240 | - |
241 | - #Open Terminal using the dash, and typing 'terminal' |
242 | - self.keyboard.press_and_release("Super") |
243 | - self.keyboard.type("terminal\n") |
244 | - |
245 | - #Is an instance of gnome-terminal with the title '@: ~' opened, with the current directory set to the users home directory? |
246 | - |
247 | - |
248 | - #Close opened terminal |
249 | - self.keyboard.press_and_release("Ctrl+d", delay=0.2) |
250 | - |
251 | - #Press Ctrl+Alt+T |
252 | - self.keyboard.press_and_release("Ctrl+Alt+t") |
253 | - |
254 | - #Is an instance of gnome-terminal with the title '@: ~' opened, with the current directory set to the users home directory? |
255 | - |
256 | - |
257 | - #Close opened terminal |
258 | - self.keyboard.press_and_release("Ctrl+d") |
259 | - self.keyboard.press_and_release("Ctrl+d") |
260 | - #Had to put two Ctrl+d's as the first one closes the terminal that opens with the launch of this test |
261 | - |
262 | - |
263 | - def test_new_title(self): |
264 | - #Test-case name: gnometerminal/ter-005 |
265 | - #This test will check that the terminal can be given a new title |
266 | - |
267 | - #From the main menu select 'Terminal > Set Title...' |
268 | - self.keyboard.press_and_release("Alt+t", delay=0.5) |
269 | - self.keyboard.press_and_release("s", delay=0.5) |
270 | - |
271 | - #Verify the Set Title dialog appears |
272 | - #Check to see that the title of the window is "Set Title" |
273 | - #self.assertThat(lambda: self.app.title, Eventually(Contains("Set Title"))) |
274 | - |
275 | - |
276 | - #Enter 'Test Title' and click OK |
277 | - self.keyboard.type("Test Title") |
278 | - self.keyboard.press_and_release("Alt+o") |
279 | - |
280 | - #Is the title of the window now 'Test Title'? |
281 | - #Check to see that the title reflects our 'Test Title' |
282 | - self.assertThat(lambda: self.app.name, Eventually(Contains("Test Title"))) |
283 | - |
284 | -def _generateTempFileName(): |
285 | - #Create temporary file, then close it, so we can re-use the file name |
286 | - sFile = tempfile.NamedTemporaryFile() |
287 | - sFile.close() |
288 | - return sFile.name |
289 | - |
290 | - |
291 | + def test_create_directory(self): |
292 | + self.keyboard.type('mkdir /tmp/temp-dir\n') |
293 | + self.assertTrue('/tmp/temp-dir/', DirExists()) |
294 | + self.addCleanup(os.removedirs, '/tmp/temp-dir') |
295 | + |
296 | + def test_directory_contains_files(self): |
297 | + self.create_temp_directory_with_temp_files() |
298 | + self.assertTrue('/tmp/temp-dir/', DirContains(['a', 'b', 'c'])) |
299 | + self.addCleanup(shutil.rmtree, '/tmp/temp-dir') |
300 | + |
301 | + def test_move_directory_with_files(self): |
302 | + self.create_temp_directory_with_temp_files() |
303 | + #create directory to move to |
304 | + self.keyboard.type('mkdir /tmp/temp-dir2\n') |
305 | + #move temp-dir to temp-dir2 |
306 | + self.keyboard.type('mv /tmp/temp-dir/ /tmp/temp-dir2/\n') |
307 | + #assert dir moved |
308 | + self.assertTrue('/tmp/temp-dir2/temp-dir/', DirExists()) |
309 | + ##assert files moved |
310 | + self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c'])) |
311 | + |
312 | + self.addCleanup(shutil.rmtree, '/tmp/temp-dir2') |
313 | + |
314 | + def test_copying_file(self): |
315 | + self.create_temp_directory_with_temp_files() |
316 | + #create directory to move to |
317 | + self.keyboard.type('mkdir /tmp/temp-dir2\n') |
318 | + #move file 'a' to temp-dir2 |
319 | + self.keyboard.type('cp /tmp/temp-dir/a /tmp/temp-dir2/\n') |
320 | + ##assert file moved |
321 | + self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a'])) |
322 | + self.addCleanup(shutil.rmtree, '/tmp/temp-dir') |
323 | + self.addCleanup(shutil.rmtree, '/tmp/temp-dir2') |
324 | + |
325 | + |
326 | +class TerminalWindowTests(TerminalAutopilotTestCase): |
327 | + |
328 | + def test_window_visible(self): |
329 | + terminal_window = self.app.select_single('TerminalWindow') |
330 | + self.assertThat(terminal_window.visible, Eventually(Equals(1))) |
331 | + |
332 | + def test_window_title(self): |
333 | + terminal_window = self.app.select_single('TerminalWindow') |
334 | + self.assertThat(terminal_window.title, Eventually(Contains('~'))) |
335 | + |
336 | + def test_window_title_changes_when_changing_directory(self): |
337 | + terminal_window = self.app.select_single('TerminalWindow') |
338 | + self.keyboard.type('cd\n') |
339 | + self.keyboard.type('cd Documents\n') |
340 | + self.assertThat(terminal_window.title, Eventually(Contains('~/Documents'))) |
341 | + |
342 | + def test_open_new_tab(self, ): |
343 | + #open a new tab |
344 | + self.keyboard.press_and_release('Ctrl+Shift+t') |
345 | + # test number of tabs(containers) equals 2 |
346 | + tabs = self.app.select_many('TerminalScreenContainer') |
347 | + self.assertThat(len(tabs), Equals(2)) |
348 |
Ouch.. I didn't realize how limited your introspection on this could be. Have we mentioned this to Martin? Probably should file a bug on it. That said, let's roll with this as noted.