Unverified Commit 2102bb03 authored by Dan Field's avatar Dan Field Committed by GitHub

Remove last FakeImage implementation (#66379)

parent 4881b4b0
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'dart:typed_data';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
...@@ -14,8 +13,8 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -14,8 +13,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
class FakeFrameInfo implements FrameInfo { class FakeFrameInfo implements FrameInfo {
FakeFrameInfo(int width, int height, this._duration) FakeFrameInfo(this._duration, this._image);
: _image = FakeImage(width, height);
final Duration _duration; final Duration _duration;
final Image _image; final Image _image;
...@@ -27,27 +26,6 @@ class FakeFrameInfo implements FrameInfo { ...@@ -27,27 +26,6 @@ class FakeFrameInfo implements FrameInfo {
Image get image => _image; Image get image => _image;
} }
class FakeImage implements Image {
FakeImage(this._width, this._height);
final int _width;
final int _height;
@override
int get width => _width;
@override
int get height => _height;
@override
void dispose() { }
@override
Future<ByteData> toByteData({ ImageByteFormat format = ImageByteFormat.rawRgba }) async {
throw UnsupportedError('Cannot encode test image');
}
}
class MockCodec implements Codec { class MockCodec implements Codec {
@override @override
...@@ -92,6 +70,13 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter { ...@@ -92,6 +70,13 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
} }
void main() { void main() {
Image image20x10;
Image image200x100;
setUpAll(() async {
image20x10 = await createTestImage(width: 20, height: 10);
image200x100 = await createTestImage(width: 200, height: 100);
});
testWidgets('Codec future fails', (WidgetTester tester) async { testWidgets('Codec future fails', (WidgetTester tester) async {
final Completer<Codec> completer = Completer<Codec>(); final Completer<Codec> completer = Completer<Codec>();
MultiFrameImageStreamCompleter( MultiFrameImageStreamCompleter(
...@@ -310,7 +295,7 @@ void main() { ...@@ -310,7 +295,7 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
mockCodec.completeNextFrame(frame); mockCodec.completeNextFrame(frame);
await tester.idle(); await tester.idle();
...@@ -336,7 +321,7 @@ void main() { ...@@ -336,7 +321,7 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); await tester.idle();
// We are waiting for the next animation tick, so at this point no frames // We are waiting for the next animation tick, so at this point no frames
...@@ -346,7 +331,7 @@ void main() { ...@@ -346,7 +331,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(emittedImages, equals(<ImageInfo>[ImageInfo(image: frame1.image)])); expect(emittedImages, equals(<ImageInfo>[ImageInfo(image: frame1.image)]));
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame2); mockCodec.completeNextFrame(frame2);
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
...@@ -384,8 +369,8 @@ void main() { ...@@ -384,8 +369,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -427,8 +412,8 @@ void main() { ...@@ -427,8 +412,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -465,8 +450,8 @@ void main() { ...@@ -465,8 +450,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -510,8 +495,8 @@ void main() { ...@@ -510,8 +495,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -549,8 +534,8 @@ void main() { ...@@ -549,8 +534,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -582,8 +567,8 @@ void main() { ...@@ -582,8 +567,8 @@ void main() {
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); final FrameInfo frame2 = FakeFrameInfo(const Duration(milliseconds: 400), image200x100);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
...@@ -658,7 +643,7 @@ void main() { ...@@ -658,7 +643,7 @@ void main() {
imageStream.addListener(ImageStreamListener(listener)); imageStream.addListener(ImageStreamListener(listener));
final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); final FrameInfo frame1 = FakeFrameInfo(const Duration(milliseconds: 200), image20x10);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); // let nextFrameFuture complete await tester.idle(); // let nextFrameFuture complete
......
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