File: gfx_fpsmanager.t

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (58 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (7)
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
56
57
58
#!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 => 11 );
}

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 );

my $fps = SDL::GFX::FPSManager->new( 0, 0, 0, 0 );

isa_ok( $fps, 'SDL::GFX::FPSManager' );
is( $fps->framecount, 0, 'fps has framecount' );
is( $fps->rateticks,  0, 'fps has rateticks' );
is( $fps->lastticks,  0, 'fps has lastticks' );
is( $fps->rate,       0, 'fps has rate' );

$fps->framecount(1);
$fps->rateticks(2);
$fps->lastticks(3);
$fps->rate(4);

is( $fps->framecount, 1, 'fps has framecount' );
is( $fps->rateticks,  2, 'fps has rateticks' );
is( $fps->lastticks,  3, 'fps has lastticks' );
is( $fps->rate,       4, 'fps has rate' );

SDL::delay(100);

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

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

done_testing;