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