Unverified Commit 50eeda24 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] fix frontend server generated entrypoint (#50036)

parent 5039e259
...@@ -515,7 +515,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner { ...@@ -515,7 +515,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
'import "$generatedImport";', 'import "$generatedImport";',
'Future<void> main() async {', 'Future<void> main() async {',
if (hasWebPlugins) if (hasWebPlugins)
' registerPlugins(webPluginRegistry);' ' registerPlugins(webPluginRegistry);',
' await ui.webOnlyInitializePlatform();', ' await ui.webOnlyInitializePlatform();',
' entrypoint.main();', ' entrypoint.main();',
'}', '}',
......
...@@ -414,6 +414,7 @@ void main() { ...@@ -414,6 +414,7 @@ void main() {
test('Can hot restart after attaching - experimental', () => testbed.run(() async { test('Can hot restart after attaching - experimental', () => testbed.run(() async {
_setupMocks(); _setupMocks();
launchChromeInstance(mockChrome); launchChromeInstance(mockChrome);
String entrypointFileName;
when(mockWebDevFS.update( when(mockWebDevFS.update(
mainPath: anyNamed('mainPath'), mainPath: anyNamed('mainPath'),
target: anyNamed('target'), target: anyNamed('target'),
...@@ -428,6 +429,7 @@ void main() { ...@@ -428,6 +429,7 @@ void main() {
pathToReload: anyNamed('pathToReload'), pathToReload: anyNamed('pathToReload'),
invalidatedFiles: anyNamed('invalidatedFiles'), invalidatedFiles: anyNamed('invalidatedFiles'),
)).thenAnswer((Invocation invocation) async { )).thenAnswer((Invocation invocation) async {
entrypointFileName = invocation.namedArguments[#mainPath] as String;
return UpdateFSReport(success: true) return UpdateFSReport(success: true)
..invalidatedModules = <String>['example']; ..invalidatedModules = <String>['example'];
}); });
...@@ -438,6 +440,12 @@ void main() { ...@@ -438,6 +440,12 @@ void main() {
await connectionInfoCompleter.future; await connectionInfoCompleter.future;
final OperationResult result = await residentWebRunner.restart(fullRestart: true); final OperationResult result = await residentWebRunner.restart(fullRestart: true);
// Ensure that generated entrypoint is generated correctly.
expect(entrypointFileName, isNotNull);
expect(globals.fs.file(entrypointFileName).readAsStringSync(), contains(
'await ui.webOnlyInitializePlatform();'
));
expect(testLogger.statusText, contains('Restarted application in')); expect(testLogger.statusText, contains('Restarted application in'));
expect(result.code, 0); expect(result.code, 0);
verify(mockResidentCompiler.accept()).called(2); verify(mockResidentCompiler.accept()).called(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment