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

Subscribers

People subscribed via source and target branches