mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
66 lines
1.8 KiB
// ignore_for_file: cascade_invocations
|
|
|
|
import 'package:flame_bloc/flame_bloc.dart';
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
import 'package:flame_test/flame_test.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
class _TestGame extends Forge2DGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
images.prefix = '';
|
|
await images.loadAll([
|
|
Assets.images.multiplier.x2.lit.keyName,
|
|
Assets.images.multiplier.x2.dimmed.keyName,
|
|
Assets.images.multiplier.x3.lit.keyName,
|
|
Assets.images.multiplier.x3.dimmed.keyName,
|
|
Assets.images.multiplier.x4.lit.keyName,
|
|
Assets.images.multiplier.x4.dimmed.keyName,
|
|
Assets.images.multiplier.x5.lit.keyName,
|
|
Assets.images.multiplier.x5.dimmed.keyName,
|
|
Assets.images.multiplier.x6.lit.keyName,
|
|
Assets.images.multiplier.x6.dimmed.keyName,
|
|
]);
|
|
}
|
|
|
|
Future<void> pump(Multipliers child) async {
|
|
await ensureAdd(
|
|
FlameBlocProvider<GameBloc, GameState>.value(
|
|
value: GameBloc(),
|
|
children: [child],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final flameTester = FlameTester(_TestGame.new);
|
|
|
|
group('Multipliers', () {
|
|
flameTester.test(
|
|
'loads correctly',
|
|
(game) async {
|
|
final component = Multipliers();
|
|
await game.pump(component);
|
|
expect(game.descendants(), contains(component));
|
|
},
|
|
);
|
|
|
|
flameTester.test(
|
|
'loads five Multiplier',
|
|
(game) async {
|
|
final multipliersGroup = Multipliers();
|
|
await game.pump(multipliersGroup);
|
|
expect(
|
|
multipliersGroup.descendants().whereType<Multiplier>().length,
|
|
equals(5),
|
|
);
|
|
},
|
|
);
|
|
});
|
|
}
|