Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (102 sloc) 2.78 kb
a677489 @kthakore Moved old SDL::Video test to smpeg test
kthakore authored
1 #!perl
2 # basic testing of SDL::SMPEG
3
4 BEGIN {
4979eb1 @jtpalmer perltidy
jtpalmer authored
5 unshift @INC, 'blib/lib', 'blib/arch';
a677489 @kthakore Moved old SDL::Video test to smpeg test
kthakore authored
6 }
7
8 use strict;
a618f29 @kthakore Video is showing but tests are not working as expected
kthakore authored
9 use SDL;
a677489 @kthakore Moved old SDL::Video test to smpeg test
kthakore authored
10 use SDL::Config;
11
12 use Test::More;
13
6b9a70b @kthakore Accidently added ppport to bundle file for Mac build
kthakore authored
14 my $videodriver = $ENV{SDL_VIDEODRIVER};
15 $ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
16
17
78ce693 SDL_mixer is not necessary
Tobias Leich authored
18 if ( SDL::Config->has('smpeg') ) {
0609c2b @kthakore We can only run smpeg as release_testing
kthakore authored
19 if( $ENV{SDL_RELEASE_TESTING} )
20 {
21 plan( tests => 17 );
22 }
23 else
24 {
25 plan( skip_all => "Skiping test for now. EXPERIMENTAL" );
26 }
4979eb1 @jtpalmer perltidy
jtpalmer authored
27 } else {
28 plan( skip_all => ( SDL::Config->has('smpeg') ? '' : ' smpeg support not compiled' ) );
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
29 }
30
31 use_ok('SDL::SMPEG');
a618f29 @kthakore Video is showing but tests are not working as expected
kthakore authored
32 use SDL::Video;
a677489 @kthakore Moved old SDL::Video test to smpeg test
kthakore authored
33
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
34 can_ok(
4979eb1 @jtpalmer perltidy
jtpalmer authored
35 'SDL::SMPEG', qw/
36 new
37 error
38 audio
39 video
40 volume
41 display
42 scale
43 play
44 pause
45 stop
46 rewind
47 seek
48 skip
49 loop
50 region
51 frame
52 info
53 status
54 /
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
55 );
a677489 @kthakore Moved old SDL::Video test to smpeg test
kthakore authored
56
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
57 # Create a video as it is done in the SYNOPSIS for SDL::SMPEG
58 SCOPE: {
59 my $smpeg = SDL::SMPEG->new(
60 -name => 'test/data/test-mpeg.mpg',
61 );
62 isa_ok( $smpeg, 'SDL::SMPEG' );
63 }
64
65 # Get some information about a video
66 SCOPE: {
67 # TODO: On the following line we don't use the same code as
68 # above, intentionally so we can evade the failing test and
69 # continue testing. Once the above test case passes, merge
70 # this with the test case above.
2e56c95 @kthakore Fixed silly typo
kthakore authored
71 my ($smpeg) = SDL::SMPEG->new(
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
72 -name => 'test/data/test-mpeg.mpg',
73 );
74 isa_ok( $smpeg, 'SDL::SMPEG' );
75
76 # Get the video metadata
77 my $mpeg = $smpeg->info;
207837e @kthakore Using a better name for SDL::MPEG
kthakore authored
78 isa_ok( $mpeg, 'SDL::SMPEG::Info' );
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
79
80 # Check it matches what we expect
81 is( $mpeg->has_audio, 1, '->has_audio ok' );
82 is( $mpeg->has_video, 1, '->has_video ok' );
83 is( $mpeg->width, 160, '->width ok' );
84 is( $mpeg->height, 120, '->height ok' );
85 is( $mpeg->size, 706564, '->size ok' );
86 is( $mpeg->offset, 2717, '->offset ok' );
87 is( $mpeg->frame, 0, '->frame ok' );
88 is( $mpeg->time, 0, '->time ok' );
89 like( $mpeg->length, qr/^21.3/, '->length ok' );
90
91 # TODO: I'm not entirely sure this is meant to be zero
92 is( $mpeg->fps, 0, '->fps ok' );
93
a618f29 @kthakore Video is showing but tests are not working as expected
kthakore authored
94 # Create a display to attach the movie to
95 my $surface = SDL::Video::set_video_mode(
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
96 $mpeg->height,
97 $mpeg->width,
a618f29 @kthakore Video is showing but tests are not working as expected
kthakore authored
98 32, # Colour bits
99 SDL::Video::SDL_SWSURFACE, # flags
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
100 );
101 isa_ok( $surface, 'SDL::Surface' );
102
103 # Attach the movie to a surface
6b9a70b @kthakore Accidently added ppport to bundle file for Mac build
kthakore authored
104 is( $smpeg->display($surface), undef, '->display(surface) ok' );
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
105
106 # Now that we are bound we should be able to do things
107 # to the movie and have them actually work.
108 # Confirm we can change where we are in the video.
0609c2b @kthakore We can only run smpeg as release_testing
kthakore authored
109 # is( $smpeg->frame(5), undef, '->frame(5) ok' );
110 $smpeg->play();
820749b @kthakore All tests pass but segfaults on exit
kthakore authored
111 # TODO: Figure out how this info object really works
112 #is( $mpeg->current_frame, 5, '->frame updated in info object' );
5c9faa9 @adamkennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
113 }
9cd8a16 @kthakore Added SMPEG priliminary support
kthakore authored
114
6b9a70b @kthakore Accidently added ppport to bundle file for Mac build
kthakore authored
115
116 if ($videodriver) {
117 $ENV{SDL_VIDEODRIVER} = $videodriver;
118 } else {
119 delete $ENV{SDL_VIDEODRIVER};
120 }
121
Something went wrong with that request. Please try again.