|
|
|
@ -8,17 +8,23 @@ import 'package:mocktail/mocktail.dart';
|
|
|
|
|
|
|
|
|
|
class _MockImages extends Mock implements Images {}
|
|
|
|
|
|
|
|
|
|
/// {@template mock_flame_images}
|
|
|
|
|
/// Mock for flame images instance.
|
|
|
|
|
///
|
|
|
|
|
/// Using real images blocks the tests, for this reason we need fake image
|
|
|
|
|
/// everywhere we use [Images.fromCache] or [Images.load].
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
// TODO(arturplaczek): need to find for a better solution for loading image
|
|
|
|
|
// or use original images.
|
|
|
|
|
Future<void> mockFlameImages() async {
|
|
|
|
|
// TODO(arturplaczek): need to find for a better solution for loading image
|
|
|
|
|
// or use original images.
|
|
|
|
|
final image = await decodeImageFromList(Uint8List.fromList(fakeImage));
|
|
|
|
|
final image = await decodeImageFromList(Uint8List.fromList(_fakeImage));
|
|
|
|
|
final images = _MockImages();
|
|
|
|
|
when(() => images.fromCache(any())).thenReturn(image);
|
|
|
|
|
when(() => images.load(any())).thenAnswer((_) => Future.value(image));
|
|
|
|
|
Flame.images = images;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fakeImage = <int>[
|
|
|
|
|
const _fakeImage = <int>[
|
|
|
|
|
0x89,
|
|
|
|
|
0x50,
|
|
|
|
|
0x4E,
|
|
|
|
|