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

/t/gfx_framerate.t

http://github.com/PerlGameDev/SDL
Perl | 55 lines | 38 code | 12 blank | 5 comment | 4 complexity | a0fbc37028b79074b1d667c7c24d330b 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 => 6 );
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
30# init
31my $fps = SDL::GFX::FPSManager->new( 0, 0, 0, 0 );
32is( SDL::GFX::Framerate::init($fps), undef, '[init] returns undef' );
33
34# get
35my $rate = SDL::GFX::Framerate::get($fps);
36is( $rate, 30, "[rate] is 30 by default" );
37
38# set
39SDL::GFX::Framerate::set( $fps, 60 );
40is( SDL::GFX::Framerate::get($fps), 60, "[rate] successfully set to 60" );
41
42# delay
43is( SDL::GFX::Framerate::delay($fps), undef, "[delay] return undef" );
44
45SDL::delay(100);
46
47if ($videodriver) {
48	$ENV{SDL_VIDEODRIVER} = $videodriver;
49} else {
50	delete $ENV{SDL_VIDEODRIVER};
51}
52
53pass 'Are we still alive? Checking for segfaults';
54
55done_testing;