Merge lp:~jibel/ubuntu-server-iso-testing/test-emptystartupapp into lp:ubuntu-server-iso-testing

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 249
Proposed branch: lp:~jibel/ubuntu-server-iso-testing/test-emptystartupapp
Merge into: lp:ubuntu-server-iso-testing
Diff against target: 98 lines (+94/-0)
1 file modified
templates.desktop/test_cases/default/test_apps (+94/-0)
To merge this branch: bzr merge lp:~jibel/ubuntu-server-iso-testing/test-emptystartupapp
Reviewer Review Type Date Requested Status
Ubuntu Server Iso Testing Developers Pending
Review via email: mp+80223@code.launchpad.net

Description of the change

work item from https://blueprints.launchpad.net/ubuntu/+spec/desktop-o-startup-applications which was initially assigned to the desktop team.

To post a comment you must log in.
250. By Jean-Baptiste Lallement

removed debugging code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'templates.desktop/test_cases/default/test_apps'
2--- templates.desktop/test_cases/default/test_apps 1970-01-01 00:00:00 +0000
3+++ templates.desktop/test_cases/default/test_apps 2011-10-25 13:54:23 +0000
4@@ -0,0 +1,94 @@
5+#!/usr/bin/python
6+#
7+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
8+#
9+# This file is part of ubuntu-server-iso-testing.
10+#
11+# ubuntu-server-iso-testing is free software: you can redistribute it
12+# and/or modify it under the terms of the GNU General Public License
13+# as published by the Free Software Foundation, either version 3 of
14+# the License, or (at your option) any later version.
15+#
16+# ubuntu-server-iso-testing is distributed in the hope that it will
17+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with ubuntu-server-iso-testing. If not, see
23+# <http://www.gnu.org/licenses/>.
24+#
25+""" Basic Desktop Application tests """
26+
27+import logging
28+import os.path
29+import unittest
30+import subprocess
31+from time import sleep
32+from tempfile import NamedTemporaryFile
33+
34+logging.basicConfig(level=logging.DEBUG)
35+
36+class ApplicationsTest(unittest.TestCase):
37+ """Main Test Class"""
38+
39+ def test_empty_startupapp(self):
40+ """Test that startup application list is empty"""
41+
42+ # Imagemagick required
43+ try:
44+ cmd = ['dpkg-query', '-W', '-f', '${Status}', 'imagemagick']
45+ output = subprocess.Popen(cmd, stdout = subprocess.PIPE
46+ ).communicate()[0]
47+ if not output.startswith('install'):
48+ raise Exception('imagemagick is not installed')
49+ except:
50+ raise Exception('imagemagick is not correctly installed.\
51+Please check your setup')
52+
53+ appname = "gnome-session-properties"
54+ wm_name = "Startup Applications Preferences"
55+ # Start gnome-session-properties
56+ proc = subprocess.Popen(appname)
57+ sleep(1)
58+
59+ # Generate a bunch of temporary file names
60+ (imgxwd, imgpng, imgblank, imgdiff) = [
61+ NamedTemporaryFile().name+ '.' + ext
62+ for ext in ('xwd','png','blank.png','diff.png')
63+ ]
64+
65+ # Take a screenshot of the window and crop the application list
66+ # don't bother with decorations that will changes depending on
67+ # designer's mood
68+ imgsize = '400x300'
69+ cmd = ['xwd', '-name', wm_name, '-out', imgxwd ]
70+ subprocess.check_call(cmd)
71+ cmd = ['convert', '-crop', imgsize + '+30+55', '-monochrome', imgxwd,
72+ imgpng]
73+ subprocess.check_call(cmd)
74+
75+ # Compare to an empty image
76+ cmd = ['convert', '-size', imgsize, 'xc:white', imgblank]
77+ subprocess.check_call(cmd)
78+
79+ output = None
80+ try:
81+ # Note: compare outputs to stderr
82+ cmd = ['compare', '-metric', 'AE', imgpng, imgblank, imgdiff]
83+ output = subprocess.Popen(cmd, stderr = subprocess.PIPE
84+ ).communicate()[1]
85+ self.assertEqual(output.strip(), '0')
86+ os.unlink(imgdiff)
87+ except:
88+ raise AssertionError("'compare' call failed: %s", output)
89+ finally:
90+ # Close gnome-session-properties and clean temp files
91+ proc.kill()
92+ os.unlink(imgxwd)
93+ os.unlink(imgpng)
94+ os.unlink(imgblank)
95+
96+if __name__ == '__main__':
97+ """ Main loop """
98+ unittest.main()

Subscribers

People subscribed via source and target branches