chore: update BonusAnimation

pull/191/head
arturplaczek 3 years ago
parent 91bef71ada
commit cb354a67fe

@ -23,6 +23,24 @@ class BonusAnimation extends StatelessWidget {
key: key,
);
BonusAnimation.sparkyTurboCharge({
Key? key,
VoidCallback? onCompleted,
}) : this._(
Assets.images.bonusAnimation.sparkyTurboCharge.keyName,
onCompleted: onCompleted,
key: key,
);
BonusAnimation.dino({
Key? key,
VoidCallback? onCompleted,
}) : this._(
Assets.images.bonusAnimation.dino.keyName,
onCompleted: onCompleted,
key: key,
);
final String image;
final VoidCallback? onCompleted;
@ -34,7 +52,7 @@ class BonusAnimation extends StatelessWidget {
// TODO(arturplaczek): Load assets in parent widget, remove future builder
// and user image from cache.
return FutureBuilder<Image>(
future: Flame.images.load(Assets.images.bonusAnimation.dashNest.keyName),
future: Flame.images.load(image),
builder: (BuildContext context, AsyncSnapshot<Image> snapshot) {
if (snapshot.hasData) {
final spriteSheet = SpriteSheet.fromColumnsAndRows(

@ -27,7 +27,8 @@ void main() {
Flame.images = images;
});
testWidgets('renders SpriteAnimationWidget', (tester) async {
group('renders SpriteAnimationWidget for', () {
testWidgets('dashNest', (tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(
MaterialApp(
@ -42,6 +43,37 @@ void main() {
});
});
testWidgets('dino', (tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BonusAnimation.dino(),
),
),
);
await tester.pump();
expect(find.byType(SpriteAnimationWidget), findsOneWidget);
});
});
testWidgets('sparkyTurboCharge', (tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BonusAnimation.sparkyTurboCharge(),
),
),
);
await tester.pump();
expect(find.byType(SpriteAnimationWidget), findsOneWidget);
});
});
});
testWidgets('called onCompleted callback at the end of animation ',
(tester) async {
final completer = Completer<void>();

Loading…
Cancel
Save