image_package_asset_test.dart 1.42 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('AssetImage from package', () {
10
    const AssetImage image = AssetImage(
11 12 13 14 15 16 17
      'assets/image.png',
      package: 'test_package',
    );
    expect(image.keyName, 'packages/test_package/assets/image.png');
  });

  test('ExactAssetImage from package', () {
18
    const ExactAssetImage image = ExactAssetImage(
19 20 21 22 23 24 25 26
      'assets/image.png',
      scale: 1.5,
      package: 'test_package',
    );
    expect(image.keyName, 'packages/test_package/assets/image.png');
  });

  test('Image.asset from package', () {
27
    final Image imageWidget = Image.asset(
28 29 30 31
      'assets/image.png',
      package: 'test_package',
    );
    assert(imageWidget.image is AssetImage);
32
    final AssetImage assetImage = imageWidget.image as AssetImage;
33 34 35 36
    expect(assetImage.keyName, 'packages/test_package/assets/image.png');
  });

  test('Image.asset from package', () {
37
    final Image imageWidget = Image.asset(
38 39 40 41 42
      'assets/image.png',
      scale: 1.5,
      package: 'test_package',
    );
    assert(imageWidget.image is ExactAssetImage);
43
    final ExactAssetImage assetImage = imageWidget.image as ExactAssetImage;
Josh Soref's avatar
Josh Soref committed
44
    expect(assetImage.keyName, 'packages/test_package/assets/image.png');
45 46
  });
}