Code example for InputStreamEntity

Methods: sleep

0
    public void loaderShouldDisplayImage() throws Exception { 
        // prepare http response 
        byte[] buffer = new byte[1];
        InputStream is = new ByteArrayInputStream(buffer);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.setEntity(new InputStreamEntity(is, 1));
        Robolectric.addPendingHttpResponse(response);
        Bitmap bmp = BitmapFactory.decodeStream(is);
 
        ImageView image_view = mock(ImageView.class);
        when(image_view.getTag()).thenReturn("http://example.com/test.png");
 
        loader.displayImage(image_view, activity);
        Thread.sleep(1000);
 
        verify(image_view).setImageBitmap(bmp);
    } 
 
    private class TestModule extends AbstractModule { 
        @Override 
        protected void configure() {