未验证 提交 66eaa06c 编写于 作者: F Ferhat 提交者: GitHub

[web] Add test for Image.network (#22256)

上级 39f9855c
......@@ -6,8 +6,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
const MethodChannel channel =
OptionalMethodChannel('flutter/web_test_e2e', JSONMethodCodec());
OptionalMethodChannel('flutter/web_test_e2e', JSONMethodCodec());
await channel.invokeMethod<void>(
'setDevicePixelRatio',
'1.5',
......@@ -26,7 +27,10 @@ class MyAppState extends State<MyApp> {
return MaterialApp(
key: const Key('mainapp'),
title: 'Integration Test App',
home: Image.asset('assets/images/sample_image1.png')
home: Column(children: <Widget>[
Image.asset('assets/images/sample_image1.png'),
Image.network('assets/images/sample_image1.png'),
])
);
}
}
......@@ -15,10 +15,12 @@ void main() {
(WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
final html.ImageElement imageElement = html.querySelector('img') as html.ImageElement;
expect(imageElement.naturalWidth, 1.5 * 100);
expect(imageElement.naturalHeight, 1.5 * 100);
expect(imageElement.width, 100);
expect(imageElement.height, 100);
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));
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册