2
# Elisa - Home multimedia server
3
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
6
# This file is available under one of two license agreements.
8
# This file is licensed under the GPL version 3.
9
# See "LICENSE.GPL" in the root of this distribution including a special
10
# exception to use Elisa with Fluendo's plugins.
12
# The GPL part of Elisa is also available under a commercial licensing
13
# agreement from Fluendo.
14
# See "LICENSE.Elisa" in the root directory of this distribution package
15
# for details on that license.
17
from twisted.trial import unittest
18
from elisa.core.tests.elisa_test_case import ElisaTestCase
19
from elisa.core import common, player_engine_registry
21
from elisa.core.player import STATES
23
from elisa.core.components import player_engine
27
class StupidPipe(object):
30
class FooEngine(player_engine.PlayerEngine):
31
uri_schemes = {'foo' : 150, 'test' : 100, 'test2' : 50 }
40
player_engine.PlayerEngine.__init__(self)
41
self._pipeline = StupidPipe()
42
self.pipeline = self._pipeline
48
def state__set(self, state):
51
def _pipeline_set_state(self, state):
52
self.pipeline.state = state
54
def volume__set(self, volume):
57
def volume__get(self):
60
def audio_sink__set(self, sink):
61
self._audiosink = sink
63
def audio_sink__get(self):
64
return self._audiosink
66
def video_sink__set(self, sink):
67
self._videosink = sink
69
def video_sink__get(self):
70
return self._videosink
72
class BarEngine(FooEngine):
73
uri_schemes = {'bar' : 20}
75
class TestPlayerEngine(ElisaTestCase):
78
ElisaTestCase.setUp(self)
79
self._engine = FooEngine()
81
def test_engine(self):
85
engine.state = STATES.STOPPED
87
self.assertEquals(engine.state, STATES.LOADING)
88
self.assertEquals(engine.pipeline.state, gst.STATE_PLAYING)
90
engine.state = STATES.PLAYING
92
self.assertEquals(engine.pipeline.state, gst.STATE_PAUSED)
94
engine.state = STATES.PAUSED
96
self.assertEquals(engine.state, STATES.PLAYING)
97
self.assertEquals(engine.pipeline.state, gst.STATE_PLAYING)
99
engine.state = STATES.PLAYING
101
self.assertEquals(engine.pipeline.state, gst.STATE_READY)
104
engine.state = STATES.STOPPED
105
self.assertEquals(engine.position, -1)
106
self.assertEquals(engine.duration, -1)
108
engine.state = STATES.PLAYING
109
self.assertEquals(engine.position, -1)
110
self.assertEquals(engine.duration, -1)
111
self.assertEquals(engine.speed, 1.0)
113
# FIXME: not working.
115
# self.assertEquals(engine.speed, 8.0)