]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_imageop.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_imageop.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_imageop.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_imageop.py
deleted file mode 100644 (file)
index 666a93c..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-#! /usr/bin/env python\r
-\r
-"""Test script for the imageop module.  This has the side\r
-   effect of partially testing the imgfile module as well.\r
-   Roger E. Masse\r
-"""\r
-\r
-from test.test_support import verbose, unlink, import_module, run_unittest\r
-\r
-imageop = import_module('imageop', deprecated=True)\r
-import uu, os, unittest\r
-\r
-\r
-SIZES = (1, 2, 3, 4)\r
-_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)\r
-VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES\r
-AAAAA = "A" * 1024\r
-MAX_LEN = 2**20\r
-\r
-\r
-class InputValidationTests(unittest.TestCase):\r
-\r
-    def _check(self, name, size=None, *extra):\r
-        func = getattr(imageop, name)\r
-        for height in VALUES:\r
-            for width in VALUES:\r
-                strlen = abs(width * height)\r
-                if size:\r
-                    strlen *= size\r
-                if strlen < MAX_LEN:\r
-                    data = "A" * strlen\r
-                else:\r
-                    data = AAAAA\r
-                if size:\r
-                    arguments = (data, size, width, height) + extra\r
-                else:\r
-                    arguments = (data, width, height) + extra\r
-                try:\r
-                    func(*arguments)\r
-                except (ValueError, imageop.error):\r
-                    pass\r
-\r
-    def check_size(self, name, *extra):\r
-        for size in SIZES:\r
-            self._check(name, size, *extra)\r
-\r
-    def check(self, name, *extra):\r
-        self._check(name, None, *extra)\r
-\r
-    def test_input_validation(self):\r
-        self.check_size("crop", 0, 0, 0, 0)\r
-        self.check_size("scale", 1, 0)\r
-        self.check_size("scale", -1, -1)\r
-        self.check_size("tovideo")\r
-        self.check("grey2mono", 128)\r
-        self.check("grey2grey4")\r
-        self.check("grey2grey2")\r
-        self.check("dither2mono")\r
-        self.check("dither2grey2")\r
-        self.check("mono2grey", 0, 0)\r
-        self.check("grey22grey")\r
-        self.check("rgb2rgb8") # nlen*4 == len\r
-        self.check("rgb82rgb")\r
-        self.check("rgb2grey")\r
-        self.check("grey2rgb")\r
-\r
-\r
-def test_main():\r
-\r
-    run_unittest(InputValidationTests)\r
-\r
-    try:\r
-        import imgfile\r
-    except ImportError:\r
-        return\r
-\r
-    # Create binary test files\r
-    uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')\r
-\r
-    image, width, height = getimage('test'+os.extsep+'rgb')\r
-\r
-    # Return the selected part of image, which should by width by height\r
-    # in size and consist of pixels of psize bytes.\r
-    if verbose:\r
-        print 'crop'\r
-    newimage = imageop.crop (image, 4, width, height, 0, 0, 1, 1)\r
-\r
-    # Return image scaled to size newwidth by newheight. No interpolation\r
-    # is done, scaling is done by simple-minded pixel duplication or removal.\r
-    # Therefore, computer-generated images or dithered images will\r
-    # not look nice after scaling.\r
-    if verbose:\r
-        print 'scale'\r
-    scaleimage = imageop.scale(image, 4, width, height, 1, 1)\r
-\r
-    # Run a vertical low-pass filter over an image. It does so by computing\r
-    # each destination pixel as the average of two vertically-aligned source\r
-    # pixels. The main use of this routine is to forestall excessive flicker\r
-    # if the image two vertically-aligned source pixels,  hence the name.\r
-    if verbose:\r
-        print 'tovideo'\r
-    videoimage = imageop.tovideo (image, 4, width, height)\r
-\r
-    # Convert an rgb image to an 8 bit rgb\r
-    if verbose:\r
-        print 'rgb2rgb8'\r
-    greyimage = imageop.rgb2rgb8(image, width, height)\r
-\r
-    # Convert an 8 bit rgb image to a 24 bit rgb image\r
-    if verbose:\r
-        print 'rgb82rgb'\r
-    image = imageop.rgb82rgb(greyimage, width, height)\r
-\r
-    # Convert an rgb image to an 8 bit greyscale image\r
-    if verbose:\r
-        print 'rgb2grey'\r
-    greyimage = imageop.rgb2grey(image, width, height)\r
-\r
-    # Convert an 8 bit greyscale image to a 24 bit rgb image\r
-    if verbose:\r
-        print 'grey2rgb'\r
-    image = imageop.grey2rgb(greyimage, width, height)\r
-\r
-    # Convert a 8-bit deep greyscale image to a 1-bit deep image by\r
-    # thresholding all the pixels. The resulting image is tightly packed\r
-    # and is probably only useful as an argument to mono2grey.\r
-    if verbose:\r
-        print 'grey2mono'\r
-    monoimage = imageop.grey2mono (greyimage, width, height, 0)\r
-\r
-    # monoimage, width, height = getimage('monotest.rgb')\r
-    # Convert a 1-bit monochrome image to an 8 bit greyscale or color image.\r
-    # All pixels that are zero-valued on input get value p0 on output and\r
-    # all one-value input pixels get value p1 on output. To convert a\r
-    # monochrome  black-and-white image to greyscale pass the values 0 and\r
-    # 255 respectively.\r
-    if verbose:\r
-        print 'mono2grey'\r
-    greyimage = imageop.mono2grey (monoimage, width, height, 0, 255)\r
-\r
-    # Convert an 8-bit greyscale image to a 1-bit monochrome image using a\r
-    # (simple-minded) dithering algorithm.\r
-    if verbose:\r
-        print 'dither2mono'\r
-    monoimage = imageop.dither2mono (greyimage, width, height)\r
-\r
-    # Convert an 8-bit greyscale image to a 4-bit greyscale image without\r
-    # dithering.\r
-    if verbose:\r
-        print 'grey2grey4'\r
-    grey4image = imageop.grey2grey4 (greyimage, width, height)\r
-\r
-    # Convert an 8-bit greyscale image to a 2-bit greyscale image without\r
-    # dithering.\r
-    if verbose:\r
-        print 'grey2grey2'\r
-    grey2image = imageop.grey2grey2 (greyimage, width, height)\r
-\r
-    # Convert an 8-bit greyscale image to a 2-bit greyscale image with\r
-    # dithering. As for dither2mono, the dithering algorithm is currently\r
-    # very simple.\r
-    if verbose:\r
-        print 'dither2grey2'\r
-    grey2image = imageop.dither2grey2 (greyimage, width, height)\r
-\r
-    # Convert a 4-bit greyscale image to an 8-bit greyscale image.\r
-    if verbose:\r
-        print 'grey42grey'\r
-    greyimage = imageop.grey42grey (grey4image, width, height)\r
-\r
-    # Convert a 2-bit greyscale image to an 8-bit greyscale image.\r
-    if verbose:\r
-        print 'grey22grey'\r
-    image = imageop.grey22grey (grey2image, width, height)\r
-\r
-    # Cleanup\r
-    unlink('test'+os.extsep+'rgb')\r
-\r
-def getimage(name):\r
-    """return a tuple consisting of\r
-       image (in 'imgfile' format) width and height\r
-    """\r
-    import imgfile\r
-    try:\r
-        sizes = imgfile.getsizes(name)\r
-    except imgfile.error:\r
-        name = get_qualified_path(name)\r
-        sizes = imgfile.getsizes(name)\r
-    if verbose:\r
-        print 'imgfile opening test image: %s, sizes: %s' % (name, str(sizes))\r
-\r
-    image = imgfile.read(name)\r
-    return (image, sizes[0], sizes[1])\r
-\r
-def get_qualified_path(name):\r
-    """ return a more qualified path to name"""\r
-    import sys\r
-    import os\r
-    path = sys.path\r
-    try:\r
-        path = [os.path.dirname(__file__)] + path\r
-    except NameError:\r
-        pass\r
-    for dir in path:\r
-        fullname = os.path.join(dir, name)\r
-        if os.path.exists(fullname):\r
-            return fullname\r
-    return name\r
-\r
-if __name__ == '__main__':\r
-    test_main()\r