Move tests from t/surfacepm.t to t/core_surface.t
[sdlgit/SDL_perl.git] / t / core_surface.t
1 #!perl -w
2 # Copyright (C) 2009 kthakore
3 #
4 # Spec tests for SDL::Surface
5 #
6
7 BEGIN {
8     unshift @INC, 'blib/lib', 'blib/arch';
9 }
10
11 use strict;
12 use SDL;
13 use SDL::Config;
14 use SDL::Surface;
15 use SDL::App;
16 use SDL::Rect;
17 use SDL::Color;
18 use Test::More tests => 9;
19
20 my $surface
21     = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 0, 0, 0, 0, 0 );
22 isa_ok( $surface, 'SDL::Surface' );
23 is( $surface->w, 640, 'surface has width' );
24 is( $surface->h, 320, 'surface has height' );
25
26 my $image = SDL::Surface->load('test/data/logo.png');
27 is( $image->w, 608, 'image has width' );
28 is( $image->h, 126, 'image has height' );
29
30 $surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ),
31     SDL::Color->new( 200, 200, 200 ) );
32 ok( 1, 'Managed to fill_rect' );
33
34 my $small_rect = SDL::Rect->new( 0, 0, 64, 64 );
35 $image->blit( $small_rect, $surface, $small_rect );
36 ok( 1, 'Managed to blit' );
37
38 #my $image_format = $surface->display;
39 #$surface->update_rect( 0, 0, 32, 32 );
40 #ok( 1, 'Managed to update_rect' );
41 #$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) );
42 #ok( 1, 'Managed to update_rects' );
43
44 my $app = SDL::App->new(
45     -title  => "Test",
46     -width  => 640,
47     -height => 480,
48     -init   => SDL_INIT_VIDEO
49 );
50
51 pass 'did this pass';
52
53 my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h );
54
55 my $blue = SDL::Color->new( 0x00, 0x00, 0xff, );
56
57 $app->fill_rect( $rect, $blue );
58
59 diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) );
60
61 pass 'did this pass';
62