]> git.sesse.net Git - vlc/blob - bindings/python-ctypes/test.py
bd0c4a3d9944c586f36a541e12b1da5f37ed7b56
[vlc] / bindings / python-ctypes / test.py
1 #! /usr/bin/python
2
3 #
4 # Code generator for python ctypes bindings for VLC
5 # Copyright (C) 2009 the VideoLAN team
6 # $Id: $
7 #
8 # Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 #
24
25 """Unittest module.
26 """
27
28 import unittest
29 import vlc
30
31 class TestVLCAPI(unittest.TestCase):
32     #def setUp(self):
33     #    self.seq = range(10)
34     #self.assert_(element in self.seq)
35
36     # We check enum definitions against hardcoded values. In case of
37     # failure, check that the reason is not a change in the .h
38     # definitions.
39     def test_enum_event_type(self):
40         self.assertEqual(vlc.EventType.MediaStateChanged, 5)
41
42     def test_enum_meta(self):
43         self.assertEqual(vlc.Meta.Description, 6)
44
45     def test_enum_state(self):
46         self.assertEqual(vlc.State.Playing, 3)
47
48     def test_enum_media_option(self):
49         self.assertEqual(vlc.MediaOption.unique, 256)
50
51     def test_enum_playback_mode(self):
52         self.assertEqual(vlc.PlaybackMode.repeat, 2)
53
54     def test_enum_marquee_int_option(self):
55         self.assertEqual(vlc.VideoMarqueeIntOption.Size, 5)
56
57     def test_enum_output_device_type(self):
58         self.assertEqual(vlc.AudioOutputDeviceTypes._2F2R, 4)
59
60     def test_enum_output_channel(self):
61         self.assertEqual(vlc.AudioOutputChannel.Dolbys, 5)
62
63     def test_enum_position_origin(self):
64         self.assertEqual(vlc.PositionOrigin.ModuloPosition, 2)
65
66     def test_enum_position_key(self):
67         self.assertEqual(vlc.PositionKey.MediaTime, 2)
68
69     def test_enum_player_status(self):
70         self.assertEqual(vlc.PlayerStatus.StopStatus, 5)
71
72     # Basic MediaControl tests
73     def test_mediacontrol_creation(self):
74         mc=vlc.MediaControl()
75         self.assert_(mc)
76
77     def test_mediacontrol_initial_mrl(self):
78         mc=vlc.MediaControl()
79         self.assertEqual(mc.get_mrl(), '')
80
81     def test_mediacontrol_set_mrl(self):
82         mrl='/tmp/foo.avi'
83         mc=vlc.MediaControl()
84         mc.set_mrl(mrl)
85         self.assertEqual(mc.get_mrl(), mrl)
86
87     # Basic libvlc tests
88     def test_instance_creation(self):
89         i=vlc.Instance()
90         self.assert_(i)
91
92     def test_libvlc_media(self):
93         mrl='/tmp/foo.avi'
94         i=vlc.Instance()
95         m=i.media_new(mrl)
96         self.assertEqual(m.get_mrl(), mrl)
97
98     def test_libvlc_player(self):
99         mrl='/tmp/foo.avi'
100         i=vlc.Instance()
101         p=i.media_player_new(mrl)
102         self.assertEqual(p.get_media().get_mrl(), mrl)
103
104 if __name__ == '__main__':
105     unittest.main()