Ejemplo n.º 1
0
 @Test
 public void testSetLoadedFromResourceId() throws Exception {
   Drawable drawable = new TestDrawable();
   ShadowDrawable shadowDrawable = shadowOf(drawable);
   shadowDrawable.setLoadedFromResourceId(99);
   assertThat(shadowDrawable.getLoadedFromResourceId()).isEqualTo(99);
 }
Ejemplo n.º 2
0
 @Test
 public void reset__shouldClearStaticState() throws Exception {
   String src = "source1";
   ShadowDrawable.addCorruptStreamSource(src);
   assertTrue(ShadowDrawable.corruptStreamSources.contains(src));
   ShadowDrawable.reset();
   assertFalse(ShadowDrawable.corruptStreamSources.contains(src));
 }
Ejemplo n.º 3
0
 @Test
 public void testWasSelfInvalidated() throws Exception {
   Drawable drawable = ShadowDrawable.createFromResourceId(34758);
   ShadowDrawable shadowDrawable = shadowOf(drawable);
   assertThat(shadowDrawable.wasInvalidated()).isFalse();
   drawable.invalidateSelf();
   assertThat(shadowDrawable.wasInvalidated()).isTrue();
 }
Ejemplo n.º 4
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));
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 @Test
 public void createFromPath__shouldReturnDrawableWithSpecificPath() throws Exception {
   Drawable drawable = ShadowDrawable.createFromPath("/foo");
   assertNotNull(drawable);
   assertEquals("/foo", ((ShadowBitmapDrawable) shadowOf(drawable)).getPath());
 }
Ejemplo n.º 9
0
 @Test
 public void testCreateFromResourceId_shouldSetTheId() throws Exception {
   Drawable drawable = ShadowDrawable.createFromResourceId(34758);
   ShadowDrawable shadowDrawable = shadowOf(drawable);
   assertThat(shadowDrawable.getLoadedFromResourceId()).isEqualTo(34758);
 }