Add coldBoot parameter to JSON-RPC interface of daemon (#83488)
This commit is contained in:
@@ -233,6 +233,7 @@ Return a list of all available emulators. The `params` field will be a List; eac
|
||||
The `launch()` command allows launching an emulator/simulator by its `id`.
|
||||
|
||||
- `emulatorId`: the id of an emulator as returned by `getEmulators`.
|
||||
- `coldBoot`: an optional boolean flag which indicates if the emulator should be cold booted. Only supported for android emulators, silently ignored if emulator type is not android.
|
||||
|
||||
#### emulator.create
|
||||
|
||||
@@ -295,6 +296,7 @@ See the [source](https://github.com/flutter/flutter/blob/master/packages/flutter
|
||||
|
||||
## Changelog
|
||||
|
||||
- 0.6.1: Added `coldBoot` option to `emulator.lauch` command.
|
||||
- 0.6.0: Added `debounce` option to `app.restart` command.
|
||||
- 0.5.3: Added `emulatorId` field to device.
|
||||
- 0.5.2: Added `platformType` and `category` fields to emulator.
|
||||
|
||||
@@ -32,7 +32,7 @@ import '../runner/flutter_command.dart';
|
||||
import '../vmservice.dart';
|
||||
import '../web/web_runner.dart';
|
||||
|
||||
const String protocolVersion = '0.6.0';
|
||||
const String protocolVersion = '0.6.1';
|
||||
|
||||
/// A server process command. This command will start up a long-lived server.
|
||||
/// It reads JSON-RPC based commands from stdin, executes them, and returns
|
||||
@@ -1118,6 +1118,7 @@ class EmulatorDomain extends Domain {
|
||||
|
||||
Future<void> launch(Map<String, dynamic> args) async {
|
||||
final String emulatorId = _getStringArg(args, 'emulatorId', required: true);
|
||||
final bool coldBoot = _getBoolArg(args, 'coldBoot') ?? false;
|
||||
final List<Emulator> matches =
|
||||
await emulators.getEmulatorsMatching(emulatorId);
|
||||
if (matches.isEmpty) {
|
||||
@@ -1125,7 +1126,7 @@ class EmulatorDomain extends Domain {
|
||||
} else if (matches.length > 1) {
|
||||
throw "multiple emulators match '$emulatorId'";
|
||||
} else {
|
||||
await matches.first.launch();
|
||||
await matches.first.launch(coldBoot: coldBoot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,23 @@ void main() {
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('emulator.launch coldboot parameter must be boolean', () async {
|
||||
final StreamController<Map<String, dynamic>> commands = StreamController<Map<String, dynamic>>();
|
||||
final StreamController<Map<String, dynamic>> responses = StreamController<Map<String, dynamic>>();
|
||||
daemon = Daemon(
|
||||
commands.stream,
|
||||
responses.add,
|
||||
notifyingLogger: notifyingLogger,
|
||||
);
|
||||
final Map<String, dynamic> params = <String, dynamic>{'emulatorId': 'device', 'coldBoot': 1};
|
||||
commands.add(<String, dynamic>{'id': 0, 'method': 'emulator.launch', 'params': params});
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['error'], contains('coldBoot is not a bool'));
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('emulator.getEmulators should respond with list', () async {
|
||||
final StreamController<Map<String, dynamic>> commands = StreamController<Map<String, dynamic>>();
|
||||
final StreamController<Map<String, dynamic>> responses = StreamController<Map<String, dynamic>>();
|
||||
|
||||
@@ -16,7 +16,7 @@ late Process daemon;
|
||||
// stop: stop a running app
|
||||
// devices: list devices
|
||||
// emulators: list emulators
|
||||
// launch: launch an emulator
|
||||
// emulator-launch: launch an emulator, append the word coldBoot to cold boot the emulator.
|
||||
|
||||
Future<void> main() async {
|
||||
daemon = await Process.start('dart', <String>['bin/flutter_tools.dart', 'daemon']);
|
||||
@@ -72,6 +72,8 @@ Future<void> main() async {
|
||||
'method': 'emulator.launch',
|
||||
'params': <String, dynamic>{
|
||||
'emulatorId': words[1],
|
||||
if (words.contains('coldBoot'))
|
||||
'coldBoot': true
|
||||
},
|
||||
});
|
||||
} else if (line == 'enable') {
|
||||
|
||||
Reference in New Issue
Block a user