Merge lp:~lderan/ubuntu-autopilot-tests/xubuntu-tests into lp:ubuntu-autopilot-tests

Proposed by Thomas Molloy
Status: Merged
Approved by: Dan Chapman 
Approved revision: 63
Merged at revision: 63
Proposed branch: lp:~lderan/ubuntu-autopilot-tests/xubuntu-tests
Merge into: lp:ubuntu-autopilot-tests
Diff against target: 171 lines (+161/-0)
2 files modified
xubuntu_autopilot_tests/xfce4-terminal/__init__.py (+44/-0)
xubuntu_autopilot_tests/xfce4-terminal/test_terminal.py (+117/-0)
To merge this branch: bzr merge lp:~lderan/ubuntu-autopilot-tests/xubuntu-tests
Reviewer Review Type Date Requested Status
Dan Chapman  (community) Approve
Review via email: mp+201649@code.launchpad.net

Description of the change

Converted the terminal test for the gnome terminal to work with the xfce terminal and put it into the Xubuntu specific directory

To post a comment you must log in.
Revision history for this message
Dan Chapman  (dpniel) wrote :

LGTM. Thanks :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'xubuntu_autopilot_tests/xfce4-terminal'
2=== added file 'xubuntu_autopilot_tests/xfce4-terminal/__init__.py'
3--- xubuntu_autopilot_tests/xfce4-terminal/__init__.py 1970-01-01 00:00:00 +0000
4+++ xubuntu_autopilot_tests/xfce4-terminal/__init__.py 2014-01-14 19:02:54 +0000
5@@ -0,0 +1,44 @@
6+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
7+#
8+# Copyright (C) 2013
9+#
10+# Author: Daniel Chapman daniel@chapman-mail.com
11+#
12+# This program is free software; you can redistribute it and/or modify
13+# it under the terms of the GNU Lesser General Public License as published by
14+# the Free Software Foundation; version 3.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Lesser General Public License for more details.
20+#
21+# You should have received a copy of the GNU Lesser General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+from autopilot.testcase import AutopilotTestCase
24+from autopilot.matchers import Eventually
25+from testtools.matchers import Equals, Contains, FileExists, DirExists
26+import tempfile
27+import os
28+
29+
30+HOME_DIR = os.getenv('HOME')
31+
32+
33+class TerminalAutopilotTestCase(AutopilotTestCase):
34+
35+ def setUp(self):
36+ super(TerminalAutopilotTestCase, self).setUp()
37+ # print(HOME_DIR)
38+ self.app = self.launch_test_application('gnome-terminal',
39+ '--working-directory=' +
40+ HOME_DIR,
41+ '--disable-factory'
42+ )
43+
44+ def create_temp_directory_with_temp_files(self):
45+ """ Creates a temp directory with temp files 'a' 'b' and 'c' """
46+ self.keyboard.type('mkdir /tmp/temp-dir\n')
47+ self.keyboard.type('touch /tmp/temp-dir/a\n')
48+ self.keyboard.type('touch /tmp/temp-dir/b\n')
49+ self.keyboard.type('touch /tmp/temp-dir/c\n')
50
51=== added file 'xubuntu_autopilot_tests/xfce4-terminal/test_terminal.py'
52--- xubuntu_autopilot_tests/xfce4-terminal/test_terminal.py 1970-01-01 00:00:00 +0000
53+++ xubuntu_autopilot_tests/xfce4-terminal/test_terminal.py 2014-01-14 19:02:54 +0000
54@@ -0,0 +1,117 @@
55+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
56+#
57+# Copyright (C) 2013
58+#
59+# Author: Daniel Chapman daniel@chapman-mail.com
60+#
61+# This program is free software; you can redistribute it and/or modify
62+# it under the terms of the GNU Lesser General Public License as published by
63+# the Free Software Foundation; version 3.
64+#
65+# This program is distributed in the hope that it will be useful,
66+# but WITHOUT ANY WARRANTY; without even the implied warranty of
67+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68+# GNU Lesser General Public License for more details.
69+#
70+# You should have received a copy of the GNU Lesser General Public License
71+# along with this program. If not, see <http://www.gnu.org/licenses/>.
72+import os
73+import shutil
74+import tempfile
75+from autopilot.matchers import Eventually
76+from autopilot.testcase import AutopilotTestCase
77+from autopilot.process import ProcessManager
78+from testtools.matchers import Equals, Contains, FileExists, DirExists, \
79+ DirContains
80+
81+# register xfce4 terminal
82+ProcessManager.register_known_application(
83+ "xfce4-terminal",
84+ "xfce4-terminal.desktop",
85+ "xfce4-terminal")
86+
87+
88+class TerminalFileSystemTests(AutopilotTestCase):
89+ """ File writing tests for the Xfce4 terminal emulator """
90+
91+ def setUp(self):
92+ """ Basic setup instruction to run before each test """
93+ super(TerminalFileSystemTests, self).setUp()
94+ self.manager = ProcessManager.create('BAMF')
95+ self.app = self.manager.start_app("xfce4-terminal")
96+ self.assertTrue(self.app.is_active)
97+
98+ def test_save_a_file(self):
99+ self.keyboard.type("touch /tmp/test-file\n")
100+ # Verify that test-file has been created
101+ self.assertTrue('/tmp/testfile', FileExists())
102+ # Delete the file we created
103+ self.addCleanup(os.remove, "/tmp/test-file")
104+
105+ def test_create_directory(self):
106+ self.keyboard.type('mkdir /tmp/temp-dir\n')
107+ self.assertTrue('/tmp/temp-dir/', DirExists())
108+ self.addCleanup(os.removedirs, '/tmp/temp-dir')
109+
110+ def test_directory_contains_files(self):
111+ self.create_temp_directory_with_temp_files()
112+ self.assertTrue('/tmp/temp-dir/', DirContains(['a', 'b', 'c']))
113+ self.addCleanup(shutil.rmtree, '/tmp/temp-dir')
114+
115+ def test_move_directory_with_files(self):
116+ self.create_temp_directory_with_temp_files()
117+ # create directory to move to
118+ self.keyboard.type('mkdir /tmp/temp-dir2\n')
119+ # move temp-dir to temp-dir2
120+ self.keyboard.type('mv /tmp/temp-dir/ /tmp/temp-dir2/\n')
121+ # assert dir moved
122+ self.assertTrue('/tmp/temp-dir2/temp-dir/', DirExists())
123+ # assert files moved
124+ self.assertTrue(
125+ '/tmp/temp-dir2/temp-dir/', DirContains(['a', 'b', 'c']))
126+
127+ self.addCleanup(shutil.rmtree, '/tmp/temp-dir2')
128+
129+ def test_copying_file(self):
130+ self.create_temp_directory_with_temp_files()
131+ # create directory to move to
132+ self.keyboard.type('mkdir /tmp/temp-dir2\n')
133+ # move file 'a' to temp-dir2
134+ self.keyboard.type('cp /tmp/temp-dir/a /tmp/temp-dir2/\n')
135+ # assert file moved
136+ self.assertTrue('/tmp/temp-dir2/temp-dir/', DirContains(['a']))
137+ self.addCleanup(shutil.rmtree, '/tmp/temp-dir')
138+ self.addCleanup(shutil.rmtree, '/tmp/temp-dir2')
139+
140+
141+class TerminalWindowTests(AutopilotTestCase):
142+ """ Window tests for the Xfce4 terminal emulator """
143+
144+ def setUp(self):
145+ """ Basic setup instruction to run before each test """
146+ super(TerminalWindowTests, self).setUp()
147+ self.manager = ProcessManager.create('BAMF')
148+ self.app = self.manager.start_app("xfce4-terminal")
149+ self.assertTrue(self.app.is_active)
150+
151+ def test_window_visible(self):
152+ terminal_window = self.app.select_single('TerminalWindow')
153+ self.assertThat(terminal_window.visible, Eventually(Equals(1)))
154+
155+ def test_window_title(self):
156+ terminal_window = self.app.select_single('TerminalWindow')
157+ self.assertThat(terminal_window.title, Eventually(Contains('~')))
158+
159+ def test_window_title_changes_when_changing_directory(self):
160+ terminal_window = self.app.select_single('TerminalWindow')
161+ self.keyboard.type('cd\n')
162+ self.keyboard.type('cd Documents\n')
163+ self.assertThat(
164+ terminal_window.title, Eventually(Contains('~/Documents')))
165+
166+ def test_open_new_tab(self, ):
167+ # open a new tab
168+ self.keyboard.press_and_release('Ctrl+Shift+t')
169+ # test number of tabs(containers) equals 2
170+ tabs = self.app.select_many('TerminalScreenContainer')
171+ self.assertThat(len(tabs), Equals(2))

Subscribers

People subscribed via source and target branches