Skip to content
Browse files

Expanding the test suite for SDL::SMPEG to include the main setup ope…

…rations (at least as they are described in the documentation).

This test currently fails.
  • Loading branch information...
1 parent 9cd8a16 commit 5c9faa907cce86b232a479dfdbbffad6fb7ebe0a @adamkennedy adamkennedy committed Jan 5, 2011
Showing with 57 additions and 4 deletions.
  1. +57 −4 t/smpeg.t
View
61 t/smpeg.t
@@ -11,12 +11,13 @@ use SDL::Config;
use Test::More;
if ( SDL::Config->has('smpeg') ) {
- plan( tests => 4 );
+ plan( tests => 19 );
} else {
plan( skip_all => ( SDL::Config->has('smpeg') ? '' : ' smpeg support not compiled' ) );
}
use_ok('SDL::SMPEG');
+use_ok('SDL::Surface');
can_ok(
'SDL::SMPEG', qw/
@@ -41,8 +42,60 @@ can_ok(
/
);
-my ($smpeg, $mpeg) = SDL::SMPEG->new(-name => 'test/data/test-mpeg.mpg' );
-isa_ok( $smpeg, 'SDL::SMPEG' );
-isa_ok( $mpeg, 'SDL::MPEG' );
+# Create a video as it is done in the SYNOPSIS for SDL::SMPEG
+SCOPE: {
+ my $smpeg = SDL::SMPEG->new(
+ -name => 'test/data/test-mpeg.mpg',
+ );
+ isa_ok( $smpeg, 'SDL::SMPEG' );
+}
+
+# Get some information about a video
+SCOPE: {
+ # TODO: On the following line we don't use the same code as
+ # above, intentionally so we can evade the failing test and
+ # continue testing. Once the above test case passes, merge
+ # this with the test case above.
+ my ($smpeg) = SDL::SMPEG->new(
+ -name => 'test/data/test-mpeg.mpg',
+ );
+ isa_ok( $smpeg, 'SDL::SMPEG' );
+
+ # Get the video metadata
+ my $mpeg = $smpeg->info;
+ isa_ok( $mpeg, 'SDL::MPEG' );
+
+ # Check it matches what we expect
+ is( $mpeg->has_audio, 1, '->has_audio ok' );
+ is( $mpeg->has_video, 1, '->has_video ok' );
+ is( $mpeg->width, 160, '->width ok' );
+ is( $mpeg->height, 120, '->height ok' );
+ is( $mpeg->size, 706564, '->size ok' );
+ is( $mpeg->offset, 2717, '->offset ok' );
+ is( $mpeg->frame, 0, '->frame ok' );
+ is( $mpeg->time, 0, '->time ok' );
+ like( $mpeg->length, qr/^21.3/, '->length ok' );
+
+ # TODO: I'm not entirely sure this is meant to be zero
+ is( $mpeg->fps, 0, '->fps ok' );
+
+ # Create a surface to attach the movie to
+ my $surface = SDL::Surface->new(
+ $mpeg->height,
+ $mpeg->width,
+ 24, # Colour bits
+ 0, 0, 0, 0, # Masks
+ );
+ isa_ok( $surface, 'SDL::Surface' );
+
+ # Attach the movie to a surface
+ ok( $smpeg->display($surface), '->display(surface) ok' );
+
+ # Now that we are bound we should be able to do things
+ # to the movie and have them actually work.
+ # Confirm we can change where we are in the video.
+ ok( $smpeg->frame(5), '->frame(5) ok' );
+ is( $mpeg->frame, 5, '->frame updated in info object' );
+}
sleep(2);

0 comments on commit 5c9faa9

Please sign in to comment.
Something went wrong with that request. Please try again.