~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to tests/test_seeker.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# PiTiVi , Non-linear video editor
2
 
#
3
 
#       tests/test_timeline.py
4
 
#
5
 
# Copyright (c) 2009, Alessandro Decina <alessandro.decina@collabora.co.uk>
6
 
#
7
 
# This program is free software; you can redistribute it and/or
8
 
# modify it under the terms of the GNU Lesser General Public
9
 
# License as published by the Free Software Foundation; either
10
 
# version 2.1 of the License, or (at your option) any later version.
11
 
#
12
 
# This program is distributed in the hope that it will be useful,
13
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
# Lesser General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU Lesser General Public
18
 
# License along with this program; if not, write to the
19
 
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20
 
# Boston, MA 02110-1301, USA.
21
 
 
22
 
from unittest import TestCase
23
 
from pitivi.utils import Seeker
24
 
import gst
25
 
 
26
 
 
27
 
class StubSeeker(Seeker):
28
 
    seek_id = 0
29
 
 
30
 
    def _scheduleSeek(self, position, format):
31
 
        # mock Seeker._scheduleSeek so that we don't need a mainloop
32
 
        seek_id = self.seek_id
33
 
        self.seek_id += 1
34
 
 
35
 
        return seek_id
36
 
 
37
 
 
38
 
class TestSeeker(TestCase):
39
 
    def setUp(self):
40
 
        self.seek_count = 0
41
 
        self.seek_position = None
42
 
        self.seek_format = None
43
 
 
44
 
    def testSeek(self):
45
 
        def seek_cb(seeker, position, format):
46
 
            self.seek_count += 1
47
 
            self.seek_position = position
48
 
            self.seek_format = format
49
 
 
50
 
        seeker = StubSeeker(timeout=10)
51
 
        seeker.connect('seek', seek_cb)
52
 
 
53
 
        # first seek should happen immediately
54
 
        seeker.seek(1)
55
 
        self.failUnlessEqual(self.seek_count, 1)
56
 
        self.failUnlessEqual(self.seek_position, 1)
57
 
        self.failUnlessEqual(self.seek_format, gst.FORMAT_TIME)
58
 
        self.failUnlessEqual(seeker.pending_seek_id, 0)
59
 
        self.failUnlessEqual(seeker.position, None)
60
 
        self.failUnlessEqual(seeker.format, None)
61
 
 
62
 
        # second seek is queued
63
 
        seeker.seek(2, gst.FORMAT_BYTES)
64
 
        self.failUnlessEqual(seeker.pending_seek_id, 0)
65
 
        self.failUnlessEqual(seeker.position, 2)
66
 
        self.failUnlessEqual(seeker.format, gst.FORMAT_BYTES)
67
 
 
68
 
        # ... until the timeout triggers
69
 
        seeker._seekTimeoutCb()
70
 
        self.failUnlessEqual(self.seek_count, 2)
71
 
        self.failUnlessEqual(self.seek_position, 2)
72
 
        self.failUnlessEqual(self.seek_format, gst.FORMAT_BYTES)
73
 
        self.failUnlessEqual(seeker.pending_seek_id, None)
74
 
        self.failUnlessEqual(seeker.position, None)
75
 
        self.failUnlessEqual(seeker.format, None)
76
 
 
77
 
        # do another first-seek
78
 
        seeker.seek(3)
79
 
        self.failUnlessEqual(seeker.pending_seek_id, 1)
80
 
        self.failUnlessEqual(self.seek_count, 3)
81
 
        self.failUnlessEqual(seeker.position, None)
82
 
        self.failUnlessEqual(seeker.format, None)
83
 
 
84
 
        # timeout with None position
85
 
        seeker._seekTimeoutCb()