Unverified Commit 111c6ab1 authored by Dan Field's avatar Dan Field Committed by GitHub

Fix reuseApplication when ws URI does not end with `/` (#82066)

parent b8a24567
...@@ -198,7 +198,9 @@ class FlutterDriverService extends DriverService { ...@@ -198,7 +198,9 @@ class FlutterDriverService extends DriverService {
) async { ) async {
Uri uri; Uri uri;
if (vmServiceUri.scheme == 'ws') { if (vmServiceUri.scheme == 'ws') {
uri = vmServiceUri.replace(scheme: 'http', path: vmServiceUri.path.replaceFirst('ws/', '')); final List<String> segments = vmServiceUri.pathSegments.toList();
segments.remove('ws');
uri = vmServiceUri.replace(scheme: 'http', path: segments.join('/'));
} else { } else {
uri = vmServiceUri; uri = vmServiceUri;
} }
......
...@@ -354,6 +354,53 @@ void main() { ...@@ -354,6 +354,53 @@ void main() {
await driverService.stop(); await driverService.stop();
}); });
testWithoutContext('Can connect to existing application using ws URI (no trailing slash)', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <FakeVmServiceRequest>[
getVM,
getVM,
const FakeVmServiceRequest(
method: 'ext.flutter.exit',
args: <String, Object>{
'isolateId': '1',
}
)
]);
final FakeProcessManager processManager = FakeProcessManager.empty();
final DriverService driverService = setUpDriverService(processManager: processManager, vmService: fakeVmServiceHost.vmService);
final FakeDevice device = FakeDevice(LaunchResult.failed());
await driverService.reuseApplication(
Uri.parse('ws://127.0.0.1:63426/1UasC_ihpXY=/ws'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
testWithoutContext('Can connect to existing application using ws URI (no trailing slash, ws in auth code)', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <FakeVmServiceRequest>[
getVM,
getVM,
const FakeVmServiceRequest(
method: 'ext.flutter.exit',
args: <String, Object>{
'isolateId': '1',
}
)
]);
final FakeProcessManager processManager = FakeProcessManager.empty();
final DriverService driverService = setUpDriverService(processManager: processManager, vmService: fakeVmServiceHost.vmService);
final FakeDevice device = FakeDevice(LaunchResult.failed());
await driverService.reuseApplication(
Uri.parse('ws://127.0.0.1:63426/wsasC_ihpXY=/ws'),
device,
DebuggingOptions.enabled(BuildInfo.debug),
false,
);
await driverService.stop();
});
testWithoutContext('Does not call flutterExit on device types that do not support it', () async { testWithoutContext('Does not call flutterExit on device types that do not support it', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <FakeVmServiceRequest>[ final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <FakeVmServiceRequest>[
...@@ -401,6 +448,9 @@ FlutterDriverService setUpDriverService({ ...@@ -401,6 +448,9 @@ FlutterDriverService setUpDriverService({
if (httpUri.scheme != 'http') { if (httpUri.scheme != 'http') {
fail('Expected an HTTP scheme, found $httpUri'); fail('Expected an HTTP scheme, found $httpUri');
} }
if (httpUri.path.endsWith('/ws')) {
fail('Expected HTTP uri to not contain `/ws`, found $httpUri');
}
return vmService; return vmService;
} }
); );
......
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