blob: 082e8ebbb8155953922ab36ed9dbf8af33b1a1de [file] [log] [blame]
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';
class TestImageProvider extends ImageProvider<TestImageProvider> {
final ui.Image testImage;
final Completer<ImageInfo> _completer = Completer<ImageInfo>.sync();
ImageConfiguration configuration;
int loadCallCount = 0;
Future<TestImageProvider> obtainKey(ImageConfiguration configuration) {
return SynchronousFuture<TestImageProvider>(this);
void resolveStreamForKey(ImageConfiguration config, ImageStream stream, TestImageProvider key, ImageErrorListener handleError) {
configuration = config;
super.resolveStreamForKey(config, stream, key, handleError);
ImageStreamCompleter load(TestImageProvider key, DecoderCallback decode) {
loadCallCount += 1;
return OneFrameImageStreamCompleter(_completer.future);
ImageInfo complete() {
final ImageInfo imageInfo = ImageInfo(image: testImage);
return imageInfo;
String toString() => '${describeIdentity(this)}()';
class FakeImageConfiguration implements ImageConfiguration {
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);