Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_markdown] add AssetManifest.bin to TestAssetBundle #3422

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/flutter_markdown/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0
standard_message_codec: ^0.0.1+3
10 changes: 8 additions & 2 deletions packages/flutter_markdown/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,20 @@ Widget boilerplate(Widget child) {
}

class TestAssetBundle extends CachingAssetBundle {
static const String manifest = r'{"assets/logo.png":["assets/logo.png"]}';

@override
Future<ByteData> load(String key) async {
if (key == 'AssetManifest.json') {
const String manifest = r'{"assets/logo.png":["assets/logo.png"]}';
final ByteData asset =
ByteData.view(utf8.encoder.convert(manifest).buffer);
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') {
// The root directory tests are run from is different for 'flutter test'
// verses 'flutter test test/*_test.dart'. Adjust the root directory
Expand Down