Added set_colors. Started testing it. Made a percentage completed counter
[sdlgit/SDL_perl.git] / t / core_video.t
CommitLineData
df4106bf 1#!/usr/bin/perl -w
df4106bf 2use strict;
3use SDL;
2739f940 4use SDL::Color;
4510df28 5use SDL::Surface;
df4106bf 6use SDL::Config;
7fa192d4 7use Devel::Peek;
4510df28 8use Data::Dumper;
df4106bf 9use Test::More;
eaf32d63 10use SDL::Rect;
df4106bf 11
2739f940 12plan ( tests => 13 );
df4106bf 13
14use_ok( 'SDL::Video' );
494f077a 15
16my @done =
17 qw/
df4106bf 18 get_video_surface
19 get_video_info
8a2411d0 20 video_driver_name
7dda1934 21 list_modes
bbe5d2f5 22 set_video_mode
218b5471 23 video_mode_ok
eaf32d63 24 update_rect
25 update_rects
19f3ee7b 26 flip
2739f940 27 set_colors
494f077a 28 /;
29can_ok ('SDL::Video', @done);
95f5be30 30
31#testing get_video_surface
32SDL::Init(SDL_INIT_VIDEO);
33
34my $display = SDL::SetVideoMode(640,480,32, SDL_SWSURFACE );
35
218b5471 36#diag('Testing SDL::Video');
95f5be30 37
e4259ddb 38isa_ok(SDL::Video::get_video_surface(), 'SDL::Surface', '[get_video_surface] Checking if we get a surface ref back');
39
40isa_ok(SDL::Video::get_video_info(), 'SDL::VideoInfo', '[get_video_info] Checking if we get videoinfo ref back');
20f544ea 41
7fa192d4 42my $driver_name = SDL::Video::video_driver_name();
43
e4259ddb 44pass '[video_driver_name] This is your driver name: '.$driver_name;
7fa192d4 45
218b5471 46
47
48is( ref( SDL::Video::list_modes( $display->format , SDL_SWSURFACE )), 'ARRAY', '[list_modes] Returned an ARRAY! ');
49
50cmp_ok(SDL::Video::video_mode_ok( 100, 100, 16, SDL_SWSURFACE), '>=', 0, "[video_mode_ok] Checking if an integer was return");
7fa192d4 51
bbe5d2f5 52isa_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
bbe5d2f5 55#TODO: Write to surface and check inf pixel in that area got updated.
56
eaf32d63 57SDL::Video::update_rect($display, 0, 0, 0, 0);
58
bbe5d2f5 59#TODO: Write to surface and check inf pixel in that area got updated.
eaf32d63 60SDL::Video::update_rects($display, SDL::Rect->new(0, 10, 20, 20));
61
b9125226 62my $value = SDL::Video::flip($display);
63is( ($value == 0) || ($value == -1), 1, '[flip] returns 0 or -1' );
19f3ee7b 64
2739f940 65$value = SDL::Video::set_colors($display, 0);
66is( $value , 0, '[set_colors] returns 0' );
67
68$value = SDL::Video::set_colors($display, SDL::Color->new(255,0,0) );
69is( ($value == 0) || ($value == 1) , 1, '[set_colors] returns 1 or 0' );
bc1947c7 70
2739f940 71#TODO: check actual color in palette with get_palette
494f077a 72
73
74my @left = qw/
df4106bf 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
df4106bf 103 lock_YUV_overlay
104 unlock_YUV_overlay
105 display_YUV_overlay
494f077a 106 /;
107
108my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left);
109
110TODO:
111{
2739f940 112 local $TODO = $why;
113 pass "\nThe following functions:\n".join ",", @left;
494f077a 114}
2739f940 115 diag $why;
116
df4106bf 117
2739f940 118pass 'Are we still alive? Checkign for segfaults';