flutter/packages/flutter_tools/test/web.shard/hot_reload_web_test.dart
David Iglesias 1e1b5271f4
[tool] Removes deprecated --web-renderer parameter. (#159314)
Removes the `--web-renderer` option.

Flutter tool users won't be able to select their web renderer.

In order to not drop test coverage, tests are still run with the HTML
Renderer, until its code is fully removed from the engine.

Part of https://github.com/flutter/flutter/issues/145954

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2024-12-02 18:33:02 +00:00

95 lines
3.7 KiB
Dart

// 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.
@Tags(<String>['flutter-test-driver'])
library;
import 'dart:async';
import 'package:file/file.dart';
import 'package:flutter_tools/src/web/compile.dart';
import '../integration.shard/test_data/hot_reload_project.dart';
import '../integration.shard/test_driver.dart';
import '../integration.shard/test_utils.dart';
import '../src/common.dart';
import 'test_data/hot_reload_index_html_samples.dart';
void main() async {
await _testProject(HotReloadProject()); // default
await _testProject(HotReloadProject(constApp: true), name: 'Default) (with `const MyApp()`)'); // runApp(const MyApp());
await _testProject(HotReloadProject(indexHtml: indexHtmlFlutterJsCallback), name: 'flutter.js (callback)');
await _testProject(HotReloadProject(indexHtml: indexHtmlFlutterJsPromisesFull), name: 'flutter.js (promises)');
await _testProject(HotReloadProject(indexHtml: indexHtmlFlutterJsPromisesShort), name: 'flutter.js (promises, short)');
await _testProject(HotReloadProject(indexHtml: indexHtmlFlutterJsLoad), name: 'flutter.js (load)');
await _testProject(HotReloadProject(indexHtml: indexHtmlNoFlutterJs), name: 'No flutter.js');
await _testProject(HotReloadProject(indexHtml: indexHtmlWithFlutterBootstrapScriptTag), name: 'Using flutter_bootstrap.js script tag');
await _testProject(HotReloadProject(indexHtml: indexHtmlWithInlinedFlutterBootstrapScript), name: 'Using inlined flutter_bootstrap.js');
}
Future<void> _testProject(HotReloadProject project, {String name = 'Default'}) async {
late Directory tempDir;
late FlutterRunTestDriver flutter;
final String testName = 'Hot reload (index.html: $name)';
setUp(() async {
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await flutter.stop();
await flutter.done;
tryToDelete(tempDir);
});
testWithoutContext('$testName: hot restart works without error', () async {
flutter.stdout.listen(printOnFailure);
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose']);
await flutter.hotRestart();
});
testWithoutContext('$testName: newly added code executes during hot restart - html (legacy)', () async {
final Completer<void> completer = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure(line);
if (line.contains('(((((RELOAD WORKED)))))')) {
completer.complete();
}
});
await flutter.run(chrome: true, additionalCommandArgs: <String>[
'--verbose',
...WebRendererMode.html.toCliDartDefines,
]);
project.uncommentHotReloadPrint();
try {
await flutter.hotRestart();
await completer.future.timeout(const Duration(seconds: 15));
} finally {
await subscription.cancel();
}
});
testWithoutContext('$testName: newly added code executes during hot restart - canvaskit', () async {
final Completer<void> completer = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure(line);
if (line.contains('(((((RELOAD WORKED)))))')) {
completer.complete();
}
});
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose']);
project.uncommentHotReloadPrint();
try {
await flutter.hotRestart();
await completer.future.timeout(const Duration(seconds: 15));
} finally {
await subscription.cancel();
}
}, skip: true); // Skipped for https://github.com/flutter/flutter/issues/110879.
}