test: fixed some tests for ramp

pull/296/head
RuiAlonso 3 years ago
parent 081a22f69a
commit 9f1ab42215

@ -395,7 +395,6 @@ class _SpaceshipRampOpening extends LayerSensor {
/// Small sensor body used to detect when a ball has entered the /// Small sensor body used to detect when a ball has entered the
/// [SpaceshipRamp]. /// [SpaceshipRamp].
/// {@endtemplate} /// {@endtemplate}
@visibleForTesting
class RampSensor extends BodyComponent class RampSensor extends BodyComponent
with ParentIsA<SpaceshipRamp>, InitialPosition, Layered { with ParentIsA<SpaceshipRamp>, InitialPosition, Layered {
/// {@macro ramp_sensor} /// {@macro ramp_sensor}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 187 KiB

@ -0,0 +1,49 @@
// ignore_for_file: cascade_invocations
import 'package:bloc_test/bloc_test.dart';
import 'package:flame/components.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_components/src/components/android_bumper/behaviors/behaviors.dart';
import 'package:pinball_components/src/components/bumping_behavior.dart';
import '../../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final assets = [
Assets.images.android.bumper.a.lit.keyName,
Assets.images.android.bumper.a.dimmed.keyName,
Assets.images.android.bumper.b.lit.keyName,
Assets.images.android.bumper.b.dimmed.keyName,
Assets.images.android.bumper.cow.lit.keyName,
Assets.images.android.bumper.cow.dimmed.keyName,
];
final flameTester = FlameTester(() => TestGame(assets));
group('RampSensor', () {
flameTester.test('closes bloc when removed', (game) async {
final bloc = MockRampSensorCubit();
whenListen(
bloc,
const Stream<RampSensorState>.empty(),
initialState: const RampSensorState.initial(),
);
when(bloc.close).thenAnswer((_) async {});
final rampSensor = RampSensor.test(
type: RampSensorType.door,
bloc: bloc,
);
final parent = SpaceshipRamp.test();
await game.ensureAdd(parent);
await parent.ensureAdd(rampSensor);
parent.remove(rampSensor);
await game.ready();
verify(bloc.close).called(1);
});
});
}

@ -472,8 +472,11 @@ void main() {
game.onTapUp(tapUpEvent); game.onTapUp(tapUpEvent);
await game.ready(); await game.ready();
final currentBalls =
game.descendants().whereType<ControlledBall>().toList();
expect( expect(
game.descendants().whereType<ControlledBall>().length, currentBalls.length,
equals(previousBalls.length + 1), equals(previousBalls.length + 1),
); );
}, },

Loading…
Cancel
Save