Fixes some more tests

pull/505/head
Alvaro Almeida Freire Stivi 1 year ago
parent 73e0627700
commit 5e29fbdebc
No known key found for this signature in database

@ -33,9 +33,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'loads correctly', 'loads correctly',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball(); final ball = Ball();
await game.ready();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
expect(game.descendants().whereType<Ball>(), isNotEmpty); expect(game.descendants().whereType<Ball>(), isNotEmpty);
@ -45,9 +46,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'has only one SpriteComponent', 'has only one SpriteComponent',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball(); final ball = Ball();
await game.ready();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final ball = game.descendants().whereType<Ball>().single; final ball = game.descendants().whereType<Ball>().single;
@ -61,9 +63,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'BallSpriteComponent changes sprite onNewState', 'BallSpriteComponent changes sprite onNewState',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball(); final ball = Ball();
await game.ready();
await game.ensureAdd(ball); await game.ensureAdd(ball);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final ball = game.descendants().whereType<Ball>().single; final ball = game.descendants().whereType<Ball>().single;

@ -28,11 +28,13 @@ void main() {
'impulses the ball with the given velocity when loaded ' 'impulses the ball with the given velocity when loaded '
'and then removes itself', 'and then removes itself',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball.test(); final ball = Ball.test();
await game.ensureAdd(ball); await game.ensureAdd(ball);
final impulse = Vector2.all(1); final impulse = Vector2.all(1);
final behavior = BallImpulsingBehavior(impulse: impulse); final behavior = BallImpulsingBehavior(impulse: impulse);
await ball.ensureAdd(behavior); await ball.ensureAdd(behavior);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final ball = game.descendants().whereType<Ball>().single; final ball = game.descendants().whereType<Ball>().single;

@ -36,6 +36,7 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'sets ball sprite to visible and sets a linear velocity', 'sets ball sprite to visible and sets a linear velocity',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball(); final ball = Ball();
final behavior = ChromeDinoSpittingBehavior(); final behavior = ChromeDinoSpittingBehavior();
final bloc = _MockChromeDinoCubit(); final bloc = _MockChromeDinoCubit();
@ -82,6 +83,7 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'calls onSpit', 'calls onSpit',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final ball = Ball(); final ball = Ball();
final behavior = ChromeDinoSpittingBehavior(); final behavior = ChromeDinoSpittingBehavior();
final bloc = _MockChromeDinoCubit(); final bloc = _MockChromeDinoCubit();

@ -29,8 +29,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'left loads correctly', 'left loads correctly',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final googleRollover = GoogleRollover(side: BoardSide.left); final googleRollover = GoogleRollover(side: BoardSide.left);
await game.ensureAdd(googleRollover); await game.ensureAdd(googleRollover);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final googleRollover = final googleRollover =
@ -42,8 +44,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'right loads correctly', 'right loads correctly',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final googleRollover = GoogleRollover(side: BoardSide.right); final googleRollover = GoogleRollover(side: BoardSide.right);
await game.ensureAdd(googleRollover); await game.ensureAdd(googleRollover);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final googleRollover = final googleRollover =
@ -56,12 +60,14 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'new children', 'new children',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final component = Component(); final component = Component();
final googleRollover = GoogleRollover( final googleRollover = GoogleRollover(
side: BoardSide.left, side: BoardSide.left,
children: [component], children: [component],
); );
await game.ensureAdd(googleRollover); await game.ensureAdd(googleRollover);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final googleRollover = final googleRollover =
@ -73,8 +79,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'a GoogleRolloverBallContactBehavior', 'a GoogleRolloverBallContactBehavior',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final googleRollover = GoogleRollover(side: BoardSide.left); final googleRollover = GoogleRollover(side: BoardSide.left);
await game.ensureAdd(googleRollover); await game.ensureAdd(googleRollover);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final googleRollover = final googleRollover =
@ -92,6 +100,7 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'pin stops animating after animation completes', 'pin stops animating after animation completes',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final googleRollover = GoogleRollover(side: BoardSide.left); final googleRollover = GoogleRollover(side: BoardSide.left);
await game.ensureAdd(googleRollover); await game.ensureAdd(googleRollover);
await game.ready(); await game.ready();

@ -26,8 +26,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'loads correctly', 'loads correctly',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final skillShot = SkillShot(); final skillShot = SkillShot();
await game.ensureAdd(skillShot); await game.ensureAdd(skillShot);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
expect(game.descendants().whereType<SkillShot>().length, equals(1)); expect(game.descendants().whereType<SkillShot>().length, equals(1));
@ -37,6 +39,7 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'closes bloc when removed', 'closes bloc when removed',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final bloc = _MockSkillShotCubit(); final bloc = _MockSkillShotCubit();
whenListen( whenListen(
bloc, bloc,
@ -61,11 +64,13 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'new children', 'new children',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final component = Component(); final component = Component();
final skillShot = SkillShot( final skillShot = SkillShot(
children: [component], children: [component],
); );
await game.ensureAdd(skillShot); await game.ensureAdd(skillShot);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final skillShot = game.descendants().whereType<SkillShot>().single; final skillShot = game.descendants().whereType<SkillShot>().single;
@ -76,8 +81,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'a SkillShotBallContactBehavior', 'a SkillShotBallContactBehavior',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final skillShot = SkillShot(); final skillShot = SkillShot();
await game.ensureAdd(skillShot); await game.ensureAdd(skillShot);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final skillShot = game.descendants().whereType<SkillShot>().single; final skillShot = game.descendants().whereType<SkillShot>().single;
@ -91,8 +98,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'a SkillShotBlinkingBehavior', 'a SkillShotBlinkingBehavior',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final skillShot = SkillShot(); final skillShot = SkillShot();
await game.ensureAdd(skillShot); await game.ensureAdd(skillShot);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final skillShot = game.descendants().whereType<SkillShot>().single; final skillShot = game.descendants().whereType<SkillShot>().single;
@ -107,9 +116,10 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
'pin stops animating after animation completes', 'pin stops animating after animation completes',
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final skillShot = SkillShot(); final skillShot = SkillShot();
await game.ready();
await game.ensureAdd(skillShot); await game.ensureAdd(skillShot);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final skillShot = game.descendants().whereType<SkillShot>().single; final skillShot = game.descendants().whereType<SkillShot>().single;

@ -101,6 +101,7 @@ void main() {
bloc: bloc, bloc: bloc,
); );
await opening.ensureAdd(behavior); await opening.ensureAdd(behavior);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final behavior = game final behavior = game
@ -121,6 +122,7 @@ void main() {
flameTester.testGameWidget( flameTester.testGameWidget(
"doesn't call 'onAscendingBallEntered' when a ball goes out the ramp", "doesn't call 'onAscendingBallEntered' when a ball goes out the ramp",
setUp: (game, _) async { setUp: (game, _) async {
await game.onLoad();
final behavior = RampBallAscendingContactBehavior(); final behavior = RampBallAscendingContactBehavior();
final bloc = _MockSpaceshipRampCubit(); final bloc = _MockSpaceshipRampCubit();
whenListen( whenListen(
@ -141,6 +143,7 @@ void main() {
bloc: bloc, bloc: bloc,
); );
await opening.ensureAdd(behavior); await opening.ensureAdd(behavior);
await game.ready();
}, },
verify: (game, _) async { verify: (game, _) async {
final behavior = game final behavior = game

Loading…
Cancel
Save