binding_test.dart 1.24 KB
Newer Older
1 2 3 4
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8 9
import 'dart:typed_data' show Uint8List;

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/painting.dart';
10 11 12

import 'image_data.dart';
import 'painting_utils.dart';
13 14 15 16 17 18 19

void main() {
  final PaintingBindingSpy binding = PaintingBindingSpy();

  test('decodedCacheRatio', () async {
    // final PaintingBinding binding = PaintingBinding.instance;
    // Has default value.
20
    expect(binding.decodedCacheRatioCap, isNot(null)); // ignore: deprecated_member_use_from_same_package
21 22

    // Can be set.
23 24
    binding.decodedCacheRatioCap = 1.0; // ignore: deprecated_member_use_from_same_package
    expect(binding.decodedCacheRatioCap, 1.0); // ignore: deprecated_member_use_from_same_package
25 26 27 28 29 30 31 32 33 34 35
  });

  test('instantiateImageCodec used for loading images', () async {
    expect(binding.instantiateImageCodecCalledCount, 0);

    final Uint8List bytes = Uint8List.fromList(kTransparentImage);
    final MemoryImage memoryImage = MemoryImage(bytes);
    memoryImage.load(memoryImage);
    expect(binding.instantiateImageCodecCalledCount, 1);
  });
}