~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/tests/test_video.py

  • Committer: Jan Jokela
  • Date: 2008-12-10 22:18:59 UTC
  • Revision ID: janjokela@gmail.com-20081210221859-zxr2ut255a7xu15x
Hi, Glitter here

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# !/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# Glitter Toolkit
 
5
 
 
6
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
 
7
__licenses__ = ["LICENSE.LGPL"]
 
8
__description__ = "Tests for the video widget"
 
9
 
 
10
import os
 
11
import sys
 
12
 
 
13
import pygtk
 
14
pygtk.require('2.0')
 
15
import gtk
 
16
 
 
17
import clutter
 
18
 
 
19
# Change sys path to glitter path
 
20
glitter_path = os.path.split(sys.path[0])[0]
 
21
sys.path[0] = glitter_path
 
22
 
 
23
from window import Window
 
24
from video import Video
 
25
 
 
26
# Importing glitter.video messes up sys.path because in its turn, it import gst
 
27
# which messes up sys.path
 
28
glitter_path = os.path.split(sys.path[0])[0]
 
29
sys.path[0] = glitter_path
 
30
 
 
31
class TestVideo(object):
 
32
    """ Tests for the video widget """
 
33
    
 
34
    def __init__(self, video_uri, aspect_ratio):
 
35
    
 
36
        self.video_uri = video_uri
 
37
        self.aspect_ratio = aspect_ratio
 
38
        
 
39
        self.window = Window("Glitter tests")
 
40
        self.window.connect("destroy", self.destroy)
 
41
 
 
42
        self.stage = self.window.get_stage()
 
43
        self.stage.connect('notify::width', self.do_resize)
 
44
        self.stage.connect('notify::height', self.do_resize)
 
45
        
 
46
        self.video = Video(video_uri, aspect_ratio)
 
47
        self.stage.add(self.video)
 
48
        self.video._update_layout()
 
49
        self.video.play()
 
50
        
 
51
        self.window.show_all()
 
52
        gtk.main()
 
53
        
 
54
    def destroy(self, widget, data=None):
 
55
        gtk.main_quit()
 
56
 
 
57
    def do_resize(self, stage, event):
 
58
        self.video._update_layout()
 
59
        
 
60
if __name__ == '__main__':
 
61
    if len(sys.argv) != 3:
 
62
        print "Missing arguments, correct usage is: "
 
63
        print "python video.py video_file_uri [ex: glitter.mov] " + \
 
64
              "mode [native, widescreen, tv, smart]"
 
65
        sys.exit(1)
 
66
    else:
 
67
        TestVideo(sys.argv[1], sys.argv[2])