diff --git a/kraken/lib/src/launcher/bundle.dart b/kraken/lib/src/launcher/bundle.dart index 53775d16c9..128b115d4b 100644 --- a/kraken/lib/src/launcher/bundle.dart +++ b/kraken/lib/src/launcher/bundle.dart @@ -201,7 +201,7 @@ class NetworkAssetBundle extends AssetBundle { _additionalHttpHeaders = additionalHttpHeaders, httpClient = HttpClient(); - int? contextId; + final int? contextId; final Uri _baseUrl; final HttpClient httpClient; final Map? _additionalHttpHeaders; diff --git a/kraken/test/kraken_test.dart b/kraken/test/kraken_test.dart index edffcde954..5f9157d8cd 100644 --- a/kraken/test/kraken_test.dart +++ b/kraken/test/kraken_test.dart @@ -21,6 +21,8 @@ import 'src/css/values.dart' as css_values; import 'src/gesture/scroll_physics.dart' as scroll_physics; +import 'src/launcher/bundle.dart' as bundle; + // The main entry for kraken unit test. // Setup all common logic. void main() { @@ -64,6 +66,10 @@ void main() { scroll_physics.main(); }); + group('launcher', () { + bundle.main(); + }); + tearDownAll(() { if (tempDirectory.existsSync()) { tempDirectory.deleteSync(recursive: true); diff --git a/kraken/test/src/launcher/bundle.dart b/kraken/test/src/launcher/bundle.dart new file mode 100644 index 0000000000..dbef939925 --- /dev/null +++ b/kraken/test/src/launcher/bundle.dart @@ -0,0 +1,23 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:kraken/launcher.dart'; +import 'package:test/test.dart'; + +import '../../local_http_server.dart'; + +void main() { + var server = LocalHttpServer.getInstance(); + + group('Bundle', () { + test('NetworkAssetsBundle basic', () async { + Uri uri = server.getUri('js_over_128k'); + // Using contextId to active cache. + var bundle = NetworkAssetBundle(uri, contextId: 1); + ByteData data = await bundle.load(uri.toString()); + var code = utf8.decode(data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes)); + + expect(code.length > 128 * 1024, true); + }); + }); +}