[flutter_tools] initialize frontend server with build (#49405)

This commit is contained in:
Jonah Williams
2020-02-24 14:21:33 -08:00
committed by GitHub
parent e6e79bce6f
commit 59cc3cdf01
7 changed files with 41 additions and 71 deletions

View File

@@ -84,47 +84,6 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Forces fast start off for devices that do not support it', () async {
final MockDevice mockDevice = MockDevice(TargetPlatform.android_arm);
when(mockDevice.name).thenReturn('mockdevice');
when(mockDevice.supportsFastStart).thenReturn(false);
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) async => false);
when(deviceManager.hasSpecifiedAllDevices).thenReturn(false);
when(deviceManager.findTargetDevices(any)).thenAnswer((Invocation invocation) {
return Future<List<Device>>.value(<Device>[mockDevice]);
});
when(deviceManager.getDevices()).thenAnswer((Invocation invocation) {
return Future<List<Device>>.value(<Device>[mockDevice]);
});
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final RunCommand command = RunCommand();
applyMocksToCommand(command);
try {
await createTestCommandRunner(command).run(<String>[
'run',
'--fast-start',
'--no-pub',
]);
fail('Expect exception');
} catch (e) {
expect(e, isA<ToolExit>());
}
final BufferLogger bufferLogger = globals.logger as BufferLogger;
expect(bufferLogger.statusText, isNot(contains(
'Using --fast-start option with device mockdevice, but this device '
'does not support it. Overriding the setting to false.'
)));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => MockDeviceManager(),
});
testUsingContext('Walks upward looking for a pubspec.yaml and succeeds if found', () async {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages')

View File

@@ -234,10 +234,6 @@ void main() {
Usage: () => MockUsage(),
}));
test('ResidentRunner copies dill file from build output into temp directory', () => testbed.run(() async {
expect(residentRunner.artifactDirectory.childFile('app.dill').readAsStringSync(), 'ABC');
}));
test('ResidentRunner can send target platform to analytics from hot reload', () => testbed.run(() async {
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
return 'Example';

View File

@@ -36,10 +36,10 @@ void main() {
});
test('newly added code executes during hot reload', () async {
await _flutter.run();
_project.uncommentHotReloadPrint();
final StringBuffer stdout = StringBuffer();
final StreamSubscription<String> subscription = _flutter.stdout.listen(stdout.writeln);
await _flutter.run();
_project.uncommentHotReloadPrint();
try {
await _flutter.hotReload();
expect(stdout.toString(), contains('(((((RELOAD WORKED)))))'));
@@ -49,10 +49,10 @@ void main() {
});
test('reloadMethod triggers hot reload behavior', () async {
await _flutter.run();
_project.uncommentHotReloadPrint();
final StringBuffer stdout = StringBuffer();
final StreamSubscription<String> subscription = _flutter.stdout.listen(stdout.writeln);
await _flutter.run();
_project.uncommentHotReloadPrint();
try {
final String libraryId = _project.buildBreakpointUri.toString();
await _flutter.reloadMethod(libraryId: libraryId, classId: 'MyApp');
@@ -72,7 +72,6 @@ void main() {
test('breakpoints are hit after hot reload', () async {
Isolate isolate;
await _flutter.run(withDebugger: true, startPaused: true);
final Completer<void> sawTick1 = Completer<void>();
final Completer<void> sawTick3 = Completer<void>();
final Completer<void> sawDebuggerPausedMessage = Completer<void>();
@@ -92,6 +91,7 @@ void main() {
}
},
);
await _flutter.run(withDebugger: true, startPaused: true);
await _flutter.resume(); // we start paused so we can set up our TICK 1 listener before the app starts
unawaited(sawTick1.future.timeout(
const Duration(seconds: 5),
@@ -125,16 +125,15 @@ void main() {
});
test("hot reload doesn't reassemble if paused", () async {
await _flutter.run(withDebugger: true);
final Completer<void> sawTick2 = Completer<void>();
final Completer<void> sawTick1 = Completer<void>();
final Completer<void> sawTick3 = Completer<void>();
final Completer<void> sawDebuggerPausedMessage1 = Completer<void>();
final Completer<void> sawDebuggerPausedMessage2 = Completer<void>();
final StreamSubscription<String> subscription = _flutter.stdout.listen(
(String line) {
if (line.contains('((((TICK 2))))')) {
expect(sawTick2.isCompleted, isFalse);
sawTick2.complete();
if (line.contains('(((TICK 1)))')) {
expect(sawTick1.isCompleted, isFalse);
sawTick1.complete();
}
if (line.contains('The application is paused in the debugger on a breakpoint.')) {
expect(sawDebuggerPausedMessage1.isCompleted, isFalse);
@@ -146,13 +145,14 @@ void main() {
}
},
);
await _flutter.run(withDebugger: true);
await sawTick1.future;
await _flutter.addBreakpoint(
_project.buildBreakpointUri,
_project.buildBreakpointLine,
);
bool reloaded = false;
final Future<void> reloadFuture = _flutter.hotReload().then((void value) { reloaded = true; });
await sawTick2.future; // this should happen before it pauses
final Isolate isolate = await _flutter.waitForPause();
expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint));
expect(reloaded, isFalse);