PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/t/sdlx_sfont.t

http://github.com/PerlGameDev/SDL
Unknown | 61 lines | 46 code | 15 blank | 0 comment | 0 complexity | f67c047b657b216e3765085ae9612177 MD5 | raw file
 1use strict;
 2use warnings;
 3use Test::More;
 4use SDL;
 5use SDL::Config;
 6use SDL::Video;
 7use SDL::Surface;
 8use SDLx::SFont;
 9use lib 't/lib';
10use SDL::TestTool;
11my $videodriver = $ENV{SDL_VIDEODRIVER};
12$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
13
14my $audiodriver = $ENV{SDL_AUDIODRIVER};
15$ENV{SDL_AUDIODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
16
17if ( !SDL::TestTool->init(SDL_INIT_VIDEO) ) {
18	plan( skip_all => 'Failed to init video' );
19} elsif ( !SDL::Config->has('SDL_image') ) {
20	plan( skip_all => 'SDL_image support not compiled' );
21}
22
23can_ok( 'SDLx::SFont', qw( new ) );
24
25
26#Make a surface
27#Select a font
28my $d = SDL::Surface->new( SDL_SWSURFACE, 100, 100, 32 );
29my $font = SDLx::SFont->new( 'test/data/font.' . ( SDL::Config->has('png') ? 'png' : 'bmp' ) );
30
31isa_ok( $font, 'SDL::Surface', '[new] makes surface' );
32
33#print using $font
34
35SDLx::SFont::print_text( $d, 10, 10, 'Huh' );
36
37pass('[print_test] worked');
38
39$font->use();
40
41pass('[use] switch font worked');
42
43SDLx::SFont::print_text( $d, 10, 10, 'Huh' );
44pass('[use|printe_text] switch to font and print worked');
45
46END {
47	done_testing;
48
49	#reset the old video driver
50	if ($videodriver) {
51		$ENV{SDL_VIDEODRIVER} = $videodriver;
52	} else {
53		delete $ENV{SDL_VIDEODRIVER};
54	}
55
56	if ($audiodriver) {
57		$ENV{SDL_AUDIODRIVER} = $audiodriver;
58	} else {
59		delete $ENV{SDL_AUDIODRIVER};
60	}
61}