|
|
|
@ -117,251 +117,6 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('renders correctly', () {
|
|
|
|
|
const goldenFilePath = '../golden/spaceship_ramp/';
|
|
|
|
|
final centerForSpaceshipRamp = Vector2(-13, -55);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'inactive sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: SpaceshipRampState.initial(),
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.inactive,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}inactive.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'active1 sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final state = SpaceshipRampState.initial();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: state,
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
streamController.add(
|
|
|
|
|
state.copyWith(lightState: ArrowLightState.active1),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.active1,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}active1.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'active2 sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final state = SpaceshipRampState.initial();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: state,
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
streamController.add(
|
|
|
|
|
state.copyWith(lightState: ArrowLightState.active2),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.active2,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}active2.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'active3 sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final state = SpaceshipRampState.initial();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: state,
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
streamController.add(
|
|
|
|
|
state.copyWith(lightState: ArrowLightState.active3),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.active3,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}active3.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'active4 sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final state = SpaceshipRampState.initial();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: state,
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
streamController.add(
|
|
|
|
|
state.copyWith(lightState: ArrowLightState.active4),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.active4,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}active4.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameTester.testGameWidget(
|
|
|
|
|
'active5 sprite',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|
final state = SpaceshipRampState.initial();
|
|
|
|
|
final streamController = StreamController<SpaceshipRampState>();
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: state,
|
|
|
|
|
);
|
|
|
|
|
final ramp = SpaceshipRamp.test(bloc: bloc);
|
|
|
|
|
await game.ensureAdd(ramp);
|
|
|
|
|
|
|
|
|
|
streamController.add(
|
|
|
|
|
state.copyWith(lightState: ArrowLightState.active5),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
final current = ramp.children
|
|
|
|
|
.whereType<SpaceshipRampArrowSpriteComponent>()
|
|
|
|
|
.first
|
|
|
|
|
.current;
|
|
|
|
|
expect(
|
|
|
|
|
current,
|
|
|
|
|
ArrowLightState.active5,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.camera.followVector2(centerForSpaceshipRamp);
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
await expectLater(
|
|
|
|
|
find.byGame<_TestGame>(),
|
|
|
|
|
matchesGoldenFile('${goldenFilePath}active5.png'),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('adds', () {
|
|
|
|
|
flameTester.test('new children', (game) async {
|
|
|
|
|
final bloc = _MockSpaceshipRampCubit();
|
|
|
|
|