Skip to content

Commit

Permalink
More preparation for HttpClientResponse implements Uint8List (flutter…
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolkert authored and johnsonmh committed Jul 30, 2019
1 parent 0c5ba88 commit 34eb5f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
23 changes: 12 additions & 11 deletions packages/flutter/test/foundation/consolidate_response_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/foundation.dart';
import 'package:mockito/mockito.dart';
Expand All @@ -14,8 +15,8 @@ import '../flutter_test_alternative.dart';

void main() {
group(consolidateHttpClientResponseBytes, () {
final List<int> chunkOne = <int>[0, 1, 2, 3, 4, 5];
final List<int> chunkTwo = <int>[6, 7, 8, 9, 10];
final Uint8List chunkOne = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]);
final Uint8List chunkTwo = Uint8List.fromList(<int>[6, 7, 8, 9, 10]);
MockHttpClientResponse response;

setUp(() {
Expand All @@ -32,8 +33,8 @@ void main() {
final void Function() onDone = invocation.namedArguments[#onDone];
final bool cancelOnError = invocation.namedArguments[#cancelOnError];

return Stream<List<int>>.fromIterable(
<List<int>>[chunkOne, chunkTwo]).listen(
return Stream<Uint8List>.fromIterable(
<Uint8List>[chunkOne, chunkTwo]).listen(
onData,
onDone: onDone,
onError: onError,
Expand Down Expand Up @@ -98,8 +99,8 @@ void main() {
final void Function() onDone = invocation.namedArguments[#onDone];
final bool cancelOnError = invocation.namedArguments[#cancelOnError];

return Stream<List<int>>.fromFuture(
Future<List<int>>.error(Exception('Test Error')))
return Stream<Uint8List>.fromFuture(
Future<Uint8List>.error(Exception('Test Error')))
.listen(
onData,
onDone: onDone,
Expand All @@ -126,9 +127,9 @@ void main() {
});

group('when gzipped', () {
final List<int> gzipped = gzip.encode(chunkOne.followedBy(chunkTwo).toList());
final List<int> gzippedChunkOne = gzipped.sublist(0, gzipped.length ~/ 2);
final List<int> gzippedChunkTwo = gzipped.sublist(gzipped.length ~/ 2);
final Uint8List gzipped = gzip.encode(chunkOne.followedBy(chunkTwo).toList());
final Uint8List gzippedChunkOne = gzipped.sublist(0, gzipped.length ~/ 2);
final Uint8List gzippedChunkTwo = gzipped.sublist(gzipped.length ~/ 2);

setUp(() {
when(response.compressionState).thenReturn(HttpClientResponseCompressionState.compressed);
Expand All @@ -143,8 +144,8 @@ void main() {
final void Function() onDone = invocation.namedArguments[#onDone];
final bool cancelOnError = invocation.namedArguments[#cancelOnError];

return Stream<List<int>>.fromIterable(
<List<int>>[gzippedChunkOne, gzippedChunkTwo]).listen(
return Stream<Uint8List>.fromIterable(
<Uint8List>[gzippedChunkOne, gzippedChunkTwo]).listen(
onData,
onDone: onDone,
onError: onError,
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/test/painting/image_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ void main() {
});

test('Notifies listeners of chunk events', () async {
final List<List<int>> chunks = <List<int>>[];
final List<Uint8List> chunks = <Uint8List>[];
const int chunkSize = 8;
for (int offset = 0; offset < kTransparentImage.length; offset += chunkSize) {
chunks.add(kTransparentImage.skip(offset).take(chunkSize).toList());
chunks.add(Uint8List.fromList(kTransparentImage.skip(offset).take(chunkSize).toList()));
}
final Completer<void> imageAvailable = Completer<void>();
final MockHttpClientRequest request = MockHttpClientRequest();
Expand All @@ -225,7 +225,7 @@ void main() {
final void Function() onDone = invocation.namedArguments[#onDone];
final bool cancelOnError = invocation.namedArguments[#cancelOnError];

return Stream<List<int>>.fromIterable(chunks).listen(
return Stream<Uint8List>.fromIterable(chunks).listen(
onData,
onDone: onDone,
onError: onError,
Expand Down

0 comments on commit 34eb5f9

Please sign in to comment.