From 4530ad8aa5af8f196bd9ab06c3bce663cbf9ebca Mon Sep 17 00:00:00 2001 From: Allison Ryan Date: Wed, 27 Apr 2022 21:10:03 -0500 Subject: [PATCH] refactor: fix PR nits --- .../lib/src/components/chrome_dino.dart | 12 +++--------- .../test/src/components/chrome_dino_test.dart | 14 ++++---------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/packages/pinball_components/lib/src/components/chrome_dino.dart b/packages/pinball_components/lib/src/components/chrome_dino.dart index 9971a00d..cff6a3f3 100644 --- a/packages/pinball_components/lib/src/components/chrome_dino.dart +++ b/packages/pinball_components/lib/src/components/chrome_dino.dart @@ -44,10 +44,9 @@ class ChromeDino extends BodyComponent with InitialPosition { Future onLoad() async { await super.onLoad(); final joint = await _anchorToJoint(); - const halfAnimationPeriod = (_framesInAnimation / 2) * _animationFPS; await add( TimerComponent( - period: halfAnimationPeriod, + period: (_framesInAnimation / 2) * _animationFPS, onTick: joint._swivel, repeat: true, ), @@ -86,11 +85,7 @@ class ChromeDino extends BodyComponent with InitialPosition { } } -/// {@template chrome_dino_anchor} -/// [JointAnchor] positioned at the back of the [ChromeDino]. -/// {@endtemplate} class _ChromeDinoAnchor extends JointAnchor { - /// {@macro chrome_dino_anchor} _ChromeDinoAnchor(); // TODO(allisonryan0002): if these aren't moved when fixing the rendering, see @@ -120,9 +115,8 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef { chromeDino.body.position + anchor.body.position, ); enableLimit = true; - const angle = _ChromeDinoJoint._halfSweepingAngle; - lowerAngle = -angle; - upperAngle = angle; + lowerAngle = -_ChromeDinoJoint._halfSweepingAngle; + upperAngle = _ChromeDinoJoint._halfSweepingAngle; enableMotor = true; maxMotorTorque = chromeDino.body.mass * 255; diff --git a/packages/pinball_components/test/src/components/chrome_dino_test.dart b/packages/pinball_components/test/src/components/chrome_dino_test.dart index 16e02647..f97270b9 100644 --- a/packages/pinball_components/test/src/components/chrome_dino_test.dart +++ b/packages/pinball_components/test/src/components/chrome_dino_test.dart @@ -65,14 +65,12 @@ void main() { ); group('swivels', () { - flameTester.testGameWidget( + flameTester.test( 'up', - setUp: (game, tester) async { - await game.images.loadAll(assets); + (game) async { final chromeDino = ChromeDino(); await game.ensureAdd(chromeDino); game.camera.followVector2(Vector2.zero()); - await tester.pump(); final sweepAnimationDuration = game .descendants() @@ -82,20 +80,17 @@ void main() { .totalDuration() / 2; game.update(sweepAnimationDuration * 1.5); - await tester.pump(); expect(chromeDino.body.angularVelocity, isPositive); }, ); - flameTester.testGameWidget( + flameTester.test( 'down', - setUp: (game, tester) async { - await game.images.loadAll(assets); + (game) async { final chromeDino = ChromeDino(); await game.ensureAdd(chromeDino); game.camera.followVector2(Vector2.zero()); - await tester.pump(); final sweepAnimationDuration = game .descendants() @@ -105,7 +100,6 @@ void main() { .totalDuration() / 2; game.update(sweepAnimationDuration * 0.5); - await tester.pump(); expect(chromeDino.body.angularVelocity, isNegative); },