Skip to content

HTTPS clone URL

Subversion checkout URL

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