Exemplo 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);
 }
Exemplo 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));
 }
Exemplo 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();
 }
Exemplo 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));
 }
Exemplo 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());
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 @Test
 public void createFromPath__shouldReturnDrawableWithSpecificPath() throws Exception {
   Drawable drawable = ShadowDrawable.createFromPath("/foo");
   assertNotNull(drawable);
   assertEquals("/foo", ((ShadowBitmapDrawable) shadowOf(drawable)).getPath());
 }
Exemplo n.º 8
0
 @Test
 public void testCreateFromResourceId_shouldSetTheId() throws Exception {
   Drawable drawable = ShadowDrawable.createFromResourceId(34758);
   ShadowDrawable shadowDrawable = shadowOf(drawable);
   assertThat(shadowDrawable.getLoadedFromResourceId()).isEqualTo(34758);
 }