-
Notifications
You must be signed in to change notification settings - Fork 28
/
sdlx_text.t
53 lines (41 loc) · 1.1 KB
/
sdlx_text.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use SDL;
use SDL::Config;
use SDL::Color;
use SDL::Surface;
use SDLx::App;
BEGIN {
use FindBin;
use Test::More;
use lib 't/lib';
use SDL::TestTool;
if ( !SDL::Config->has('SDL_ttf') ) {
plan( skip_all => 'SDL_ttf support not compiled' );
}
}
use_ok( 'SDLx::Text' );
my $videodriver = $ENV{SDL_VIDEODRIVER};
$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
use File::Spec;
my $score = SDLx::Text->new(
font => File::Spec->catfile($FindBin::Bin, '..', 'share', 'GenBasR.ttf')
);
isa_ok( $score, 'SDLx::Text');
is($score->x, 0, 'default x position');
is($score->y, 0, 'default y position');
is($score->h_align, 'left', 'default horizontal alignment');
isa_ok( $score->font, 'SDL::TTF::Font' );
isa_ok($score->color, 'SDL::Color', 'default color');
is($score->size, 24, 'default size');
$score->text('Hello');
is( $score->w, 53, 'Hello! is 53 px wide!' );
is( $score->h, 28, 'Hello! is 28 px high!' );
isa_ok($score->surface, 'SDL::Surface');
END {
if ($videodriver) {
$ENV{SDL_VIDEODRIVER} = $videodriver;
} else {
delete $ENV{SDL_VIDEODRIVER};
}
done_testing;
}