7
7
from zim.parsing import url_encode, URL_ENCODE_READABLE
8
8
from zim.plugins.attachmentbrowser import *
10
class TestMimeData(tests.TestCase):
13
dir = Dir('./data/pixmaps')
14
for filename in dir.list():
15
file = dir.file(filename)
16
icon = get_mime_icon(file, THUMB_SIZE_NORMAL)
17
desc = get_mime_description(file.get_mimetype())
18
# TODO assert something on icon and text ?
11
21
class ThumbnailManagerTest(tests.TestCase):
23
def testCreateThumbnail(self):
14
24
manager = ThumbnailManager(preferences={})
15
25
dir = Dir('./data/pixmaps')
50
60
# TODO test detection of invalid thumbs
51
61
# TODO test with utf-8 char in image name
53
# Remove again and assert thumbnail does not exist
54
#~ manager.remove_thumbnails(file)
55
#~ for size in (THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE):
56
#~ thumbfile = manager.get_thumbnail_file(file, size)
57
#~ self.assertFalse(thumbfile.exists(), msg="File exists: %s" % thumbfile)
62
#~ def callback(file, size, thumbnail):
63
#~ seen[file] = thumbnail
65
#~ for file in dir.list_objects():
66
#~ manager.get_thumbnail_async(file, THUMB_SIZE_NORMAL, callback)
71
#~ for file in wanted:
72
#~ assert file in seen
64
def testAsyncCreateThumbnail(self):
65
manager = ThumbnailManager(preferences={})
66
dir = Dir('./data/pixmaps')
69
def on_thumbnail_ready(o, file, size, pixbuf):
71
manager.connect('thumbnail-ready', on_thumbnail_ready)
73
# Test API and functions
74
#~ for file in dir.list_objects(): # TODO
75
for filename in dir.list():
76
file = dir.file(filename)
78
# Remove and assert thumbnail does not exist
79
manager.remove_thumbnails(file)
80
for size in (THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE):
81
manager.get_thumbnail_async(file, size)
83
manager.async_queue.join()
84
self.assertTrue(len(seen) > 3)