Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 55 lines (43 sloc) 1.31 kb
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 54 55
#!perl
use strict;
use warnings;
use SDL;
use SDL::Config;
use SDL::Version;
use SDL::GFX;
use SDL::GFX::Framerate;
use SDL::GFX::FPSManager;
use Test::More;

use lib 't/lib';
use SDL::TestTool;

my $videodriver = $ENV{SDL_VIDEODRIVER};
$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};

if ( !SDL::TestTool->init(SDL_INIT_VIDEO) ) {
plan( skip_all => 'Failed to init video' );
} elsif ( !SDL::Config->has('SDL_gfx_framerate') ) {
plan( skip_all => 'SDL_gfx_framerate support not compiled' );
} else {
plan( tests => 6 );
}

my $v = SDL::GFX::linked_version();
isa_ok( $v, 'SDL::Version', '[linked_version]' );
printf( "got version: %d.%d.%d\n", $v->major, $v->minor, $v->patch );

# init
my $fps = SDL::GFX::FPSManager->new( 0, 0, 0, 0 );
is( SDL::GFX::Framerate::init($fps), undef, '[init] returns undef' );

# get
my $rate = SDL::GFX::Framerate::get($fps);
is( $rate, 30, "[rate] is 30 by default" );

# set
SDL::GFX::Framerate::set( $fps, 60 );
is( SDL::GFX::Framerate::get($fps), 60, "[rate] successfully set to 60" );

# delay
is( SDL::GFX::Framerate::delay($fps), undef, "[delay] return undef" );

SDL::delay(100);

if ($videodriver) {
$ENV{SDL_VIDEODRIVER} = $videodriver;
} else {
delete $ENV{SDL_VIDEODRIVER};
}

pass 'Are we still alive? Checking for segfaults';

done_testing;
Something went wrong with that request. Please try again.