Jean-Baptiste Lallement has proposed merging 
lp:~jibel/ubuntu-server-iso-testing/test-emptystartupapp into 
lp:ubuntu-server-iso-testing.

Requested reviews:
  Ubuntu Server Iso Testing Developers (ubuntu-server-iso-testing-dev)

For more details, see:
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/test-emptystartupapp/+merge/80223

work item from 
https://blueprints.launchpad.net/ubuntu/+spec/desktop-o-startup-applications 
which was initially assigned to the desktop team.
-- 
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/test-emptystartupapp/+merge/80223
Your team Ubuntu Server Iso Testing Developers is requested to review the 
proposed merge of lp:~jibel/ubuntu-server-iso-testing/test-emptystartupapp into 
lp:ubuntu-server-iso-testing.
=== added file 'templates.desktop/test_cases/default/test_apps'
--- templates.desktop/test_cases/default/test_apps	1970-01-01 00:00:00 +0000
+++ templates.desktop/test_cases/default/test_apps	2011-10-24 14:06:23 +0000
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+# 
+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
+#
+# This file is part of ubuntu-server-iso-testing.
+# 
+# ubuntu-server-iso-testing is free software: you can redistribute it 
+# and/or modify it under the terms of the GNU General Public License 
+# as published by the Free Software Foundation, either version 3 of 
+# the License, or (at your option) any later version.
+# 
+# ubuntu-server-iso-testing is distributed in the hope that it will 
+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with ubuntu-server-iso-testing.  If not, see 
+# <http://www.gnu.org/licenses/>.
+# 
+""" Basic Desktop Application tests """
+
+import logging
+import os.path
+import unittest
+import subprocess
+from time import sleep
+from tempfile import NamedTemporaryFile
+
+logging.basicConfig(level=logging.DEBUG)
+
+class ApplicationsTest(unittest.TestCase):
+    """Main Test Class"""
+
+    def test_empty_startupapp(self):
+        """Test that startup application list is empty"""
+
+        # Imagemagick required
+        try:
+            cmd = ['dpkg-query', '-W', '-f', '${Status}', 'imagemagick']
+            output = subprocess.Popen(cmd, stdout = subprocess.PIPE
+                                     ).communicate()[0]
+            if not output.startswith('install'):
+                raise Exception('imagemagick is not installed')
+        except:
+            raise Exception('imagemagick is not correctly installed.\
+Please check your setup')
+
+        appname = "gnome-session-properties"
+        wm_name = "Startup Applications Preferences"
+        # Start gnome-session-properties
+        proc = subprocess.Popen(appname)
+        sleep(1)
+
+        # Generate a bunch of temporary file names
+        (imgxwd, imgpng, imgblank, imgdiff) = [
+            NamedTemporaryFile().name+ '.' + ext
+            for ext in ('xwd','png','blank.png','diff.png')
+        ]
+
+        # Take a screenshot of the window and crop the application list
+        # don't bother with decorations that will changes depending on
+        # designer's mood
+        imgsize = '400x300'
+        cmd = ['xwd', '-name', wm_name, '-out', imgxwd ]
+        subprocess.check_call(cmd)
+        cmd = ['convert', '-crop', imgsize + '+30+55', '-monochrome', imgxwd,
+               imgpng]
+        subprocess.check_call(cmd)
+
+        # Compare to an empty image
+        cmd = ['convert', '-size', imgsize, 'xc:white', imgblank]
+        subprocess.check_call(cmd)
+
+        imgpng = '/tmp/xxx.png'
+
+        output = None
+        try:
+            # Note: compare outputs to stderr
+            cmd = ['compare', '-metric', 'AE', imgpng, imgblank, imgdiff]
+            output = subprocess.Popen(cmd, stderr = subprocess.PIPE
+                                     ).communicate()[1]
+            self.assertEqual(output.strip(), '0')
+            os.unlink(imgdiff)
+        except:
+            raise AssertionError("'compare' call failed: %s", output)
+        finally:
+            # Close gnome-session-properties and clean temp files
+            proc.kill()
+            os.unlink(imgxwd)
+            os.unlink(imgpng)
+            os.unlink(imgblank)
+
+if __name__ == '__main__':
+    """ Main loop """
+    unittest.main()

_______________________________________________
Mailing list: https://launchpad.net/~ubuntu-server-iso-testing-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~ubuntu-server-iso-testing-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to