PageRenderTime 43ms CodeModel.GetById 12ms app.highlight 25ms RepoModel.GetById 2ms app.codeStats 0ms

/t/sdlx_text.t

http://github.com/PerlGameDev/SDL
Unknown | 58 lines | 46 code | 12 blank | 0 comment | 0 complexity | c39826073f3a860c867b1d03aa874e58 MD5 | raw file
 1use strict;
 2use warnings;
 3use SDL;
 4use SDL::Config;
 5use SDL::Color;
 6use SDL::Surface;
 7use SDLx::App;
 8BEGIN {
 9	use FindBin;
10	use Test::More;
11	use lib 't/lib';
12	use SDL::TestTool;
13
14	if ( !SDL::Config->has('SDL_ttf') ) {
15		plan( skip_all => 'SDL_ttf support not compiled' );
16	}
17}
18
19use_ok( 'SDLx::Text' );
20
21my $videodriver = $ENV{SDL_VIDEODRIVER};
22$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
23
24use File::Spec;
25my $score = SDLx::Text->new(
26       font => File::Spec->catfile($FindBin::Bin, '..', 'share', 'GenBasR.ttf')
27);
28
29isa_ok( $score, 'SDLx::Text');
30
31is($score->x, 0, 'default x position');
32is($score->y, 0, 'default y position');
33is($score->h_align, 'left', 'default horizontal alignment');
34isa_ok( $score->font, 'SDL::TTF::Font' );
35isa_ok($score->color, 'SDL::Color', 'default color');
36is($score->size, 24, 'default size');
37
38$score->text('Hello');
39
40is( $score->text, 'Hello', 'text() as a getter' );
41ok( $score->w >= 50 && $score->w <= 53, 'Hello! is 50..53 px wide!' );
42is( $score->h, 28, 'Hello! is 28 px high!' );
43isa_ok($score->surface, 'SDL::Surface');
44
45my $value = undef;
46my $other_self = $score->text($value);
47isa_ok($score, 'SDLx::Text');
48
49END {
50
51	if ($videodriver) {
52		$ENV{SDL_VIDEODRIVER} = $videodriver;
53	} else {
54		delete $ENV{SDL_VIDEODRIVER};
55	}
56
57	done_testing;
58}