PageRenderTime 33ms CodeModel.GetById 13ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 1ms

/t/gfx_fpsmanager.t

http://github.com/PerlGameDev/SDL
Perl | 58 lines | 45 code | 12 blank | 1 comment | 4 complexity | 0ff8d7f68021198e7a759c04f6c2e4d5 MD5 | raw file
 1#!perl
 2use strict;
 3use warnings;
 4use SDL;
 5use SDL::Config;
 6use SDL::Version;
 7use SDL::GFX;
 8use SDL::GFX::Framerate;
 9use SDL::GFX::FPSManager;
10use Test::More;
11
12use lib 't/lib';
13use SDL::TestTool;
14
15my $videodriver = $ENV{SDL_VIDEODRIVER};
16$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
17
18if ( !SDL::TestTool->init(SDL_INIT_VIDEO) ) {
19	plan( skip_all => 'Failed to init video' );
20} elsif ( !SDL::Config->has('SDL_gfx_framerate') ) {
21	plan( skip_all => 'SDL_gfx_framerate support not compiled' );
22} else {
23	plan( tests => 11 );
24}
25
26my $v = SDL::GFX::linked_version();
27isa_ok( $v, 'SDL::Version', '[linked_version]' );
28printf( "got version: %d.%d.%d\n", $v->major, $v->minor, $v->patch );
29
30my $fps = SDL::GFX::FPSManager->new( 0, 0, 0, 0 );
31
32isa_ok( $fps, 'SDL::GFX::FPSManager' );
33is( $fps->framecount, 0, 'fps has framecount' );
34is( $fps->rateticks,  0, 'fps has rateticks' );
35is( $fps->lastticks,  0, 'fps has lastticks' );
36is( $fps->rate,       0, 'fps has rate' );
37
38$fps->framecount(1);
39$fps->rateticks(2);
40$fps->lastticks(3);
41$fps->rate(4);
42
43is( $fps->framecount, 1, 'fps has framecount' );
44is( $fps->rateticks,  2, 'fps has rateticks' );
45is( $fps->lastticks,  3, 'fps has lastticks' );
46is( $fps->rate,       4, 'fps has rate' );
47
48SDL::delay(100);
49
50if ($videodriver) {
51	$ENV{SDL_VIDEODRIVER} = $videodriver;
52} else {
53	delete $ENV{SDL_VIDEODRIVER};
54}
55
56pass 'Are we still alive? Checking for segfaults';
57
58done_testing;