refactor: renaming to

pull/396/head
Erick Zanardo 3 years ago
parent 2284f57ac2
commit fb0eed84ef

@ -15,7 +15,7 @@ class App extends StatelessWidget {
Key? key, Key? key,
required AuthenticationRepository authenticationRepository, required AuthenticationRepository authenticationRepository,
required LeaderboardRepository leaderboardRepository, required LeaderboardRepository leaderboardRepository,
required PinballPlayer pinballPlayer, required PinballAudioPlayer pinballPlayer,
}) : _authenticationRepository = authenticationRepository, }) : _authenticationRepository = authenticationRepository,
_leaderboardRepository = leaderboardRepository, _leaderboardRepository = leaderboardRepository,
_pinballPlayer = pinballPlayer, _pinballPlayer = pinballPlayer,
@ -23,7 +23,7 @@ class App extends StatelessWidget {
final AuthenticationRepository _authenticationRepository; final AuthenticationRepository _authenticationRepository;
final LeaderboardRepository _leaderboardRepository; final LeaderboardRepository _leaderboardRepository;
final PinballPlayer _pinballPlayer; final PinballAudioPlayer _pinballPlayer;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

@ -15,7 +15,7 @@ class BonusNoiseBehavior extends Component {
}, },
onNewState: (state) { onNewState: (state) {
final bonus = state.bonusHistory.last; final bonus = state.bonusHistory.last;
final audioPlayer = readProvider<PinballPlayer>(); final audioPlayer = readProvider<PinballAudioPlayer>();
switch (bonus) { switch (bonus) {
case GameBonus.googleWord: case GameBonus.googleWord:

@ -6,6 +6,6 @@ class BumperNoiseBehavior extends ContactBehavior {
@override @override
void beginContact(Object other, Contact contact) { void beginContact(Object other, Contact contact) {
super.beginContact(other, contact); super.beginContact(other, contact);
readProvider<PinballPlayer>().play(PinballAudio.bumper); readProvider<PinballAudioPlayer>().play(PinballAudio.bumper);
} }
} }

@ -30,7 +30,7 @@ class PlungerNoiseBehavior extends Component {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
readProvider<PinballPlayer>().play(PinballAudio.launcher); readProvider<PinballAudioPlayer>().play(PinballAudio.launcher);
} }
@override @override

@ -20,7 +20,7 @@ class GameBlocStatusListener extends Component
case GameStatus.waiting: case GameStatus.waiting:
break; break;
case GameStatus.playing: case GameStatus.playing:
readProvider<PinballPlayer>().play(PinballAudio.backgroundMusic); readProvider<PinballAudioPlayer>().play(PinballAudio.backgroundMusic);
gameRef gameRef
.descendants() .descendants()
.whereType<Flipper>() .whereType<Flipper>()
@ -29,7 +29,7 @@ class GameBlocStatusListener extends Component
gameRef.overlays.remove(PinballGame.playButtonOverlay); gameRef.overlays.remove(PinballGame.playButtonOverlay);
break; break;
case GameStatus.gameOver: case GameStatus.gameOver:
readProvider<PinballPlayer>().play(PinballAudio.gameOverVoiceOver); readProvider<PinballAudioPlayer>().play(PinballAudio.gameOverVoiceOver);
gameRef.descendants().whereType<Backbox>().first.requestInitials( gameRef.descendants().whereType<Backbox>().first.requestInitials(
score: state.displayScore, score: state.displayScore,
character: readBloc<CharacterThemeCubit, CharacterThemeState>() character: readBloc<CharacterThemeCubit, CharacterThemeState>()

@ -22,10 +22,10 @@ class PinballGame extends PinballForge2DGame
required this.leaderboardRepository, required this.leaderboardRepository,
required GameBloc gameBloc, required GameBloc gameBloc,
required AppLocalizations l10n, required AppLocalizations l10n,
required PinballPlayer player, required PinballAudioPlayer audioPlayer,
}) : focusNode = FocusNode(), }) : focusNode = FocusNode(),
_gameBloc = gameBloc, _gameBloc = gameBloc,
_player = player, _audioPlayer = audioPlayer,
_characterThemeBloc = characterThemeBloc, _characterThemeBloc = characterThemeBloc,
_l10n = l10n, _l10n = l10n,
super( super(
@ -47,7 +47,7 @@ class PinballGame extends PinballForge2DGame
final CharacterThemeCubit _characterThemeBloc; final CharacterThemeCubit _characterThemeBloc;
final PinballPlayer _player; final PinballAudioPlayer _audioPlayer;
final LeaderboardRepository leaderboardRepository; final LeaderboardRepository leaderboardRepository;
@ -82,7 +82,7 @@ class PinballGame extends PinballForge2DGame
children: [ children: [
MultiFlameProvider( MultiFlameProvider(
providers: [ providers: [
FlameProvider<PinballPlayer>.value(_player), FlameProvider<PinballAudioPlayer>.value(_audioPlayer),
FlameProvider<LeaderboardRepository>.value(leaderboardRepository), FlameProvider<LeaderboardRepository>.value(leaderboardRepository),
FlameProvider<AppLocalizations>.value(_l10n), FlameProvider<AppLocalizations>.value(_l10n),
], ],
@ -188,11 +188,11 @@ class DebugPinballGame extends PinballGame with FPSCounter, PanDetector {
required CharacterThemeCubit characterThemeBloc, required CharacterThemeCubit characterThemeBloc,
required LeaderboardRepository leaderboardRepository, required LeaderboardRepository leaderboardRepository,
required AppLocalizations l10n, required AppLocalizations l10n,
required PinballPlayer player, required PinballAudioPlayer audioPlayer,
required GameBloc gameBloc, required GameBloc gameBloc,
}) : super( }) : super(
characterThemeBloc: characterThemeBloc, characterThemeBloc: characterThemeBloc,
player: player, audioPlayer: audioPlayer,
leaderboardRepository: leaderboardRepository, leaderboardRepository: leaderboardRepository,
l10n: l10n, l10n: l10n,
gameBloc: gameBloc, gameBloc: gameBloc,

@ -30,20 +30,20 @@ class PinballGamePage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final characterThemeBloc = context.read<CharacterThemeCubit>(); final characterThemeBloc = context.read<CharacterThemeCubit>();
final player = context.read<PinballPlayer>(); final audioPlayer = context.read<PinballAudioPlayer>();
final leaderboardRepository = context.read<LeaderboardRepository>(); final leaderboardRepository = context.read<LeaderboardRepository>();
final gameBloc = context.read<GameBloc>(); final gameBloc = context.read<GameBloc>();
final game = isDebugMode final game = isDebugMode
? DebugPinballGame( ? DebugPinballGame(
characterThemeBloc: characterThemeBloc, characterThemeBloc: characterThemeBloc,
player: player, audioPlayer: audioPlayer,
leaderboardRepository: leaderboardRepository, leaderboardRepository: leaderboardRepository,
l10n: context.l10n, l10n: context.l10n,
gameBloc: gameBloc, gameBloc: gameBloc,
) )
: PinballGame( : PinballGame(
characterThemeBloc: characterThemeBloc, characterThemeBloc: characterThemeBloc,
player: player, audioPlayer: audioPlayer,
leaderboardRepository: leaderboardRepository, leaderboardRepository: leaderboardRepository,
l10n: context.l10n, l10n: context.l10n,
gameBloc: gameBloc, gameBloc: gameBloc,
@ -52,7 +52,7 @@ class PinballGamePage extends StatelessWidget {
final loadables = [ final loadables = [
game.preFetchLeaderboard(), game.preFetchLeaderboard(),
...game.preLoadAssets(), ...game.preLoadAssets(),
...player.load(), ...audioPlayer.load(),
...BonusAnimation.loadAssets(), ...BonusAnimation.loadAssets(),
...SelectedCharacter.loadAssets(), ...SelectedCharacter.loadAssets(),
]; ];

@ -91,7 +91,9 @@ class _HowToPlayDialogState extends State<HowToPlayDialog> {
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {
widget.onDismissCallback.call(); widget.onDismissCallback.call();
context.read<PinballPlayer>().play(PinballAudio.ioPinballVoiceOver); context
.read<PinballAudioPlayer>()
.play(PinballAudio.ioPinballVoiceOver);
return Future.value(true); return Future.value(true);
}, },
child: PinballDialog( child: PinballDialog(

@ -11,7 +11,7 @@ void main() {
bootstrap((firestore, firebaseAuth) async { bootstrap((firestore, firebaseAuth) async {
final leaderboardRepository = LeaderboardRepository(firestore); final leaderboardRepository = LeaderboardRepository(firestore);
final authenticationRepository = AuthenticationRepository(firebaseAuth); final authenticationRepository = AuthenticationRepository(firebaseAuth);
final pinballPlayer = PinballPlayer(); final pinballPlayer = PinballAudioPlayer();
unawaited( unawaited(
Firebase.initializeApp().then( Firebase.initializeApp().then(
(_) => authenticationRepository.authenticateAnonymously(), (_) => authenticationRepository.authenticateAnonymously(),

@ -11,7 +11,7 @@ void main() {
bootstrap((firestore, firebaseAuth) async { bootstrap((firestore, firebaseAuth) async {
final leaderboardRepository = LeaderboardRepository(firestore); final leaderboardRepository = LeaderboardRepository(firestore);
final authenticationRepository = AuthenticationRepository(firebaseAuth); final authenticationRepository = AuthenticationRepository(firebaseAuth);
final pinballPlayer = PinballPlayer(); final pinballPlayer = PinballAudioPlayer();
unawaited( unawaited(
Firebase.initializeApp().then( Firebase.initializeApp().then(
(_) => authenticationRepository.authenticateAnonymously(), (_) => authenticationRepository.authenticateAnonymously(),

@ -11,7 +11,7 @@ void main() {
bootstrap((firestore, firebaseAuth) async { bootstrap((firestore, firebaseAuth) async {
final leaderboardRepository = LeaderboardRepository(firestore); final leaderboardRepository = LeaderboardRepository(firestore);
final authenticationRepository = AuthenticationRepository(firebaseAuth); final authenticationRepository = AuthenticationRepository(firebaseAuth);
final pinballPlayer = PinballPlayer(); final pinballPlayer = PinballAudioPlayer();
unawaited( unawaited(
Firebase.initializeApp().then( Firebase.initializeApp().then(
(_) => authenticationRepository.authenticateAnonymously(), (_) => authenticationRepository.authenticateAnonymously(),

@ -145,12 +145,12 @@ class _BumperAudio extends _Audio {
} }
} }
/// {@template pinball_player} /// {@template pinball_audio_player}
/// Sound manager for the pinball game /// Sound manager for the pinball game
/// {@endtemplate} /// {@endtemplate}
class PinballPlayer { class PinballAudioPlayer {
/// {@macro pinball_player} /// {@macro pinball_audio_player}
PinballPlayer({ PinballAudioPlayer({
CreateAudioPool? createAudioPool, CreateAudioPool? createAudioPool,
PlaySingleAudio? playSingleAudio, PlaySingleAudio? playSingleAudio,
LoopSingleAudio? loopSingleAudio, LoopSingleAudio? loopSingleAudio,

@ -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 PinballPlayer player; late PinballAudioPlayer player;
setUpAll(() { setUpAll(() {
registerFallbackValue(_MockAudioCache()); registerFallbackValue(_MockAudioCache());
@ -81,7 +81,7 @@ void main() {
seed = _MockRandom(); seed = _MockRandom();
player = PinballPlayer( player = PinballAudioPlayer(
configureAudioCache: configureAudioCache.onCall, configureAudioCache: configureAudioCache.onCall,
createAudioPool: createAudioPool.onCall, createAudioPool: createAudioPool.onCall,
playSingleAudio: playSingleAudio.onCall, playSingleAudio: playSingleAudio.onCall,
@ -92,7 +92,7 @@ void main() {
}); });
test('can be instantiated', () { test('can be instantiated', () {
expect(PinballPlayer(), isNotNull); expect(PinballAudioPlayer(), isNotNull);
}); });
group('load', () { group('load', () {
@ -124,7 +124,7 @@ void main() {
}); });
test('sets the correct prefix', () async { test('sets the correct prefix', () async {
player = PinballPlayer( player = PinballAudioPlayer(
createAudioPool: createAudioPool.onCall, createAudioPool: createAudioPool.onCall,
playSingleAudio: playSingleAudio.onCall, playSingleAudio: playSingleAudio.onCall,
preCacheSingleAudio: preCacheSingleAudio.onCall, preCacheSingleAudio: preCacheSingleAudio.onCall,

@ -9,7 +9,7 @@ import 'package:pinball_audio/pinball_audio.dart';
class _MockAuthenticationRepository extends Mock class _MockAuthenticationRepository extends Mock
implements AuthenticationRepository {} implements AuthenticationRepository {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockLeaderboardRepository extends Mock implements LeaderboardRepository { class _MockLeaderboardRepository extends Mock implements LeaderboardRepository {
} }
@ -18,12 +18,12 @@ void main() {
group('App', () { group('App', () {
late AuthenticationRepository authenticationRepository; late AuthenticationRepository authenticationRepository;
late LeaderboardRepository leaderboardRepository; late LeaderboardRepository leaderboardRepository;
late PinballPlayer pinballPlayer; late PinballAudioPlayer pinballPlayer;
setUp(() { setUp(() {
authenticationRepository = _MockAuthenticationRepository(); authenticationRepository = _MockAuthenticationRepository();
leaderboardRepository = _MockLeaderboardRepository(); leaderboardRepository = _MockLeaderboardRepository();
pinballPlayer = _MockPinballPlayer(); pinballPlayer = _MockPinballAudioPlayer();
when(pinballPlayer.load).thenAnswer((_) => [Future.value()]); when(pinballPlayer.load).thenAnswer((_) => [Future.value()]);
}); });

@ -14,14 +14,14 @@ import 'package:pinball_flame/pinball_flame.dart';
class _TestGame extends Forge2DGame { class _TestGame extends Forge2DGame {
Future<void> pump( Future<void> pump(
BonusNoiseBehavior child, { BonusNoiseBehavior child, {
required PinballPlayer player, required PinballAudioPlayer player,
required GameBloc bloc, required GameBloc bloc,
}) { }) {
return ensureAdd( return ensureAdd(
FlameBlocProvider<GameBloc, GameState>.value( FlameBlocProvider<GameBloc, GameState>.value(
value: bloc, value: bloc,
children: [ children: [
FlameProvider<PinballPlayer>.value( FlameProvider<PinballAudioPlayer>.value(
player, player,
children: [ children: [
child, child,
@ -33,7 +33,7 @@ class _TestGame extends Forge2DGame {
} }
} }
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockGameBloc extends Mock implements GameBloc {} class _MockGameBloc extends Mock implements GameBloc {}
@ -41,7 +41,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
group('BonusNoiseBehavior', () { group('BonusNoiseBehavior', () {
late PinballPlayer player; late PinballAudioPlayer player;
late GameBloc bloc; late GameBloc bloc;
final flameTester = FlameTester(_TestGame.new); final flameTester = FlameTester(_TestGame.new);
@ -50,7 +50,7 @@ void main() {
}); });
setUp(() { setUp(() {
player = _MockPinballPlayer(); player = _MockPinballAudioPlayer();
when(() => player.play(any())).thenAnswer((_) {}); when(() => player.play(any())).thenAnswer((_) {});
bloc = _MockGameBloc(); bloc = _MockGameBloc();
}); });

@ -9,9 +9,10 @@ import 'package:pinball_audio/pinball_audio.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
class _TestGame extends Forge2DGame { class _TestGame extends Forge2DGame {
Future<void> pump(_TestBodyComponent child, {required PinballPlayer player}) { Future<void> pump(_TestBodyComponent child,
{required PinballAudioPlayer player}) {
return ensureAdd( return ensureAdd(
FlameProvider<PinballPlayer>.value( FlameProvider<PinballAudioPlayer>.value(
player, player,
children: [ children: [
child, child,
@ -26,7 +27,7 @@ class _TestBodyComponent extends BodyComponent {
Body createBody() => world.createBody(BodyDef()); Body createBody() => world.createBody(BodyDef());
} }
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockContact extends Mock implements Contact {} class _MockContact extends Mock implements Contact {}
@ -35,11 +36,11 @@ void main() {
group('BumperNoiseBehavior', () {}); group('BumperNoiseBehavior', () {});
late PinballPlayer player; late PinballAudioPlayer player;
final flameTester = FlameTester(_TestGame.new); final flameTester = FlameTester(_TestGame.new);
setUp(() { setUp(() {
player = _MockPinballPlayer(); player = _MockPinballAudioPlayer();
}); });
flameTester.testGameWidget( flameTester.testGameWidget(

@ -28,15 +28,15 @@ class _TestGame extends Forge2DGame with HasKeyboardHandlerComponents {
Future<void> pump( Future<void> pump(
Plunger child, { Plunger child, {
GameBloc? gameBloc, GameBloc? gameBloc,
PinballPlayer? pinballPlayer, PinballAudioPlayer? pinballPlayer,
}) { }) {
return ensureAdd( return ensureAdd(
FlameBlocProvider<GameBloc, GameState>.value( FlameBlocProvider<GameBloc, GameState>.value(
value: gameBloc ?? GameBloc() value: gameBloc ?? GameBloc()
..add(const GameStarted()), ..add(const GameStarted()),
children: [ children: [
FlameProvider<PinballPlayer>.value( FlameProvider<PinballAudioPlayer>.value(
pinballPlayer ?? _MockPinballPlayer(), pinballPlayer ?? _MockPinballAudioPlayer(),
children: [child], children: [child],
) )
], ],
@ -47,7 +47,7 @@ class _TestGame extends Forge2DGame with HasKeyboardHandlerComponents {
class _MockGameBloc extends Mock implements GameBloc {} class _MockGameBloc extends Mock implements GameBloc {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
@ -158,10 +158,10 @@ void main() {
}); });
group('PlungerNoiseBehavior', () { group('PlungerNoiseBehavior', () {
late PinballPlayer player; late PinballAudioPlayer player;
setUp(() { setUp(() {
player = _MockPinballPlayer(); player = _MockPinballAudioPlayer();
}); });
flameTester.test('plays the correct sound on load', (game) async { flameTester.test('plays the correct sound on load', (game) async {

@ -36,7 +36,7 @@ class _TestGame extends Forge2DGame {
value: _MockGameBloc(), value: _MockGameBloc(),
children: [ children: [
FlameProvider.value( FlameProvider.value(
_MockPinballPlayer(), _MockPinballAudioPlayer(),
children: [ children: [
ZCanvasComponent(children: [child]), ZCanvasComponent(children: [child]),
], ],
@ -47,7 +47,7 @@ class _TestGame extends Forge2DGame {
} }
} }
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockGameBloc extends Mock implements GameBloc {} class _MockGameBloc extends Mock implements GameBloc {}

@ -30,7 +30,7 @@ class _TestGame extends Forge2DGame {
Future<void> pump( Future<void> pump(
Iterable<Component> children, { Iterable<Component> children, {
PinballPlayer? pinballPlayer, PinballAudioPlayer? pinballPlayer,
}) async { }) async {
return ensureAdd( return ensureAdd(
FlameMultiBlocProvider( FlameMultiBlocProvider(
@ -45,8 +45,8 @@ class _TestGame extends Forge2DGame {
children: [ children: [
MultiFlameProvider( MultiFlameProvider(
providers: [ providers: [
FlameProvider<PinballPlayer>.value( FlameProvider<PinballAudioPlayer>.value(
pinballPlayer ?? _MockPinballPlayer(), pinballPlayer ?? _MockPinballAudioPlayer(),
), ),
FlameProvider<AppLocalizations>.value( FlameProvider<AppLocalizations>.value(
_MockAppLocalizations(), _MockAppLocalizations(),
@ -60,7 +60,7 @@ class _TestGame extends Forge2DGame {
} }
} }
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockLeaderboardRepository extends Mock implements LeaderboardRepository { class _MockLeaderboardRepository extends Mock implements LeaderboardRepository {
} }
@ -191,7 +191,7 @@ void main() {
flameTester.test( flameTester.test(
'plays the game over voice over', 'plays the game over voice over',
(game) async { (game) async {
final player = _MockPinballPlayer(); final player = _MockPinballAudioPlayer();
final component = GameBlocStatusListener(); final component = GameBlocStatusListener();
final repository = _MockLeaderboardRepository(); final repository = _MockLeaderboardRepository();
final backbox = Backbox( final backbox = Backbox(
@ -219,7 +219,7 @@ void main() {
flameTester.test( flameTester.test(
'plays the background music on start', 'plays the background music on start',
(game) async { (game) async {
final player = _MockPinballPlayer(); final player = _MockPinballAudioPlayer();
final component = GameBlocStatusListener(); final component = GameBlocStatusListener();
await game.pump([component], pinballPlayer: player); await game.pump([component], pinballPlayer: player);

@ -36,8 +36,8 @@ class _TestGame extends Forge2DGame {
FlameBlocProvider<GameBloc, GameState>.value( FlameBlocProvider<GameBloc, GameState>.value(
value: gameBloc, value: gameBloc,
children: [ children: [
FlameProvider<PinballPlayer>.value( FlameProvider<PinballAudioPlayer>.value(
_MockPinballPlayer(), _MockPinballAudioPlayer(),
children: [child], children: [child],
) )
], ],
@ -48,7 +48,7 @@ class _TestGame extends Forge2DGame {
class _MockGameBloc extends Mock implements GameBloc {} class _MockGameBloc extends Mock implements GameBloc {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();

@ -24,7 +24,7 @@ class _TestPinballGame extends PinballGame {
leaderboardRepository: _MockLeaderboardRepository(), leaderboardRepository: _MockLeaderboardRepository(),
gameBloc: GameBloc(), gameBloc: GameBloc(),
l10n: _MockAppLocalizations(), l10n: _MockAppLocalizations(),
player: _MockPinballPlayer(), audioPlayer: _MockPinballAudioPlayer(),
); );
@override @override
@ -43,7 +43,7 @@ class _TestDebugPinballGame extends DebugPinballGame {
leaderboardRepository: _MockLeaderboardRepository(), leaderboardRepository: _MockLeaderboardRepository(),
gameBloc: GameBloc(), gameBloc: GameBloc(),
l10n: _MockAppLocalizations(), l10n: _MockAppLocalizations(),
player: _MockPinballPlayer(), audioPlayer: _MockPinballAudioPlayer(),
); );
@override @override
@ -78,7 +78,7 @@ class _MockDragEndInfo extends Mock implements DragEndInfo {}
class _MockLeaderboardRepository extends Mock implements LeaderboardRepository { class _MockLeaderboardRepository extends Mock implements LeaderboardRepository {
} }
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();

@ -26,7 +26,7 @@ class _TestPinballGame extends PinballGame {
leaderboardRepository: _MockLeaderboardRepository(), leaderboardRepository: _MockLeaderboardRepository(),
gameBloc: GameBloc(), gameBloc: GameBloc(),
l10n: _MockAppLocalizations(), l10n: _MockAppLocalizations(),
player: _MockPinballPlayer(), audioPlayer: _MockPinballAudioPlayer(),
); );
@override @override
@ -52,7 +52,7 @@ class _MockStartGameBloc extends Mock implements StartGameBloc {}
class _MockAppLocalizations extends Mock implements AppLocalizations {} class _MockAppLocalizations extends Mock implements AppLocalizations {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
class _MockLeaderboardRepository extends Mock implements LeaderboardRepository { class _MockLeaderboardRepository extends Mock implements LeaderboardRepository {
} }

@ -24,12 +24,12 @@ class _MockGameBloc extends Mock implements GameBloc {}
class _MockStartGameBloc extends Mock implements StartGameBloc {} class _MockStartGameBloc extends Mock implements StartGameBloc {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
PinballPlayer _buildDefaultPinballPlayer() { PinballAudioPlayer _buildDefaultPinballAudioPlayer() {
final player = _MockPinballPlayer(); final audioPlayer = _MockPinballAudioPlayer();
when(player.load).thenAnswer((_) => [Future.value()]); when(audioPlayer.load).thenAnswer((_) => [Future.value()]);
return player; return audioPlayer;
} }
AssetsManagerCubit _buildDefaultAssetsManagerCubit() { AssetsManagerCubit _buildDefaultAssetsManagerCubit() {
@ -55,7 +55,7 @@ extension PumpApp on WidgetTester {
AssetsManagerCubit? assetsManagerCubit, AssetsManagerCubit? assetsManagerCubit,
CharacterThemeCubit? characterThemeCubit, CharacterThemeCubit? characterThemeCubit,
LeaderboardRepository? leaderboardRepository, LeaderboardRepository? leaderboardRepository,
PinballPlayer? pinballPlayer, PinballAudioPlayer? pinballPlayer,
}) { }) {
return runAsync(() { return runAsync(() {
return pumpWidget( return pumpWidget(
@ -65,7 +65,7 @@ extension PumpApp on WidgetTester {
value: leaderboardRepository ?? _MockLeaderboardRepository(), value: leaderboardRepository ?? _MockLeaderboardRepository(),
), ),
RepositoryProvider.value( RepositoryProvider.value(
value: pinballPlayer ?? _buildDefaultPinballPlayer(), value: pinballPlayer ?? _buildDefaultPinballAudioPlayer(),
), ),
], ],
child: MultiBlocProvider( child: MultiBlocProvider(

@ -16,11 +16,11 @@ class _MockGameBloc extends Mock implements GameBloc {}
class _MockCharacterThemeCubit extends Mock implements CharacterThemeCubit {} class _MockCharacterThemeCubit extends Mock implements CharacterThemeCubit {}
class _MockPinballPlayer extends Mock implements PinballPlayer {} class _MockPinballAudioPlayer extends Mock implements PinballAudioPlayer {}
void main() { void main() {
late StartGameBloc startGameBloc; late StartGameBloc startGameBloc;
late PinballPlayer pinballPlayer; late PinballAudioPlayer pinballAudioPlayer;
late CharacterThemeCubit characterThemeCubit; late CharacterThemeCubit characterThemeCubit;
group('StartGameListener', () { group('StartGameListener', () {
@ -28,7 +28,7 @@ void main() {
await mockFlameImages(); await mockFlameImages();
startGameBloc = _MockStartGameBloc(); startGameBloc = _MockStartGameBloc();
pinballPlayer = _MockPinballPlayer(); pinballAudioPlayer = _MockPinballAudioPlayer();
characterThemeCubit = _MockCharacterThemeCubit(); characterThemeCubit = _MockCharacterThemeCubit();
}); });
@ -241,7 +241,7 @@ void main() {
child: SizedBox.shrink(), child: SizedBox.shrink(),
), ),
startGameBloc: startGameBloc, startGameBloc: startGameBloc,
pinballPlayer: pinballPlayer, pinballPlayer: pinballAudioPlayer,
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -258,7 +258,7 @@ void main() {
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
verify(() => pinballPlayer.play(PinballAudio.ioPinballVoiceOver)) verify(() => pinballAudioPlayer.play(PinballAudio.ioPinballVoiceOver))
.called(1); .called(1);
}, },
); );

Loading…
Cancel
Save