|
|
@ -10,11 +10,11 @@ import '../../helpers/helpers.dart';
|
|
|
|
class TestLayerSensor extends LayerSensor {
|
|
|
|
class TestLayerSensor extends LayerSensor {
|
|
|
|
TestLayerSensor({
|
|
|
|
TestLayerSensor({
|
|
|
|
required LayerEntranceOrientation orientation,
|
|
|
|
required LayerEntranceOrientation orientation,
|
|
|
|
required int insidePriority,
|
|
|
|
required int insideZIndex,
|
|
|
|
required Layer insideLayer,
|
|
|
|
required Layer insideLayer,
|
|
|
|
}) : super(
|
|
|
|
}) : super(
|
|
|
|
insideLayer: insideLayer,
|
|
|
|
insideLayer: insideLayer,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insideZIndex,
|
|
|
|
orientation: orientation,
|
|
|
|
orientation: orientation,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
@ -48,7 +48,7 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
@ -66,7 +66,7 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
)..layer = openingLayer;
|
|
|
|
)..layer = openingLayer;
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
@ -80,7 +80,7 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
)..layer = openingLayer;
|
|
|
|
)..layer = openingLayer;
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
@ -95,7 +95,7 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
final layerSensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
insideLayer: pathwayLayer,
|
|
|
|
)..layer = openingLayer;
|
|
|
|
)..layer = openingLayer;
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
|
await game.ensureAdd(layerSensor);
|
|
|
@ -111,10 +111,14 @@ void main() {
|
|
|
|
group('beginContact', () {
|
|
|
|
group('beginContact', () {
|
|
|
|
late Ball ball;
|
|
|
|
late Ball ball;
|
|
|
|
late Body body;
|
|
|
|
late Body body;
|
|
|
|
|
|
|
|
late int insideZIndex;
|
|
|
|
|
|
|
|
late Layer insideLayer;
|
|
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
setUp(() {
|
|
|
|
ball = MockBall();
|
|
|
|
ball = MockBall();
|
|
|
|
body = MockBody();
|
|
|
|
body = MockBody();
|
|
|
|
|
|
|
|
insideZIndex = 1;
|
|
|
|
|
|
|
|
insideLayer = Layer.spaceshipEntranceRamp;
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
when(() => ball.priority).thenReturn(1);
|
|
|
|
when(() => ball.priority).thenReturn(1);
|
|
|
@ -127,23 +131,21 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final sensor = TestLayerSensor(
|
|
|
|
final sensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
orientation: LayerEntranceOrientation.down,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
insideLayer: insideLayer,
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
|
|
|
|
|
|
|
|
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
verify(() => ball.layer = sensor.insideLayer).called(1);
|
|
|
|
verify(() => ball.layer = insideLayer).called(1);
|
|
|
|
verify(() => ball.priority = sensor.insidePriority).called(1);
|
|
|
|
verify(() => ball.zIndex = insideZIndex).called(1);
|
|
|
|
verify(ball.reorderChildren).called(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(sensor.insideLayer);
|
|
|
|
when(() => ball.layer).thenReturn(insideLayer);
|
|
|
|
|
|
|
|
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.priority = RenderPriority.ballOnBoard).called(1);
|
|
|
|
verify(() => ball.zIndex = RenderPriority.ballOnBoard).called(1);
|
|
|
|
verify(ball.reorderChildren).called(1);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
@ -152,23 +154,21 @@ void main() {
|
|
|
|
(game) async {
|
|
|
|
(game) async {
|
|
|
|
final sensor = TestLayerSensor(
|
|
|
|
final sensor = TestLayerSensor(
|
|
|
|
orientation: LayerEntranceOrientation.up,
|
|
|
|
orientation: LayerEntranceOrientation.up,
|
|
|
|
insidePriority: insidePriority,
|
|
|
|
insideZIndex: insidePriority,
|
|
|
|
insideLayer: Layer.spaceshipEntranceRamp,
|
|
|
|
insideLayer: insideLayer,
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
|
|
|
|
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
verify(() => ball.layer = sensor.insideLayer).called(1);
|
|
|
|
verify(() => ball.layer = insideLayer).called(1);
|
|
|
|
verify(() => ball.priority = sensor.insidePriority).called(1);
|
|
|
|
verify(() => ball.zIndex = insidePriority).called(1);
|
|
|
|
verify(ball.reorderChildren).called(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(sensor.insideLayer);
|
|
|
|
when(() => ball.layer).thenReturn(insideLayer);
|
|
|
|
|
|
|
|
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
sensor.beginContact(ball, MockContact());
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.priority = RenderPriority.ballOnBoard).called(1);
|
|
|
|
verify(() => ball.zIndex = RenderPriority.ballOnBoard).called(1);
|
|
|
|
verify(ball.reorderChildren).called(1);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|