diff --git a/packages/flame/test/_goldens/sprite_batch_test.png b/packages/flame/test/_goldens/sprite_batch_test.png new file mode 100644 index 00000000000..6c1bfcf6020 Binary files /dev/null and b/packages/flame/test/_goldens/sprite_batch_test.png differ diff --git a/packages/flame/test/_resources/boom.png b/packages/flame/test/_resources/boom.png new file mode 100644 index 00000000000..2127917d860 Binary files /dev/null and b/packages/flame/test/_resources/boom.png differ diff --git a/packages/flame/test/sprite_batch_test.dart b/packages/flame/test/sprite_batch_test.dart index 8ccc4694607..20161021ed4 100644 --- a/packages/flame/test/sprite_batch_test.dart +++ b/packages/flame/test/sprite_batch_test.dart @@ -1,10 +1,14 @@ import 'dart:ui'; +import 'package:flame/components.dart'; import 'package:flame/sprite.dart'; +import 'package:flame_test/flame_test.dart'; import 'package:flutter/material.dart' hide Image; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; +import '_resources/load_image.dart'; + class _MockImage extends Mock implements Image {} void main() { @@ -56,5 +60,34 @@ void main() { .having((t) => t.ty, 'ty', 1), ); }); + + testGolden( + 'can render a batch', + (game) async { + final spriteSheet = await loadImage('boom.png'); + final spriteBatch = SpriteBatch(spriteSheet); + + const source = Rect.fromLTWH(128 * 4.0, 128 * 4.0, 64, 128); + + spriteBatch.add( + source: source, + color: Colors.redAccent, + ); + + spriteBatch.add( + source: source, + offset: Vector2(100, 0), + ); + + game.add( + SpriteBatchComponent( + spriteBatch: spriteBatch, + blendMode: BlendMode.srcOver, + ), + ); + }, + size: Vector2(300, 200), + goldenFile: '_goldens/sprite_batch_test.png', + ); }); }