refactor: spaceship ramp tests

pull/207/head
RuiAlonso 3 years ago
parent 2e80485a4e
commit 2c529e8b51

@ -15,12 +15,6 @@ class SpaceshipRamp extends Forge2DBlueprint {
/// {@macro spaceship_ramp}
SpaceshipRamp();
/// Forwards the sprite to the next [SpaceshipRampArrowSpriteState].
///
/// If the current state is the last one it goes back to the initial state.
void progress() =>
firstChild<_SpaceshipRampArrowSpriteComponent>()?.progress();
@override
void build(_) {
addAllContactCallback([
@ -150,6 +144,7 @@ class _SpaceshipRampBackgroundRampSpriteComponent extends SpriteComponent
@override
Future<void> onLoad() async {
await super.onLoad();
// TODO(ruimiguel): update asset correctly cut from the ramp opening.
final sprite = await gameRef.loadSprite(
Assets.images.spaceship.ramp.main.keyName,
);
@ -201,12 +196,6 @@ extension SpaceshipRampArrowSpriteStateX on SpaceshipRampArrowSpriteState {
return Assets.images.spaceship.ramp.arrow.fiveActive.keyName;
}
}
/// Gives next sprite state
SpaceshipRampArrowSpriteState get next {
return SpaceshipRampArrowSpriteState
.values[(index + 1) % SpaceshipRampArrowSpriteState.values.length];
}
}
class _SpaceshipRampArrowSpriteComponent
@ -215,8 +204,6 @@ class _SpaceshipRampArrowSpriteComponent
_SpaceshipRampArrowSpriteComponent()
: super(priority: RenderPriority.spaceshipRampBackgroundRailing);
void progress() => current = current?.next;
@override
Future<void> onLoad() async {
await super.onLoad();
@ -238,6 +225,7 @@ class _SpaceshipRampBoardOpeningSpriteComponent extends SpriteComponent
@override
Future<void> onLoad() async {
await super.onLoad();
// TODO(ruimiguel): update asset correctly cut from the ramp background.
final sprite = await gameRef.loadSprite(
Assets.images.spaceship.ramp.boardOpening.keyName,
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

@ -1,8 +1,10 @@
// ignore_for_file: cascade_invocations
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart';
import '../../helpers/helpers.dart';
@ -22,29 +24,20 @@ void main() {
);
group('renders correctly', () {
/*
flameTester.testGameWidget(
'inactive sprite',
'renders correctly',
setUp: (game, tester) async {
final spaceshipRamp = SpaceshipRamp();
await game.addFromBlueprint(spaceshipRamp);
await game.ready();
expect(
spaceshipRamp.firstChild<SpriteGroupComponent>()?.current,
SpaceshipRampArrowSpriteState.inactive,
);
await game.addFromBlueprint(SpaceshipRamp());
game.camera.followVector2(Vector2(-13, -50));
await game.ready();
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/spaceship_ramp/inactive.png'),
matchesGoldenFile('golden/spaceship_ramp/ramp.png'),
);
},
);
*/
});
});
}

Loading…
Cancel
Save