Allow headers to be passed to the WebSocket connection for VMServiceFlutterDriver (#54698)
This commit is contained in:
@@ -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', () {
|
||||
|
||||
Reference in New Issue
Block a user