From: Leon Brocard Date: Fri, 16 Oct 2009 07:20:46 +0000 (+0100) Subject: Move tests from t/surfacepm.t to t/core_surface.t X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a70569add5d184de75c04a635b0f13a15029398;p=sdlgit%2FSDL_perl.git Move tests from t/surfacepm.t to t/core_surface.t --- diff --git a/MANIFEST b/MANIFEST index e61ce50..29bc73e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -119,7 +119,6 @@ t/sdlgamerect.t t/sdlpm.t t/soundpm.t t/surfaceML.t -t/surfacepm.t t/timerpm.t t/toolfontpm.t t/toolgraphicpm.t diff --git a/t/core_surface.t b/t/core_surface.t index 958df3e..497c5bb 100644 --- a/t/core_surface.t +++ b/t/core_surface.t @@ -5,8 +5,8 @@ # BEGIN { - unshift @INC, 'blib/lib','blib/arch'; - } + unshift @INC, 'blib/lib', 'blib/arch'; +} use strict; use SDL; @@ -15,28 +15,48 @@ use SDL::Surface; use SDL::App; use SDL::Rect; use SDL::Color; -use Test::More; - -plan (tests => 2 ); - - -my $app = SDL::App->new(-title => "Test", -width => 640, -height => 480, -init => SDL_INIT_VIDEO); +use Test::More tests => 9; + +my $surface + = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 0, 0, 0, 0, 0 ); +isa_ok( $surface, 'SDL::Surface' ); +is( $surface->w, 640, 'surface has width' ); +is( $surface->h, 320, 'surface has height' ); + +my $image = SDL::Surface->load('test/data/logo.png'); +is( $image->w, 608, 'image has width' ); +is( $image->h, 126, 'image has height' ); + +$surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ), + SDL::Color->new( 200, 200, 200 ) ); +ok( 1, 'Managed to fill_rect' ); + +my $small_rect = SDL::Rect->new( 0, 0, 64, 64 ); +$image->blit( $small_rect, $surface, $small_rect ); +ok( 1, 'Managed to blit' ); + +#my $image_format = $surface->display; +#$surface->update_rect( 0, 0, 32, 32 ); +#ok( 1, 'Managed to update_rect' ); +#$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) ); +#ok( 1, 'Managed to update_rects' ); + +my $app = SDL::App->new( + -title => "Test", + -width => 640, + -height => 480, + -init => SDL_INIT_VIDEO +); pass 'did this pass'; -my $rect = SDL::Rect->new(0,0, $app->w, $app->h); - - - my $blue = SDL::Color->new( - 0x00, - 0x00, - 0xff, - ); +my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h ); -$app->fill_rect($rect,$blue); +my $blue = SDL::Color->new( 0x00, 0x00, 0xff, ); +$app->fill_rect( $rect, $blue ); -diag('This is in surface : '.SDL::Surface::get_pixels($app)); +diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) ); pass 'did this pass'; diff --git a/t/surfacepm.t b/t/surfacepm.t deleted file mode 100644 index 243af6d..0000000 --- a/t/surfacepm.t +++ /dev/null @@ -1,33 +0,0 @@ -#!perl -use strict; -use warnings; -use Test::More tests => 11; -use_ok('SDL'); -use_ok('SDL::Color'); -use_ok('SDL::Rect'); -use_ok('SDL::Surface'); - -my $surface - = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 0, 0, 0, 0, 0 ); -isa_ok( $surface, 'SDL::Surface' ); -is( $surface->w, 640, 'surface has width' ); -is( $surface->h, 320, 'surface has height' ); - -my $image = SDL::Surface->load('test/data/logo.png'); -is( $image->w, 608, 'image has width' ); -is( $image->h, 126, 'image has height' ); - -$surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ), - SDL::Color->new( 200, 200, 200 ) ); -ok( 1, 'Managed to fill_rect' ); - -my $rect = SDL::Rect->new( 0, 0, 64, 64 ); -$image->blit( $rect, $surface, $rect ); -ok( 1, 'Managed to blit' ); - -#my $image_format = $surface->display; -#$surface->update_rect( 0, 0, 32, 32 ); -#ok( 1, 'Managed to update_rect' ); -#$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) ); -#ok( 1, 'Managed to update_rects' ); -