mirror of
https://github.com/flutter/flutter
synced 2024-10-12 19:23:02 +00:00
[web] delete unhelpful image loading e2e test (#122059)
[web] delete unhelpful image loading e2e test
This commit is contained in:
parent
961df985fa
commit
91dea4d1a6
|
@ -1162,11 +1162,6 @@ Future<void> _runWebLongRunningTests() async {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
// This test specifically tests how images are loaded in HTML mode, so we don't run it in CanvasKit mode.
|
|
||||||
() => _runWebE2eTest('image_loading_integration', buildMode: 'debug', renderer: 'html'),
|
|
||||||
() => _runWebE2eTest('image_loading_integration', buildMode: 'profile', renderer: 'html'),
|
|
||||||
() => _runWebE2eTest('image_loading_integration', buildMode: 'release', renderer: 'html'),
|
|
||||||
|
|
||||||
// This test doesn't do anything interesting w.r.t. rendering, so we don't run the full build mode x renderer matrix.
|
// This test doesn't do anything interesting w.r.t. rendering, so we don't run the full build mode x renderer matrix.
|
||||||
() => _runWebE2eTest('platform_messages_integration', buildMode: 'debug', renderer: 'canvaskit'),
|
() => _runWebE2eTest('platform_messages_integration', buildMode: 'debug', renderer: 'canvaskit'),
|
||||||
() => _runWebE2eTest('platform_messages_integration', buildMode: 'profile', renderer: 'html'),
|
() => _runWebE2eTest('platform_messages_integration', buildMode: 'profile', renderer: 'html'),
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
// Copyright 2014 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:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
final Completer<void> _assetImageCompleter = Completer<void>();
|
|
||||||
final Completer<void> _networkImageCompleter = Completer<void>();
|
|
||||||
|
|
||||||
/// Notifies that Image.asset used in the test app loaded the image.
|
|
||||||
@visibleForTesting
|
|
||||||
Future<void> get whenAssetImageLoads => _assetImageCompleter.future;
|
|
||||||
|
|
||||||
/// Notifies that Image.network used in the test app loaded the image.
|
|
||||||
@visibleForTesting
|
|
||||||
Future<void> get whenNetworkImageLoads => _networkImageCompleter.future;
|
|
||||||
|
|
||||||
Future<void> main() async {
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
const MethodChannel channel =
|
|
||||||
OptionalMethodChannel('flutter/web_test_e2e', JSONMethodCodec());
|
|
||||||
|
|
||||||
// Artificially override the device pixel ratio to force the framework to pick the 1.5x asset variants.
|
|
||||||
await channel.invokeMethod<void>('setDevicePixelRatio', '1.5');
|
|
||||||
runApp(const MyApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
|
||||||
const MyApp({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
MyAppState createState() => MyAppState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyAppState extends State<MyApp> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
key: const Key('mainapp'),
|
|
||||||
title: 'Integration Test App',
|
|
||||||
home: Column(children: <Widget>[
|
|
||||||
const Text('Asset image:'),
|
|
||||||
RepaintBoundary(child: Image.asset(
|
|
||||||
'assets/icons/material/material.png',
|
|
||||||
package: 'flutter_gallery_assets',
|
|
||||||
frameBuilder: (
|
|
||||||
BuildContext context,
|
|
||||||
Widget child,
|
|
||||||
int? frame,
|
|
||||||
bool wasSynchronouslyLoaded,
|
|
||||||
) {
|
|
||||||
if (frame != null) {
|
|
||||||
_assetImageCompleter.complete();
|
|
||||||
}
|
|
||||||
return child;
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
const Text('Network image:'),
|
|
||||||
RepaintBoundary(child: Image.network(
|
|
||||||
'assets/packages/flutter_gallery_assets/assets/icons/material/material.png',
|
|
||||||
frameBuilder: (
|
|
||||||
BuildContext context,
|
|
||||||
Widget child,
|
|
||||||
int? frame,
|
|
||||||
bool wasSynchronouslyLoaded,
|
|
||||||
) {
|
|
||||||
if (frame != null) {
|
|
||||||
_networkImageCompleter.complete();
|
|
||||||
}
|
|
||||||
return child;
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
// Copyright 2014 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:integration_test/integration_test.dart';
|
|
||||||
import 'package:web_e2e_tests/common.dart';
|
|
||||||
import 'package:web_e2e_tests/image_loading_main.dart' as app;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
|
|
||||||
testWidgets('Image loads asset variant based on device pixel ratio',
|
|
||||||
(WidgetTester tester) async {
|
|
||||||
await app.main();
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
// `pumpAndSettle` only waits until no more frames are scheduled, but the
|
|
||||||
// test must wait for the image network requests to finish.
|
|
||||||
await app.whenAssetImageLoads;
|
|
||||||
await app.whenNetworkImageLoads;
|
|
||||||
|
|
||||||
// At the time the network requests are finished the engine may not have
|
|
||||||
// updated the DOM yet. Delay checking the DOM until the next event, which
|
|
||||||
// will guarantee that the current frame is done rendering.
|
|
||||||
await Future<void>.delayed(Duration.zero);
|
|
||||||
|
|
||||||
final List<html.ImageElement> imageElements = findElements('img').cast<html.ImageElement>();
|
|
||||||
expect(imageElements.length, 2);
|
|
||||||
expect(imageElements[0].naturalWidth, 1.5 * 64);
|
|
||||||
expect(imageElements[0].naturalHeight, 1.5 * 64);
|
|
||||||
expect(imageElements[0].width, 64);
|
|
||||||
expect(imageElements[0].height, 64);
|
|
||||||
expect(imageElements[1].width, isNot(0));
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Copyright 2014 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 'package:integration_test/integration_test_driver.dart' as test;
|
|
||||||
|
|
||||||
Future<void> main() async => test.integrationDriver();
|
|
Loading…
Reference in a new issue