aboutsummaryrefslogtreecommitdiffstats
path: root/test/uitests.sikuli/datafiles.py
blob: 4db8b278ef153585e6a122909f98d679d3fdf07b (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Default Device Conversion Parameters
import os

class TestData(object):
    _UNITTESTFILES = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"..","..","..",'testdata'))
    _SIKTESTFILES = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'testdata'))

    _FILES = {
                'mp3-0.mp3':   {
                                'testdir': _UNITTESTFILES,
                                'container': 'mp3',
                                'audio_codec': 'mp3',
                                'title': 'Invisible Walls',
                                'artist': 'Revolution Void',
                                'album': 'Increase The Dosage',
                                'track': '1',
                                'genre': 'Blues',
                                'duration': 1.07
                               },
               'mp3-1.mp3':
                              {
                                'testdir': _UNITTESTFILES,
                                'container': 'mp3',
                                'audio_codec': 'mp3',
                                'title': 'Race Lieu',
                                'artist': 'Ckz',
                                'album': 'The Heart EP',
                                'track': '2/5',
                                'duration': 1.07
                              },

               'mp3-2.mp3':
                               {
                                'testdir': _UNITTESTFILES,
                                'container': 'mp3',
                                'audio_codec': 'mp3',
                                'artist': 'This American Life',
                                'genre': 'Podcast',
                                'title': '#426: Tough Room 2011',
                                'duration': 1.09
                               },

               'theora_with_ogg_extension.ogg':
                               {
                                'testdir': _UNITTESTFILES,
                                'container': 'ogg',
                                'video_codec': 'theora',
                                'width': 320,
                                'height': 240,
                                'duration': 0.1},

               'webm-0.webm':
                               {'testdir': _UNITTESTFILES,
                                'container': ['matroska', 'webm'],
                                'video_codec': 'vp8',
                                'width': 1920,
                                'height': 912,
                                'duration': 0.43},

               'mp4-0.mp4':
                               {'testdir': _UNITTESTFILES,
                                'container': ['mov',
                                              'mp4',
                                              'm4a',
                                              '3gp',
                                              '3g2',
                                              'mj2',
                                              'isom',
                                              'mp41'],
                                'video_codec': 'h264',
                                'audio_codec': 'aac',
                                'width': 640,
                                'height': 480,
                                'title': 'Africa: Cash for Climate Change?',
                                'duration': 312.37},


               'nuls.mp3':
                               {
                                'testdir': _UNITTESTFILES,
                                'container': 'mp3',
                                'title': 'Invisible'},

               'drm.m4v':
                               {
                                'testdir': _UNITTESTFILES,
                                'container': ['mov',
                                              'mp4',
                                              'm4a',
                                              '3gp',
                                              '3g2',
                                              'mj2',
                                              'M4V',
                                              'mp42',
                                        'isom'],
                                'video_codec': 'none',
                                'audio_codec': 'aac',
                                'has_drm': ['audio', 'video'],
                                'width': 640,
                                'height': 480,
                                'title': 'Thinkers',
                                'artist': 'The Most Extreme',
                                'album': 'The Most Extreme',
                                'track': '10',
                                'genre': 'Nonfiction',
                                'duration': 2668.8},

                'baby_block.m4v': 
                               {
                                'testdir': _SIKTESTFILES,
                                'container': 'm4v',
                                'video_codec': 'h264',
                                'audio_codec': 'aac',
                                'width': 960,
                                'height': 540,
                               },
                'fake_video.mp4': # this is a fake mp4 file it is a pdf file renamed to an mp4 extension and should fail conversion
                               {
                                'testdir': _SIKTESTFILES,
                                'container': 'mp4',
                                'video_codec': None,
                                'audio_codec': None,
                                'width': None,
                                'height': None,
                               },
                'story_stuff.mov': 
                               {'testdir': _SIKTESTFILES,
                                'container': 'mov',
                                'video_codec': 'h264',
                                'audio_codec': 'mp3',
                                'width': 320,
                                'height': 180,
                               }

                 }

    def testfile_attr(self, testfile, default):
        try:
            return self._FILES[testfile][default]
        except:
            return None

    def directory_list(self, testdir):
        files_list = []
        for k, v in self._FILES.iteritems():
            if v.has_key('testdir') and testdir in v['testdir']:
                files_list.append(k)
        return files_list

    def test_data(self, many=True, new=False):
        """Grab a subset of the test files.
   
        Default selection is to use the unittest files, 
        but, if I need extra files, getting them from the sikuli test files dir.
        """
        DEFAULT_UNITTESTFILES = ['mp4-0.mp4', 'webm-0.webm']
        DEFAULT_SIKTESTFILES = ['baby_block.m4v', 'story_styff.mov']
        if new:
            TESTFILES = DEFAULT_SIKTESTFILES
        else:
            TESTFILES = DEFAULT_UNITTESTFILES

        DATADIR = self.testfile_attr(TESTFILES[0], 'testdir')

        if not many:
            TESTFILES = TESTFILES[:1]

        print TESTFILES
        return DATADIR, TESTFILES