Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 126 lines (101 sloc) 4.027 kb
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
1 #!/usr/bin/perl -w
2 use strict;
54b3c65 Constants exported by default now (again)
Tobias Leich authored
3 use SDL;
4 use SDL::Audio;
afb3d72 @acme Implement SDL::AudioSpec
acme authored
5 use SDL::AudioSpec;
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
6 use Test::More;
e2076fb @kthakore Fixed another stupid O_OBJECT return for AudioSpec in t/core_audio.t TOD...
kthakore authored
7 use Devel::Peek;
8
0d55605 @kthakore Fixed broken t/core_audio tests.
kthakore authored
9 use lib 't/lib';
10 use SDL::TestTool;
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
11
d1c9e67 @kthakore Made tests wrok with no Video
kthakore authored
12 if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
0d55605 @kthakore Fixed broken t/core_audio tests.
kthakore authored
13 plan( skip_all => 'Failed to init sound' );
14 } else {
0a2a025 moved audio constants
Tobias Leich authored
15 plan( tests => 44);
0d55605 @kthakore Fixed broken t/core_audio tests.
kthakore authored
16 }
afb3d72 @acme Implement SDL::AudioSpec
acme authored
17 my @done = qw/
18 audio_spec
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
19 open
20 pause
21 close
22 get_status
23 lock
24 unlock
afb3d72 @acme Implement SDL::AudioSpec
acme authored
25 /;
26
0a2a025 moved audio constants
Tobias Leich authored
27 is( AUDIO_S16, 32784, 'AUDIO_S16 should be imported' );
28 is( AUDIO_S16(), 32784, 'AUDIO_S16() should also be available' );
29 is( AUDIO_S16MSB, 36880, 'AUDIO_S16MSB should be imported' );
30 is( AUDIO_S16MSB(), 36880, 'AUDIO_S16MSB() should also be available' );
31 is( AUDIO_S16LSB, 0x8010, 'AUDIO_S16MSB should be imported' );
32 is( AUDIO_S16LSB(), 0x8010, 'AUDIO_S16MSB() should also be available' );
33 is( AUDIO_S8, 32776, 'AUDIO_S8 should be imported' );
34 is( AUDIO_S8(), 32776, 'AUDIO_S8() should also be available' );
35 is( AUDIO_U16, 16, 'AUDIO_U16 should be imported' );
36 is( AUDIO_U16(), 16, 'AUDIO_U16() should also be available' );
37 is( AUDIO_U16MSB, 4112, 'AUDIO_U16MSB should be imported' );
38 is( AUDIO_U16MSB(), 4112, 'AUDIO_U16MSB() should also be available' );
39 is( AUDIO_U16LSB, 0x0010, 'AUDIO_U16MSB should be imported' );
40 is( AUDIO_U16LSB(), 0x0010, 'AUDIO_U16MSB() should also be available' );
41 is( AUDIO_U8, 8, 'AUDIO_U8 should be imported' );
42 is( AUDIO_U8(), 8, 'AUDIO_U8() should also be available' );
43 ok( (AUDIO_U16SYS == AUDIO_U16LSB) || (AUDIO_U16SYS == AUDIO_U16MSB), 'AUDIO_U16SYS should be imported' );
44 ok( (AUDIO_U16SYS() == AUDIO_U16LSB()) || (AUDIO_U16SYS() == AUDIO_U16MSB()), 'AUDIO_U16SYS() should also be available' );
45
46 is( SDL_AUDIO_PAUSED, 2, 'SDL_AUDIO_PAUSED should be imported' );
47 is( SDL_AUDIO_PAUSED(), 2, 'SDL_AUDIO_PAUSED() should also be available' );
48 is( SDL_AUDIO_PLAYING, 1, 'SDL_AUDIO_PLAYING should be imported' );
49 is( SDL_AUDIO_PLAYING(), 1, 'SDL_AUDIO_PLAYING() should also be available' );
50 is( SDL_AUDIO_STOPPED, 0, 'SDL_AUDIO_STOPPED should be imported' );
51 is( SDL_AUDIO_STOPPED(), 0, 'SDL_AUDIO_STOPPED() should also be available' );
0d55605 @kthakore Fixed broken t/core_audio tests.
kthakore authored
52
afb3d72 @acme Implement SDL::AudioSpec
acme authored
53 my $desired = SDL::AudioSpec->new;
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
54 $desired->freq(44100);
afb3d72 @acme Implement SDL::AudioSpec
acme authored
55 is( $desired->freq, 44100, '[audiospec] can set freq' );
0a2a025 moved audio constants
Tobias Leich authored
56 $desired->format(AUDIO_S16SYS);
57 is( $desired->format, AUDIO_S16SYS,
afb3d72 @acme Implement SDL::AudioSpec
acme authored
58 '[audiospec] can set format' );
59 $desired->channels(2);
60 is( $desired->channels, 2, '[audiospec] can set channels' );
61 $desired->samples(4096);
62 is( $desired->samples, 4096, '[audiospec] can set samples' );
783daef added callback to audiospec for SDL::audio::open
Tobias Leich authored
63 $desired->callback('main::audio_callback');
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
64
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
65 is( SDL::Audio::get_status, SDL_AUDIO_STOPPED, '[get_status stopped]' );
80a2e43 @acme Implement open_audio, pause_audio, close_audio, get_audio_status
acme authored
66
67 my $obtained = SDL::AudioSpec->new;
d56b2d8 @kthakore oops. I iz teh stuoix *.0
kthakore authored
68 is( SDL::Audio::open( $desired, $obtained ),
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
69 0, '[open returned success]' );
e2076fb @kthakore Fixed another stupid O_OBJECT return for AudioSpec in t/core_audio.t TOD...
kthakore authored
70 isa_ok( $obtained, 'SDL::AudioSpec', 'Created a new AudioSpec' );
80a2e43 @acme Implement open_audio, pause_audio, close_audio, get_audio_status
acme authored
71
c6edf02 @kthakore Cannot do load_wav after SDL::Audio::close()
kthakore authored
72
73
74 my $wav_ref = SDL::Audio::load_wav( 'test/data/sample.wav', $obtained );
75 isa_ok( $wav_ref, 'ARRAY', "Got and Array Out of load_wav. $wav_ref");
76 my ( $wav_spec, $audio_buf, $audio_len ) = @{$wav_ref};
77 isa_ok( $wav_spec, 'SDL::AudioSpec', '[load_wav] got Audio::Spec back out ');
78 is( $audio_len, 481712, '[load_wav] length is correct' );
79 SDL::Audio::free_wav($audio_buf);
80
81
82
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
83 is( SDL::Audio::get_status, SDL_AUDIO_PAUSED, '[get_status paused]' );
80a2e43 @acme Implement open_audio, pause_audio, close_audio, get_audio_status
acme authored
84
d56b2d8 @kthakore oops. I iz teh stuoix *.0
kthakore authored
85 SDL::Audio::pause(0);
80a2e43 @acme Implement open_audio, pause_audio, close_audio, get_audio_status
acme authored
86
c6edf02 @kthakore Cannot do load_wav after SDL::Audio::close()
kthakore authored
87 is( SDL::Audio::get_status, SDL_AUDIO_PLAYING, '[get_status playing]' );
25aadf6 @kthakore Okay handling bag creation manually for dyanamic O_OBJECT creation for E...
kthakore authored
88
d56b2d8 @kthakore oops. I iz teh stuoix *.0
kthakore authored
89 SDL::Audio::lock();
ee702fb @kthakore Added more tests to core_audio.t for clarity
kthakore authored
90 pass ('Audio locked');
d56b2d8 @kthakore oops. I iz teh stuoix *.0
kthakore authored
91 SDL::Audio::unlock();
ee702fb @kthakore Added more tests to core_audio.t for clarity
kthakore authored
92 pass ('Audio unlocked');
d56b2d8 @kthakore oops. I iz teh stuoix *.0
kthakore authored
93 SDL::Audio::close();
ee702fb @kthakore Added more tests to core_audio.t for clarity
kthakore authored
94 pass ('Audio Closed');
e7e64f5 docs for audio, renamed sub(s) in test and xs
Tobias Leich authored
95 is( SDL::Audio::get_status, SDL_AUDIO_STOPPED, '[get_status stopped]' );
80a2e43 @acme Implement open_audio, pause_audio, close_audio, get_audio_status
acme authored
96
e2076fb @kthakore Fixed another stupid O_OBJECT return for AudioSpec in t/core_audio.t TOD...
kthakore authored
97
4816103 @acme Implement load_wav, free_wav, with failing tests though...
acme authored
98
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
99 my @left = qw/
afb3d72 @acme Implement SDL::AudioSpec
acme authored
100 audio_cvt
101 build_audio_cvt
102 convert_audio
103 mix_audio
104 /;
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
105
106 my $why
107 = '[Percentage Completion] '
108 . int( 100 * ( $#done + 1 ) / ( $#done + $#left + 2 ) )
109 . "\% implementation. "
110 . ( $#done + 1 ) . " / "
111 . ( $#done + $#left + 2 );
112
113 TODO:
114 {
115 local $TODO = $why;
afb3d72 @acme Implement SDL::AudioSpec
acme authored
116 fail "Not Implmented $_" foreach (@left)
117
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in Bu...
kthakore authored
118 }
27b1140 silent tests now, unless --verbose switch
Tobias Leich authored
119 print "$why\n";
ee702fb @kthakore Added more tests to core_audio.t for clarity
kthakore authored
120 sleep(1);
783daef added callback to audiospec for SDL::audio::open
Tobias Leich authored
121
122 sub audio_callback
123 {
124
125 }
Something went wrong with that request. Please try again.