1# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX 2# All rights reserved. 3# 4# This software is provided without warranty under the terms of the BSD 5# license included in LICENSE.txt and may be redistributed only under 6# the conditions described in the aforementioned license. The license 7# is also available online at http://www.enthought.com/licenses/BSD.txt 8# 9# Thanks for using Enthought open source! 10 11 12import os 13import unittest 14 15from ..image_cache import ImageCache 16 17IMAGE_PATH = os.path.join(os.path.dirname(__file__), "images", "core.png") 18 19 20class TestPyfaceResourceFactory(unittest.TestCase): 21 def setUp(self): 22 self.image_cache = ImageCache(32, 32) 23 24 def test_get_image(self): 25 image = self.image_cache.get_image(IMAGE_PATH) 26 27 def test_get_bitmap(self): 28 bitmap = self.image_cache.get_bitmap(IMAGE_PATH) 29 30 def test_get_image_twice(self): 31 image1 = self.image_cache.get_image(IMAGE_PATH) 32 image2 = self.image_cache.get_image(IMAGE_PATH) 33 34 def test_get_bitmap_twice(self): 35 bitmap1 = self.image_cache.get_bitmap(IMAGE_PATH) 36 bitmap2 = self.image_cache.get_bitmap(IMAGE_PATH) 37 38 def test_get_image_different_sizes(self): 39 other_image_cache = ImageCache(48, 48) 40 image1 = self.image_cache.get_image(IMAGE_PATH) 41 image2 = other_image_cache.get_image(IMAGE_PATH) 42 self.assertNotEqual(image1, image2) 43 44 def test_get_bitmap_different_sizes(self): 45 other_image_cache = ImageCache(48, 48) 46 bitmap1 = self.image_cache.get_bitmap(IMAGE_PATH) 47 bitmap2 = other_image_cache.get_bitmap(IMAGE_PATH) 48 self.assertNotEqual(bitmap1, bitmap2) 49