Пример #1
0
 @Test
 public void createFromStream__shouldReturnDrawableWithSpecificSource() throws Exception {
   Drawable drawable =
       ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source");
   assertNotNull(drawable);
   assertEquals("my_source", ((ShadowBitmapDrawable) shadowOf(drawable)).getSource());
 }
Пример #2
0
 @Test
 public void
     createFromStream__shouldReturnNullWhenAskedToCreateADrawableFromACorruptedSourceStream()
         throws Exception {
   String corruptedStreamSource = "http://foo.com/image.jpg";
   ShadowDrawable.addCorruptStreamSource(corruptedStreamSource);
   assertNull(
       ShadowDrawable.createFromStream(
           new ByteArrayInputStream(new byte[0]), corruptedStreamSource));
 }
Пример #3
0
 @Test
 public void copyBoundsToReturnedRect() {
   Drawable drawable =
       ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source");
   drawable.setBounds(1, 2, 3, 4);
   Rect r = drawable.copyBounds();
   assertThat(r.left).isEqualTo(1);
   assertThat(r.top).isEqualTo(2);
   assertThat(r.right).isEqualTo(3);
   assertThat(r.bottom).isEqualTo(4);
 }