use of org.chromium.net.UrlRequest in project ExoPlayer by google.
the class CronetDataSourceTest method testCallbackFromPreviousRequest.
@Test
public void testCallbackFromPreviousRequest() throws HttpDataSourceException {
mockResponseStartSuccess();
dataSourceUnderTest.open(testDataSpec);
dataSourceUnderTest.close();
// Prepare a mock UrlRequest to be used in the second open() call.
final UrlRequest mockUrlRequest2 = mock(UrlRequest.class);
when(mockUrlRequestBuilder.build()).thenReturn(mockUrlRequest2);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
// Invoke the callback for the previous request.
dataSourceUnderTest.onFailed(mockUrlRequest, testUrlResponseInfo, mockNetworkException);
dataSourceUnderTest.onResponseStarted(mockUrlRequest2, testUrlResponseInfo);
return null;
}
}).when(mockUrlRequest2).start();
dataSourceUnderTest.open(testDataSpec);
}
use of org.chromium.net.UrlRequest in project ExoPlayer by google.
the class CronetDataSource method getStatus.
private static int getStatus(UrlRequest request) {
final ConditionVariable conditionVariable = new ConditionVariable();
final int[] statusHolder = new int[1];
request.getStatus(new UrlRequest.StatusListener() {
@Override
public void onStatus(int status) {
statusHolder[0] = status;
conditionVariable.open();
}
});
conditionVariable.block();
return statusHolder[0];
}
Aggregations