PageRenderTime 25ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/t/sdlx_sound.t

http://github.com/PerlGameDev/SDL
Unknown | 94 lines | 77 code | 17 blank | 0 comment | 0 complexity | b8342f549a9e82398f597dc5f09df497 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. # basic testing of SDLx::Sound
  2. use strict;
  3. use warnings;
  4. my $audiodriver;
  5. BEGIN {
  6. use Config;
  7. if ( !$Config{'useithreads'} ) {
  8. print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
  9. exit(0);
  10. }
  11. use Test::More;
  12. use lib 't/lib';
  13. use lib 'lib';
  14. use SDL;
  15. use SDL::TestTool;
  16. use SDL::Config;
  17. use SDLx::Sound;
  18. $audiodriver = $ENV{SDL_AUDIODRIVER};
  19. $ENV{SDL_AUDIODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
  20. if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
  21. plan( skip_all => 'Failed to init sound' );
  22. } elsif ( !SDL::Config->has('SDL_mixer') ) {
  23. plan( skip_all => 'SDL_mixer support not compiled' );
  24. }
  25. }
  26. my $fase2 = 0;
  27. # load
  28. # NOTE: use ok is tested in t/00-load.t so we can bail out
  29. # methods
  30. can_ok(
  31. 'SDLx::Sound', qw/
  32. new
  33. load
  34. unload
  35. play
  36. stop
  37. loud
  38. fade
  39. /
  40. );
  41. ok (my $snd = SDLx::Sound->new(), 'Can be instantiated');
  42. ok (my $snd2 = SDLx::Sound->new(), 'Can be instantiated again');
  43. isa_ok( $snd, 'SDLx::Sound', 'snd' );
  44. isa_ok( $snd2, 'SDLx::Sound', 'snd2' );
  45. # load and play a sound
  46. ok ($snd->play('test/data/sample.wav'), 'Can play a wav');
  47. SKIP:
  48. {
  49. skip 'complex tests', 1 unless $fase2;
  50. # in a single act do the wole Sound
  51. ok( my $snd2 = SDLx::Sound->new(
  52. files => (
  53. chanell_01 => "test/data/sample.wav",
  54. chanell_02 => "test/data/tribe_i.wav"
  55. ),
  56. loud => (
  57. channel_01 => 80,
  58. channel_02 => 75
  59. ),
  60. bangs => (
  61. chanell_01 => 0, # start
  62. chanell_01 => 1256, # miliseconds
  63. chanell_02 => 2345
  64. ),
  65. fade => (
  66. chanell_02 => [2345, 3456, -20]
  67. )
  68. )->play()
  69. );
  70. }
  71. #diag( "Testing SDLx::Sound $SDLx::Sound::VERSION, Perl $], $^X" );
  72. if ($audiodriver) {
  73. $ENV{SDL_AUDIODRIVER} = $audiodriver;
  74. } else {
  75. delete $ENV{SDL_AUDIODRIVER};
  76. }
  77. done_testing();