mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Add test for Image.network (#22256)
This commit is contained in:
parent
39f9855c1f
commit
66eaa06cd5
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user