|
|
@ -51,7 +51,7 @@ void main() {
|
|
|
|
late _MockLoopSingleAudio loopSingleAudio;
|
|
|
|
late _MockLoopSingleAudio loopSingleAudio;
|
|
|
|
late _PreCacheSingleAudio preCacheSingleAudio;
|
|
|
|
late _PreCacheSingleAudio preCacheSingleAudio;
|
|
|
|
late Random seed;
|
|
|
|
late Random seed;
|
|
|
|
late PinballAudio audio;
|
|
|
|
late PinballPlayer player;
|
|
|
|
|
|
|
|
|
|
|
|
setUpAll(() {
|
|
|
|
setUpAll(() {
|
|
|
|
registerFallbackValue(_MockAudioCache());
|
|
|
|
registerFallbackValue(_MockAudioCache());
|
|
|
@ -81,7 +81,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
|
|
seed = _MockRandom();
|
|
|
|
seed = _MockRandom();
|
|
|
|
|
|
|
|
|
|
|
|
audio = PinballAudio(
|
|
|
|
player = PinballPlayer(
|
|
|
|
configureAudioCache: configureAudioCache.onCall,
|
|
|
|
configureAudioCache: configureAudioCache.onCall,
|
|
|
|
createAudioPool: createAudioPool.onCall,
|
|
|
|
createAudioPool: createAudioPool.onCall,
|
|
|
|
playSingleAudio: playSingleAudio.onCall,
|
|
|
|
playSingleAudio: playSingleAudio.onCall,
|
|
|
@ -92,12 +92,12 @@ void main() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('can be instantiated', () {
|
|
|
|
test('can be instantiated', () {
|
|
|
|
expect(PinballAudio(), isNotNull);
|
|
|
|
expect(PinballPlayer(), isNotNull);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
group('load', () {
|
|
|
|
group('load', () {
|
|
|
|
test('creates the bumpers pools', () async {
|
|
|
|
test('creates the bumpers pools', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
verify(
|
|
|
|
() => createAudioPool.onCall(
|
|
|
|
() => createAudioPool.onCall(
|
|
|
@ -117,25 +117,25 @@ void main() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('configures the audio cache instance', () async {
|
|
|
|
test('configures the audio cache instance', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
|
|
|
|
|
|
|
|
verify(() => configureAudioCache.onCall(FlameAudio.audioCache))
|
|
|
|
verify(() => configureAudioCache.onCall(FlameAudio.audioCache))
|
|
|
|
.called(1);
|
|
|
|
.called(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('sets the correct prefix', () async {
|
|
|
|
test('sets the correct prefix', () async {
|
|
|
|
audio = PinballAudio(
|
|
|
|
player = PinballPlayer(
|
|
|
|
createAudioPool: createAudioPool.onCall,
|
|
|
|
createAudioPool: createAudioPool.onCall,
|
|
|
|
playSingleAudio: playSingleAudio.onCall,
|
|
|
|
playSingleAudio: playSingleAudio.onCall,
|
|
|
|
preCacheSingleAudio: preCacheSingleAudio.onCall,
|
|
|
|
preCacheSingleAudio: preCacheSingleAudio.onCall,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
|
|
|
|
|
|
|
|
expect(FlameAudio.audioCache.prefix, equals(''));
|
|
|
|
expect(FlameAudio.audioCache.prefix, equals(''));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('pre cache the assets', () async {
|
|
|
|
test('pre cache the assets', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
verify(
|
|
|
|
() => preCacheSingleAudio
|
|
|
|
() => preCacheSingleAudio
|
|
|
@ -184,8 +184,8 @@ void main() {
|
|
|
|
group('when seed is true', () {
|
|
|
|
group('when seed is true', () {
|
|
|
|
test('plays the bumper A sound pool', () async {
|
|
|
|
test('plays the bumper A sound pool', () async {
|
|
|
|
when(seed.nextBool).thenReturn(true);
|
|
|
|
when(seed.nextBool).thenReturn(true);
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
audio.bumper();
|
|
|
|
player.play(PinballAudio.bumper);
|
|
|
|
|
|
|
|
|
|
|
|
verify(() => bumperAPool.start(volume: 0.6)).called(1);
|
|
|
|
verify(() => bumperAPool.start(volume: 0.6)).called(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -194,8 +194,8 @@ void main() {
|
|
|
|
group('when seed is false', () {
|
|
|
|
group('when seed is false', () {
|
|
|
|
test('plays the bumper B sound pool', () async {
|
|
|
|
test('plays the bumper B sound pool', () async {
|
|
|
|
when(seed.nextBool).thenReturn(false);
|
|
|
|
when(seed.nextBool).thenReturn(false);
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
audio.bumper();
|
|
|
|
player.play(PinballAudio.bumper);
|
|
|
|
|
|
|
|
|
|
|
|
verify(() => bumperBPool.start(volume: 0.6)).called(1);
|
|
|
|
verify(() => bumperBPool.start(volume: 0.6)).called(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -204,8 +204,8 @@ void main() {
|
|
|
|
|
|
|
|
|
|
|
|
group('googleBonus', () {
|
|
|
|
group('googleBonus', () {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
audio.googleBonus();
|
|
|
|
player.play(PinballAudio.google);
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
verify(
|
|
|
|
() => playSingleAudio
|
|
|
|
() => playSingleAudio
|
|
|
@ -216,8 +216,8 @@ void main() {
|
|
|
|
|
|
|
|
|
|
|
|
group('ioPinballVoiceOver', () {
|
|
|
|
group('ioPinballVoiceOver', () {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
audio.ioPinballVoiceOver();
|
|
|
|
player.play(PinballAudio.ioPinballVoiceOver);
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
verify(
|
|
|
|
() => playSingleAudio.onCall(
|
|
|
|
() => playSingleAudio.onCall(
|
|
|
@ -229,8 +229,8 @@ void main() {
|
|
|
|
|
|
|
|
|
|
|
|
group('backgroundMusic', () {
|
|
|
|
group('backgroundMusic', () {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
test('plays the correct file', () async {
|
|
|
|
await Future.wait(audio.load());
|
|
|
|
await Future.wait(player.load());
|
|
|
|
audio.backgroundMusic();
|
|
|
|
player.play(PinballAudio.backgroundMusic);
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
verify(
|
|
|
|
() => loopSingleAudio
|
|
|
|
() => loopSingleAudio
|
|
|
|