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