use of com.facebook.stetho.inspector.network.ResponseHandler in project stetho by facebook.
the class StethoInterceptorTest method hookAlmostRealInterpretResponseStream.
/**
* Provide a suitably "real" implementation of
* {@link NetworkEventReporter#interpretResponseStream} for our mock to test that
* events are properly delegated.
*/
private static ByteArrayOutputStream hookAlmostRealInterpretResponseStream(final NetworkEventReporter mockEventReporter) {
final ByteArrayOutputStream capturedOutput = new ByteArrayOutputStream();
Mockito.when(mockEventReporter.interpretResponseStream(anyString(), anyString(), anyString(), any(InputStream.class), any(ResponseHandler.class))).thenAnswer(new Answer<InputStream>() {
@Override
public InputStream answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
String requestId = (String) args[0];
String contentEncoding = (String) args[2];
InputStream responseStream = (InputStream) args[3];
ResponseHandler responseHandler = (ResponseHandler) args[4];
return DecompressionHelper.teeInputWithDecompression(null, /* networkPeerManager */
requestId, responseStream, capturedOutput, contentEncoding, responseHandler);
}
});
return capturedOutput;
}
use of com.facebook.stetho.inspector.network.ResponseHandler in project stetho by facebook.
the class StethoInterceptorTest method hookAlmostRealInterpretResponseStream.
/**
* Provide a suitably "real" implementation of
* {@link NetworkEventReporter#interpretResponseStream} for our mock to test that
* events are properly delegated.
*/
private static ByteArrayOutputStream hookAlmostRealInterpretResponseStream(final NetworkEventReporter mockEventReporter) {
final ByteArrayOutputStream capturedOutput = new ByteArrayOutputStream();
Mockito.when(mockEventReporter.interpretResponseStream(anyString(), anyString(), anyString(), any(InputStream.class), any(ResponseHandler.class))).thenAnswer(new Answer<InputStream>() {
@Override
public InputStream answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
String requestId = (String) args[0];
String contentEncoding = (String) args[2];
InputStream responseStream = (InputStream) args[3];
ResponseHandler responseHandler = (ResponseHandler) args[4];
return DecompressionHelper.teeInputWithDecompression(null, /* networkPeerManager */
requestId, responseStream, capturedOutput, contentEncoding, responseHandler);
}
});
return capturedOutput;
}
Aggregations