Skip to content

Commit

Permalink
Add test for mixed color/non-color assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
luanpotter committed Oct 13, 2024
1 parent 27257a5 commit 5de93db
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/flame/test/_resources/boom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions packages/flame/test/sprite_batch_test.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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',
);
});
}

0 comments on commit 5de93db

Please sign in to comment.