Unverified Commit 735352a8 authored by Dan Field's avatar Dan Field Committed by GitHub

Deflake ImageProvider.evict test (#35999)

parent 7ea7f1c6
......@@ -44,11 +44,19 @@ void main() {
final ImageCache otherCache = ImageCache();
final Uint8List bytes = Uint8List.fromList(kTransparentImage);
final MemoryImage imageProvider = MemoryImage(bytes);
otherCache.putIfAbsent(imageProvider, () => imageProvider.load(imageProvider));
final ImageStreamCompleter cacheStream = otherCache.putIfAbsent(
imageProvider, () => imageProvider.load(imageProvider),
);
final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty);
final Completer<void> completer = Completer<void>();
stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) => completer.complete()));
await completer.future;
final Completer<void> cacheCompleter = Completer<void>();
stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
completer.complete();
}));
cacheStream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
cacheCompleter.complete();
}));
await Future.wait(<Future<void>>[completer.future, cacheCompleter.future]);
expect(otherCache.currentSize, 1);
expect(imageCache.currentSize, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment