126974904e2a040313aa7d2e94837a9cb8e96395
[sdlgit/SDL_perl.git] / t / core_video.t
1 #!/usr/bin/perl -w
2 use strict;
3 use SDL;
4 use SDL::Color;
5 use SDL::Surface;
6 use SDL::Config;
7 use Devel::Peek;
8 use Data::Dumper;
9 use Test::More;
10 use SDL::Rect;
11
12 plan ( tests => 13 );
13
14 use_ok( 'SDL::Video' ); 
15
16 my @done =
17         qw/ 
18         get_video_surface
19         get_video_info
20         video_driver_name
21         list_modes
22         set_video_mode
23         video_mode_ok
24         update_rect
25         update_rects
26         flip
27         set_colors
28         /;
29 can_ok ('SDL::Video', @done); 
30
31 #testing get_video_surface
32 SDL::Init(SDL_INIT_VIDEO);                                                                          
33                                                                                                     
34 my $display = SDL::SetVideoMode(640,480,32, SDL_SWSURFACE );
35
36 #diag('Testing SDL::Video');
37
38 isa_ok(SDL::Video::get_video_surface(), 'SDL::Surface', '[get_video_surface] Checking if we get a surface ref back'); 
39
40 isa_ok(SDL::Video::get_video_info(), 'SDL::VideoInfo', '[get_video_info] Checking if we get videoinfo ref back');
41
42 my $driver_name = SDL::Video::video_driver_name();
43
44 pass '[video_driver_name] This is your driver name: '.$driver_name;
45
46
47
48 is( ref( SDL::Video::list_modes( $display->format , SDL_SWSURFACE )), 'ARRAY', '[list_modes] Returned an ARRAY! ');
49
50 cmp_ok(SDL::Video::video_mode_ok( 100, 100, 16, SDL_SWSURFACE), '>=', 0, "[video_mode_ok] Checking if an integer was return");
51
52 isa_ok(SDL::Video::set_video_mode( 100, 100 ,16, SDL_SWSURFACE), 'SDL::Surface', '[set_video_more] Checking if we get a surface ref back'); 
53
54
55 #TODO: Write to surface and check inf pixel in that area got updated.
56
57 SDL::Video::update_rect($display, 0, 0, 0, 0);
58
59 #TODO: Write to surface and check inf pixel in that area got updated.
60 SDL::Video::update_rects($display, SDL::Rect->new(0, 10, 20, 20));
61
62 my $value = SDL::Video::flip($display);
63 is( ($value == 0)  ||  ($value == -1), 1,  '[flip] returns 0 or -1'  );
64
65 $value = SDL::Video::set_colors($display, 0);
66 is(  $value , 0,  '[set_colors] returns 0'  );
67
68 $value = SDL::Video::set_colors($display, SDL::Color->new(255,0,0) );
69 is( ($value == 0)  ||  ($value == 1) , 1,  '[set_colors] returns 1 or 0'  );
70
71 #TODO: check actual color in palette with get_palette
72
73
74 my @left = qw/
75         set_palette
76         set_gamma
77         get_gamma_ramp
78         set_gmmma_ramp
79         map_RGB
80         map_RGBA
81         get_RGB
82         get_RGBA
83         create_RGB_surface_from
84         lock_surface
85         unlock_surface
86         convert_surface
87         display_format
88         display_format_alpha
89         load_BMP
90         save_BMP
91         set_color_key
92         set_alpha
93         set_clip_rect
94         get_clip_rect
95         blit_surface
96         fill_rect
97         GL_load_library
98         GL_get_proc_address
99         GL_get_attribute
100         GL_set_attribute
101         GL_swap_buffers
102         GL_attr
103         lock_YUV_overlay
104         unlock_YUV_overlay
105         display_YUV_overlay
106         /;
107
108 my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left); 
109
110 TODO:
111 {
112         local $TODO = $why;
113         pass "\nThe following functions:\n".join ",", @left; 
114 }
115         diag  $why;
116
117
118 pass 'Are we still alive? Checkign for segfaults';