Skip to content
Merged
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
Prev Previous commit
Add TestAssetBundle override
  • Loading branch information
arnemolland committed Feb 28, 2023
commit 0b1a61147dbfc05d43ee7ee4d23c84e55a258dc9
15 changes: 15 additions & 0 deletions flutter/test/sentry_asset_bundle_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: invalid_use_of_internal_member
// The lint above is okay, because we're using another Sentry package
import 'dart:async';
import 'dart:convert';
// backcompatibility for Flutter < 3.3
// ignore: unnecessary_import
Expand Down Expand Up @@ -545,6 +546,20 @@ class TestAssetBundle extends CachingAssetBundle {
bool throwException = false;
String? evictKey;

@override
// ignore: override_on_non_overriding_member
Future<T> loadStructuredBinaryData<T>(
String key, FutureOr<T> Function(ByteData data) parser) async {
if (throwException) {
throw Exception('exception thrown for testing purposes');
}
if (key == _testFileName) {
return parser(ByteData.view(
Uint8List.fromList(utf8.encode('Hello World!')).buffer));
}
return parser(ByteData(0));
}

@override
Future<ByteData> load(String key) async {
if (throwException) {
Expand Down