Code example for Resources

Methods: getDrawable

0
        assertThat(Robolectric.getShadowApplication().getResources().getDrawable(R.drawable.nine_patch_drawable)).isInstanceOf(NinePatchDrawable.class);
    } 
 
    @Test(expected = Resources.NotFoundException.class) 
    public void testGetBitmapDrawableForUnknownId() { 
        assertThat(resources.getDrawable(Integer.MAX_VALUE)).isInstanceOf(BitmapDrawable.class);
    } 
 
    @Test 
    public void testDensity() { 
        Activity activity = new Activity();
        assertThat(activity.getResources().getDisplayMetrics().density).isEqualTo(1f);
 
        shadowOf(activity.getResources()).setDensity(1.5f);
        assertThat(activity.getResources().getDisplayMetrics().density).isEqualTo(1.5f);
 
        Activity anotherActivity = new Activity();
        assertThat(anotherActivity.getResources().getDisplayMetrics().density).isEqualTo(1.5f);
    } 
 
Connect your IDE to all the code out there  Get Codota for Java