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.
70 lines
1.6 KiB
70 lines
1.6 KiB
3 years ago
|
// 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/game/game.dart';
|
||
|
|
||
|
void main() {
|
||
3 years ago
|
group('Kicker', () {
|
||
3 years ago
|
// TODO(alestiago): Include golden tests for left and right.
|
||
3 years ago
|
final flameTester = FlameTester(Forge2DGame.new);
|
||
|
|
||
|
flameTester.test(
|
||
|
'loads correctly',
|
||
|
(game) async {
|
||
3 years ago
|
final kicker = Kicker(
|
||
3 years ago
|
side: BoardSide.left,
|
||
|
);
|
||
3 years ago
|
await game.ensureAdd(kicker);
|
||
3 years ago
|
|
||
3 years ago
|
expect(game.contains(kicker), isTrue);
|
||
3 years ago
|
},
|
||
|
);
|
||
|
|
||
3 years ago
|
flameTester.test(
|
||
|
'body is static',
|
||
|
(game) async {
|
||
3 years ago
|
final kicker = Kicker(
|
||
3 years ago
|
side: BoardSide.left,
|
||
|
);
|
||
3 years ago
|
await game.ensureAdd(kicker);
|
||
3 years ago
|
|
||
3 years ago
|
expect(kicker.body.bodyType, equals(BodyType.static));
|
||
3 years ago
|
},
|
||
|
);
|
||
3 years ago
|
|
||
3 years ago
|
flameTester.test(
|
||
|
'has restitution',
|
||
|
(game) async {
|
||
3 years ago
|
final kicker = Kicker(
|
||
3 years ago
|
side: BoardSide.left,
|
||
|
);
|
||
3 years ago
|
await game.ensureAdd(kicker);
|
||
3 years ago
|
|
||
3 years ago
|
final totalRestitution = kicker.body.fixtures.fold<double>(
|
||
3 years ago
|
0,
|
||
|
(total, fixture) => total + fixture.restitution,
|
||
|
);
|
||
|
expect(totalRestitution, greaterThan(0));
|
||
|
},
|
||
|
);
|
||
3 years ago
|
|
||
3 years ago
|
flameTester.test(
|
||
|
'has no friction',
|
||
|
(game) async {
|
||
3 years ago
|
final kicker = Kicker(
|
||
3 years ago
|
side: BoardSide.left,
|
||
|
);
|
||
3 years ago
|
await game.ensureAdd(kicker);
|
||
3 years ago
|
|
||
3 years ago
|
final totalFriction = kicker.body.fixtures.fold<double>(
|
||
3 years ago
|
0,
|
||
|
(total, fixture) => total + fixture.friction,
|
||
|
);
|
||
|
expect(totalFriction, equals(0));
|
||
|
},
|
||
|
);
|
||
3 years ago
|
});
|
||
|
}
|