4 # Code generator for python ctypes bindings for VLC
5 # Copyright (C) 2009 the VideoLAN team
8 # Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
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.
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.
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.
31 class TestVLCAPI(unittest.TestCase):
33 # self.seq = range(10)
34 #self.assert_(element in self.seq)
36 # We check enum definitions against hardcoded values. In case of
37 # failure, check that the reason is not a change in the .h
39 def test_enum_event_type(self):
40 self.assertEqual(vlc.EventType.MediaStateChanged.value, 5)
42 def test_enum_meta(self):
43 self.assertEqual(vlc.Meta.Description.value, 6)
45 def test_enum_state(self):
46 self.assertEqual(vlc.State.Playing.value, 3)
48 def test_enum_media_option(self):
49 self.assertEqual(vlc.MediaOption.unique.value, 256)
51 def test_enum_playback_mode(self):
52 self.assertEqual(vlc.PlaybackMode.repeat.value, 2)
54 def test_enum_marquee_int_option(self):
55 self.assertEqual(vlc.VideoMarqueeIntOption.Size.value, 5)
57 def test_enum_output_device_type(self):
58 self.assertEqual(vlc.AudioOutputDeviceTypes._2F2R.value, 4)
60 def test_enum_output_channel(self):
61 self.assertEqual(vlc.AudioOutputChannel.Dolbys.value, 5)
63 def test_enum_position_origin(self):
64 self.assertEqual(vlc.PositionOrigin.ModuloPosition.value, 2)
66 def test_enum_position_key(self):
67 self.assertEqual(vlc.PositionKey.MediaTime.value, 2)
69 def test_enum_player_status(self):
70 self.assertEqual(vlc.PlayerStatus.StopStatus.value, 5)
72 # Basic MediaControl tests
73 def test_mediacontrol_creation(self):
77 def test_mediacontrol_initial_mrl(self):
79 self.assertEqual(mc.get_mrl(), '')
81 def test_mediacontrol_set_mrl(self):
85 self.assertEqual(mc.get_mrl(), mrl)
87 def test_mediacontrol_position(self):
88 p=vlc.MediaControlPosition(value=2,
89 origin=vlc.PositionOrigin.RelativePosition,
90 key=vlc.PositionKey.MediaTime)
91 self.assertEqual(p.value, 2)
93 def test_mediacontrol_position_shortcut(self):
94 p=vlc.MediaControlPosition(2)
95 self.assertEqual(p.value, 2)
96 self.assertEqual(p.key, vlc.PositionKey.MediaTime)
97 self.assertEqual(p.origin, vlc.PositionOrigin.AbsolutePosition)
99 def test_mediacontrol_get_media_position(self):
100 mc=vlc.MediaControl()
101 p=mc.get_media_position()
102 self.assertEqual(p.value, -1)
104 def test_mediacontrol_get_stream_information(self):
105 mc=vlc.MediaControl()
106 s=mc.get_stream_information()
107 self.assertEqual(s.position, 0)
108 self.assertEqual(s.length, 0)
111 def test_instance_creation(self):
115 def test_libvlc_media(self):
119 self.assertEqual(m.get_mrl(), mrl)
121 def test_libvlc_player(self):
124 p=i.media_player_new(mrl)
125 self.assertEqual(p.get_media().get_mrl(), mrl)
127 def test_libvlc_player_state(self):
130 p=i.media_player_new(mrl)
131 self.assertEqual(p.get_state(), vlc.State.Ended)
133 def test_libvlc_logger(self):
137 self.assertEqual(l.count(), 0)
140 def test_libvlc_logger_clear(self):
144 self.assertEqual(l.count(), 0)
147 def test_libvlc_logger(self):
149 i.set_log_verbosity(3)
151 # This should generate a log message
153 self.assertNotEqual(l.count(), 0)
155 # Ensure that messages can be read.
156 self.assertNotEqual(len(m.message), 0)
159 if __name__ == '__main__':