Skip to content

Commit

Permalink
Pass device-user in machine mode (#107747)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingjun authored Jul 15, 2022
1 parent 1a4f963 commit 2cfeb0d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/flutter_tools/lib/src/commands/daemon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class AppDomain extends Domain {
bool multidexEnabled = false,
String? isolateFilter,
bool machine = true,
String? userIdentifier,
}) async {
if (!await device.supportsRuntimeMode(options.buildInfo.mode)) {
throw Exception(
Expand All @@ -517,6 +518,7 @@ class AppDomain extends Domain {
target: target,
buildInfo: options.buildInfo,
platform: globals.platform,
userIdentifier: userIdentifier,
);

ResidentRunner runner;
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_tools/lib/src/commands/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ class RunCommand extends RunCommandBase {
dillOutputPath: stringArgDeprecated('output-dill'),
ipv6: ipv6 ?? false,
multidexEnabled: boolArgDeprecated('multidex'),
userIdentifier: userIdentifier,
);
} on Exception catch (error) {
throwToolExit(error.toString());
Expand Down
34 changes: 34 additions & 0 deletions packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,37 @@ void main() {
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});

testUsingContext('can pass --device-user', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
final FakeDevice device = FakeDevice(platformType: PlatformType.android);
mockDeviceManager
..devices = <Device>[device]
..targetDevices = <Device>[device];

await expectLater(
() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--machine',
'--device-user',
'10',
'-d',
device.id,
]),
throwsToolExit(),
);
expect(command.appDomain.userIdentifier, '10');
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});
});
});

Expand Down Expand Up @@ -1080,6 +1111,7 @@ class CapturingAppDomain extends AppDomain {
CapturingAppDomain(Daemon daemon) : super(daemon);

bool /*?*/ multidexEnabled;
String /*?*/ userIdentifier;

@override
Future<AppInstance> startApp(
Expand All @@ -1098,8 +1130,10 @@ class CapturingAppDomain extends AppDomain {
bool multidexEnabled = false,
String isolateFilter,
bool machine = true,
String userIdentifier,
}) async {
this.multidexEnabled = multidexEnabled;
this.userIdentifier = userIdentifier;
throwToolExit('');
}
}
Expand Down

0 comments on commit 2cfeb0d

Please sign in to comment.