mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
Added size parameter to testGolden() function, allowing us to reduce the size of the game canvas used. The default size is 2400x1800, as given by the Flutter framework, seems like too much for most tests.
61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame_test/flame_test.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('Golden tests', () {
|
|
final tester = FlameTester(FlameGame.new);
|
|
|
|
tester.testGameWidget(
|
|
'renders correctly',
|
|
setUp: (game, _) async {
|
|
await game.ensureAdd(
|
|
CircleComponent(
|
|
radius: 10,
|
|
position: Vector2.all(100),
|
|
paint: Paint()..color = Colors.white,
|
|
),
|
|
);
|
|
},
|
|
verify: (game, tester) async {
|
|
await expectLater(
|
|
find.byGame<FlameGame>(),
|
|
matchesGoldenFile('golden_test.png'),
|
|
);
|
|
},
|
|
);
|
|
|
|
testGolden(
|
|
'Same test but with testGolden',
|
|
(game) async {
|
|
final paint = Paint()..color = Colors.white;
|
|
game.add(
|
|
CircleComponent(radius: 10, position: Vector2.all(100), paint: paint),
|
|
);
|
|
},
|
|
goldenFile: 'golden_test.png',
|
|
);
|
|
|
|
testGolden(
|
|
'Same test, but with smaller size',
|
|
(game) async {
|
|
final paint = Paint()..color = Colors.white;
|
|
game.add(
|
|
CircleComponent(radius: 10, position: Vector2.all(100), paint: paint),
|
|
);
|
|
},
|
|
size: Vector2(200, 200),
|
|
goldenFile: 'golden_test_small.png',
|
|
);
|
|
|
|
testGolden(
|
|
'skipped test',
|
|
(game) async {},
|
|
goldenFile: 'golden_test.png',
|
|
skip: true,
|
|
);
|
|
});
|
|
}
|