image_loading_integration.dart 975 字节
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2013 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.

import 'dart:html' as html;
import 'package:flutter_test/flutter_test.dart';
import 'package:regular_integration_tests/image_loading_main.dart' as app;

9
import 'package:integration_test/integration_test.dart';
10 11

void main() {
12
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
13 14 15 16 17

  testWidgets('Image loads asset variant based on device pixel ratio',
          (WidgetTester tester) async {
    app.main();
    await tester.pumpAndSettle();
F
Ferhat 已提交
18 19 20 21 22 23 24
    final List<html.ImageElement> imageElements = html.querySelectorAll('img');
    expect(imageElements.length, 2);
    expect(imageElements[0].naturalWidth, 1.5 * 100);
    expect(imageElements[0].naturalHeight, 1.5 * 100);
    expect(imageElements[0].width, 100);
    expect(imageElements[0].height, 100);
    expect(imageElements[1].width, isNot(0));
25 26
  });
}