Allow headers to be passed to the WebSocket connection for VMServiceFlutterDriver (#54698)

This commit is contained in:
Aubrey Anderson
2020-04-15 18:25:02 -07:00
committed by GitHub
parent 0ece276ecb
commit d537834b38
3 changed files with 34 additions and 7 deletions

View File

@@ -51,7 +51,7 @@ void main() {
when(mockIsolate.loadRunnable()).thenAnswer((_) => Future<MockIsolate>.value(mockIsolate));
when(mockIsolate.invokeExtension(any, any)).thenAnswer(
(Invocation invocation) => makeMockResponse(<String, dynamic>{'status': 'ok'}));
vmServiceConnectFunction = (String url) {
vmServiceConnectFunction = (String url, {Map<String, dynamic> headers}) {
return Future<VMServiceClientConnection>.value(
VMServiceClientConnection(mockClient, mockPeer)
);
@@ -116,6 +116,22 @@ void main() {
expect(driver, isNotNull);
expectLogContains('Isolate is not paused. Assuming application is ready.');
});
test('connects with headers', () async {
Map<String, dynamic> actualHeaders;
vmServiceConnectFunction = (String url, {Map<String, dynamic> headers}) {
actualHeaders = headers;
return Future<VMServiceClientConnection>.value(
VMServiceClientConnection(mockClient, mockPeer)
);
};
final Map<String, String> expectedHeaders = <String, String>{'header-key': 'header-value'};
final FlutterDriver driver = await FlutterDriver.connect(
dartVmServiceUrl: '', headers: expectedHeaders);
expect(driver, isNotNull);
expect(actualHeaders, equals(expectedHeaders));
});
});
group('VMServiceFlutterDriver', () {