Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (100 sloc) 2.745 kb
a677489 Kartik Thakore Moved old SDL::Video test to smpeg test
kthakore authored
1 #!perl
2 # basic testing of SDL::SMPEG
3
4 BEGIN {
4979eb1 Jeffrey T. Palmer perltidy
jtpalmer authored
5 unshift @INC, 'blib/lib', 'blib/arch';
a677489 Kartik Thakore Moved old SDL::Video test to smpeg test
kthakore authored
6 }
7
8 use strict;
a57ab2a Jeffrey T. Palmer Add strict and warnings
jtpalmer authored
9 use warnings;
a618f29 Kartik Thakore Video is showing but tests are not working as expected
kthakore authored
10 use SDL;
a677489 Kartik Thakore Moved old SDL::Video test to smpeg test
kthakore authored
11 use SDL::Config;
12
13 use Test::More;
14
6b9a70b Kartik Thakore Accidently added ppport to bundle file for Mac build
kthakore authored
15 my $videodriver = $ENV{SDL_VIDEODRIVER};
16 $ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
17
18
78ce693 SDL_mixer is not necessary
Tobias Leich authored
19 if ( SDL::Config->has('smpeg') ) {
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
20 if ( $ENV{SDL_RELEASE_TESTING} ) {
0609c2b Kartik Thakore We can only run smpeg as release_testing
kthakore authored
21 plan( tests => 17 );
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
22 } else {
0609c2b Kartik Thakore We can only run smpeg as release_testing
kthakore authored
23 plan( skip_all => "Skiping test for now. EXPERIMENTAL" );
24 }
4979eb1 Jeffrey T. Palmer perltidy
jtpalmer authored
25 } else {
26 plan( skip_all => ( SDL::Config->has('smpeg') ? '' : ' smpeg support not compiled' ) );
e6e146e Kartik Thakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
27 }
28
29 use_ok('SDL::SMPEG');
a618f29 Kartik Thakore Video is showing but tests are not working as expected
kthakore authored
30 use SDL::Video;
a677489 Kartik Thakore Moved old SDL::Video test to smpeg test
kthakore authored
31
e6e146e Kartik Thakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
32 can_ok(
4979eb1 Jeffrey T. Palmer perltidy
jtpalmer authored
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 /
e6e146e Kartik Thakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
53 );
a677489 Kartik Thakore Moved old SDL::Video test to smpeg test
kthakore authored
54
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
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: {
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
65
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
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.
2e56c95 Kartik Thakore Fixed silly typo
kthakore authored
70 my ($smpeg) = SDL::SMPEG->new(
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
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;
207837e Kartik Thakore Using a better name for SDL::MPEG
kthakore authored
77 isa_ok( $mpeg, 'SDL::SMPEG::Info' );
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
78
79 # Check it matches what we expect
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
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' );
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
89
90 # TODO: I'm not entirely sure this is meant to be zero
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
91 is( $mpeg->fps, 0, '->fps ok' );
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
92
a618f29 Kartik Thakore Video is showing but tests are not working as expected
kthakore authored
93 # Create a display to attach the movie to
94 my $surface = SDL::Video::set_video_mode(
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
95 $mpeg->height,
96 $mpeg->width,
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
97 32, # Colour bits
a618f29 Kartik Thakore Video is showing but tests are not working as expected
kthakore authored
98 SDL::Video::SDL_SWSURFACE, # flags
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
99 );
100 isa_ok( $surface, 'SDL::Surface' );
101
102 # Attach the movie to a surface
6b9a70b Kartik Thakore Accidently added ppport to bundle file for Mac build
kthakore authored
103 is( $smpeg->display($surface), undef, '->display(surface) ok' );
5c9faa9 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
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.
d30b433 Jeffrey T. Palmer Tidied code
jtpalmer authored
108 # is( $smpeg->frame(5), undef, '->frame(5) ok' );
109 $smpeg->play();
110
820749b Kartik Thakore 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 Adam Kennedy Expanding the test suite for SDL::SMPEG to include the main setup operat...
adamkennedy authored
113 }
9cd8a16 Kartik Thakore Added SMPEG priliminary support
kthakore authored
114
6b9a70b Kartik Thakore 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.