Set DDS port to requested observatory port for test (#66607)

* Set DDS port to requested observatory port for test

* Add test for DDS and observatory ports

* Use FakePlatform instead of mock, fix spacing

* Use FakeProcessManager instead of mock

* Fix analyze issue

* Make completer private and add fn for future
This commit is contained in:
Helin Shiah
2020-09-30 10:14:13 -07:00
committed by GitHub
parent f8750b16bb
commit 9ca15d0118
2 changed files with 100 additions and 1 deletions

View File

@@ -464,7 +464,7 @@ class FlutterPlatform extends PlatformPlugin {
enableObservatory: enableObservatory,
startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes,
observatoryPort: explicitObservatoryPort,
observatoryPort: disableDds ? explicitObservatoryPort : 0,
serverPort: server.port,
);
subprocessActive = true;
@@ -495,6 +495,7 @@ class FlutterPlatform extends PlatformPlugin {
// Pipe stdout and stderr from the subprocess to our printStatus console.
// We also keep track of what observatory port the engine used, if any.
Uri processObservatoryUri;
final Uri ddsServiceUri = getDdsServiceUri();
_pipeStandardStreamsToConsole(
process,
reportObservatoryUri: (Uri detectedUri) async {
@@ -504,6 +505,7 @@ class FlutterPlatform extends PlatformPlugin {
if (!disableDds) {
final DartDevelopmentService dds = await DartDevelopmentService.startDartDevelopmentService(
detectedUri,
serviceUri: ddsServiceUri,
enableAuthCodes: !disableServiceAuthCodes,
ipv6: host.type == InternetAddressType.IPv6,
);
@@ -904,6 +906,19 @@ class FlutterPlatform extends PlatformPlugin {
return 'Shell subprocess crashed with unexpected exit code $exitCode $when.';
}
}
@visibleForTesting
@protected
Uri getDdsServiceUri() {
return Uri(
scheme: 'http',
host: (host.type == InternetAddressType.IPv6 ?
InternetAddress.loopbackIPv6 :
InternetAddress.loopbackIPv4
).host,
port: explicitObservatoryPort ?? 0,
);
}
}
// The [_shellProcessClosed] future can't have errors thrown on it because it