~x23team/moovida/redtube-plugin

« back to all changes in this revision

Viewing changes to elisa-core/elisa/core/tests/test_player_engine.py

  • Committer: Florian Boucault
  • Date: 2008-09-23 11:59:57 UTC
  • mfrom: (59.12.4 player_removal)
  • Revision ID: kaleo@samantha-20080923115957-zlal0ziz05qdfefa
Removed all references to old, deprecated player infrastructure as well as
player plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#-*- coding: utf-8 -*-
2
 
# Elisa - Home multimedia server
3
 
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
4
 
# All rights reserved.
5
 
#
6
 
# This file is available under one of two license agreements.
7
 
#
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.
11
 
#
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.
16
 
 
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
20
 
 
21
 
from elisa.core.player import STATES
22
 
 
23
 
from elisa.core.components import player_engine
24
 
 
25
 
import gst
26
 
 
27
 
class StupidPipe(object):
28
 
    state = None
29
 
 
30
 
class FooEngine(player_engine.PlayerEngine):
31
 
    uri_schemes = {'foo' : 150, 'test' : 100, 'test2' : 50 }
32
 
 
33
 
    pipeline = None
34
 
    _volume = 0
35
 
 
36
 
    _videosink = None
37
 
    _audiosink = None
38
 
 
39
 
    def __init__(self):
40
 
        player_engine.PlayerEngine.__init__(self)
41
 
        self._pipeline = StupidPipe()
42
 
        self.pipeline = self._pipeline
43
 
        self._state = None
44
 
 
45
 
    def state__get(self):
46
 
        return self._state
47
 
 
48
 
    def state__set(self, state):
49
 
        self._state = state
50
 
 
51
 
    def _pipeline_set_state(self, state):
52
 
        self.pipeline.state = state
53
 
 
54
 
    def volume__set(self, volume):
55
 
        self._volume = volume
56
 
 
57
 
    def volume__get(self):
58
 
        return self._volume
59
 
 
60
 
    def audio_sink__set(self, sink):
61
 
        self._audiosink = sink
62
 
 
63
 
    def audio_sink__get(self):
64
 
        return self._audiosink
65
 
 
66
 
    def video_sink__set(self, sink):
67
 
        self._videosink = sink
68
 
 
69
 
    def video_sink__get(self):
70
 
        return self._videosink
71
 
 
72
 
class BarEngine(FooEngine):
73
 
    uri_schemes = {'bar' : 20}
74
 
 
75
 
class TestPlayerEngine(ElisaTestCase):
76
 
 
77
 
    def setUp(self):
78
 
        ElisaTestCase.setUp(self)
79
 
        self._engine = FooEngine()
80
 
   
81
 
    def test_engine(self):
82
 
 
83
 
        engine = self._engine
84
 
 
85
 
        engine.state = STATES.STOPPED
86
 
        engine.play()
87
 
        self.assertEquals(engine.state, STATES.LOADING)
88
 
        self.assertEquals(engine.pipeline.state, gst.STATE_PLAYING)
89
 
 
90
 
        engine.state = STATES.PLAYING
91
 
        engine.pause()
92
 
        self.assertEquals(engine.pipeline.state, gst.STATE_PAUSED)
93
 
       
94
 
        engine.state = STATES.PAUSED
95
 
        engine.play()
96
 
        self.assertEquals(engine.state, STATES.PLAYING)
97
 
        self.assertEquals(engine.pipeline.state, gst.STATE_PLAYING)
98
 
 
99
 
        engine.state = STATES.PLAYING
100
 
        engine.stop()
101
 
        self.assertEquals(engine.pipeline.state, gst.STATE_READY)
102
 
 
103
 
 
104
 
        engine.state = STATES.STOPPED
105
 
        self.assertEquals(engine.position, -1)
106
 
        self.assertEquals(engine.duration, -1)
107
 
 
108
 
        engine.state = STATES.PLAYING
109
 
        self.assertEquals(engine.position, -1) 
110
 
        self.assertEquals(engine.duration, -1)
111
 
        self.assertEquals(engine.speed, 1.0)
112
 
 
113
 
        # FIXME: not working.
114
 
#        engine.speed = 8.0
115
 
#        self.assertEquals(engine.speed, 8.0)