mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[flutter_markdown] add AssetManifest.bin to TestAssetBundle (#3422)
[flutter_markdown] add AssetManifest.bin to TestAssetBundle
This commit is contained in:
@ -21,3 +21,4 @@ dev_dependencies:
|
|||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
mockito: ^5.0.0
|
mockito: ^5.0.0
|
||||||
|
standard_message_codec: ^0.0.1+3
|
||||||
|
@ -179,14 +179,17 @@ Widget boilerplate(Widget child) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TestAssetBundle extends CachingAssetBundle {
|
class TestAssetBundle extends CachingAssetBundle {
|
||||||
static const String manifest = r'{"assets/logo.png":["assets/logo.png"]}';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ByteData> load(String key) async {
|
Future<ByteData> load(String key) async {
|
||||||
if (key == 'AssetManifest.json') {
|
if (key == 'AssetManifest.json') {
|
||||||
|
const String manifest = r'{"assets/logo.png":["assets/logo.png"]}';
|
||||||
final ByteData asset =
|
final ByteData asset =
|
||||||
ByteData.view(utf8.encoder.convert(manifest).buffer);
|
ByteData.view(utf8.encoder.convert(manifest).buffer);
|
||||||
return Future<ByteData>.value(asset);
|
return Future<ByteData>.value(asset);
|
||||||
|
} else if (key == 'AssetManifest.bin') {
|
||||||
|
final ByteData manifest = const StandardMessageCodec().encodeMessage(
|
||||||
|
<String, List<Object>>{'assets/logo.png': <Object>[]})!;
|
||||||
|
return Future<ByteData>.value(manifest);
|
||||||
} else if (key == 'assets/logo.png') {
|
} else if (key == 'assets/logo.png') {
|
||||||
// The root directory tests are run from is different for 'flutter test'
|
// The root directory tests are run from is different for 'flutter test'
|
||||||
// verses 'flutter test test/*_test.dart'. Adjust the root directory
|
// verses 'flutter test test/*_test.dart'. Adjust the root directory
|
||||||
|
Reference in New Issue
Block a user