Added progress updates for all XMLHttpRequest upload types / fix crash on closed connection

Reviewed By: mdvacca

Differential Revision: D6937754

fbshipit-source-id: 89b963e16adf1bd3200806fd7374d28aa618b62f
This commit is contained in:
Héctor Ramos
2018-02-09 10:18:08 -08:00
committed by Facebook Github Bot
parent fdef3784f0
commit 27b6348f86
3 changed files with 85 additions and 61 deletions

View File

@@ -200,6 +200,10 @@ public class NetworkingModuleTest {
@Test
public void testSuccessfulPostRequest() throws Exception {
RCTDeviceEventEmitter emitter = mock(RCTDeviceEventEmitter.class);
ReactApplicationContext context = mock(ReactApplicationContext.class);
when(context.getJSModule(any(Class.class))).thenReturn(emitter);
OkHttpClient httpClient = mock(OkHttpClient.class);
when(httpClient.newCall(any(Request.class))).thenAnswer(new Answer<Object>() {
@Override
@@ -211,12 +215,13 @@ public class NetworkingModuleTest {
OkHttpClient.Builder clientBuilder = mock(OkHttpClient.Builder.class);
when(clientBuilder.build()).thenReturn(httpClient);
when(httpClient.newBuilder()).thenReturn(clientBuilder);
NetworkingModule networkingModule =
new NetworkingModule(mock(ReactApplicationContext.class), "", httpClient);
NetworkingModule networkingModule = new NetworkingModule(context, "", httpClient);
JavaOnlyMap body = new JavaOnlyMap();
body.putString("string", "This is request body");
mockEvents();
networkingModule.sendRequest(
"POST",
"http://somedomain/bar",
@@ -630,4 +635,4 @@ public class NetworkingModuleTest {
assertThat(requestIdArguments.getAllValues().contains(idx + 1)).isTrue();
}
}
}
}