Beispiel #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());
 }
 @Test
 public void canResolveDrawableGivenPackageAndResourceId() throws Exception {
   Drawable drawable =
       ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source");
   rpm.addDrawableResolution("com.example.foo", 4334, drawable);
   Drawable actual = rpm.getDrawable("com.example.foo", 4334, null);
   assertThat(actual).isSameAs(drawable);
 }
Beispiel #3
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));
 }
Beispiel #4
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);
 }