File: test_image_support.py

package info (click to toggle)
quodlibet 4.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,228 kB
  • sloc: python: 89,728; sh: 381; xml: 110; makefile: 91
file content (42 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright 2017 Christoph Reiter
#
# This program 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 2 of the License, or
# (at your option) any later version.

from gi.repository import GdkPixbuf, Gdk

from tests import TestCase, get_data_path


class Timage_support(TestCase):
    """Mostly targeted at Windows/OSX, to make sure we package all the image
    decoders correctly
    """

    IMAGES = [
        "image.svg",
        "image.bmp",
        "image.png",
        "image.gif",
        "image.jpg",
    ]

    def test_create_pixbuf(self):
        supported_formats = GdkPixbuf.Pixbuf.get_formats()

        for name in self.IMAGES:
            extension = name.split(".")[-1]

            if any(extension in x.extensions for x in supported_formats):
                file_path = get_data_path(name)
                pb = GdkPixbuf.Pixbuf.new_from_file(file_path)
                assert pb
                assert pb.get_width() == 16
                assert pb.get_height() == 16

    def test_cursors(self):
        # make sure cursor images are packaged right
        cursor = Gdk.Cursor.new_from_name(Gdk.Display.get_default(), "default")
        assert cursor.get_surface()