/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
  2. use strict;
  3. use warnings;
  4. use SDL;
  5. use SDL::Config;
  6. use SDL::Version;
  7. use SDL::GFX;
  8. use SDL::GFX::Framerate;
  9. use SDL::GFX::FPSManager;
  10. use Test::More;
  11. use lib 't/lib';
  12. use SDL::TestTool;
  13. my $videodriver = $ENV{SDL_VIDEODRIVER};
  14. $ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
  15. if ( !SDL::TestTool->init(SDL_INIT_VIDEO) ) {
  16. plan( skip_all => 'Failed to init video' );
  17. } elsif ( !SDL::Config->has('SDL_gfx_framerate') ) {
  18. plan( skip_all => 'SDL_gfx_framerate support not compiled' );
  19. } else {
  20. plan( tests => 6 );
  21. }
  22. my $v = SDL::GFX::linked_version();
  23. isa_ok( $v, 'SDL::Version', '[linked_version]' );
  24. printf( "got version: %d.%d.%d\n", $v->major, $v->minor, $v->patch );
  25. # init
  26. my $fps = SDL::GFX::FPSManager->new( 0, 0, 0, 0 );
  27. is( SDL::GFX::Framerate::init($fps), undef, '[init] returns undef' );
  28. # get
  29. my $rate = SDL::GFX::Framerate::get($fps);
  30. is( $rate, 30, "[rate] is 30 by default" );
  31. # set
  32. SDL::GFX::Framerate::set( $fps, 60 );
  33. is( SDL::GFX::Framerate::get($fps), 60, "[rate] successfully set to 60" );
  34. # delay
  35. is( SDL::GFX::Framerate::delay($fps), undef, "[delay] return undef" );
  36. SDL::delay(100);
  37. if ($videodriver) {
  38. $ENV{SDL_VIDEODRIVER} = $videodriver;
  39. } else {
  40. delete $ENV{SDL_VIDEODRIVER};
  41. }
  42. pass 'Are we still alive? Checking for segfaults';
  43. done_testing;