@TestTargets({ @TestTargetNew( level = TestLevel.COMPLETE, method = "mutate", args = {}), @TestTargetNew( level = TestLevel.COMPLETE, method = "getDrawable", args = {}) }) public void testMutate() { Resources resources = mContext.getResources(); RotateDrawable d1 = (RotateDrawable) resources.getDrawable(R.drawable.rotatedrawable); RotateDrawable d2 = (RotateDrawable) resources.getDrawable(R.drawable.rotatedrawable); RotateDrawable d3 = (RotateDrawable) resources.getDrawable(R.drawable.rotatedrawable); d1.setAlpha(100); assertEquals(100, ((BitmapDrawable) d1.getDrawable()).getPaint().getAlpha()); assertEquals(100, ((BitmapDrawable) d2.getDrawable()).getPaint().getAlpha()); assertEquals(100, ((BitmapDrawable) d3.getDrawable()).getPaint().getAlpha()); d1.mutate(); d1.setAlpha(200); assertEquals(200, ((BitmapDrawable) d1.getDrawable()).getPaint().getAlpha()); assertEquals(100, ((BitmapDrawable) d2.getDrawable()).getPaint().getAlpha()); assertEquals(100, ((BitmapDrawable) d3.getDrawable()).getPaint().getAlpha()); d2.setAlpha(50); assertEquals(200, ((BitmapDrawable) d1.getDrawable()).getPaint().getAlpha()); assertEquals(50, ((BitmapDrawable) d2.getDrawable()).getPaint().getAlpha()); assertEquals(50, ((BitmapDrawable) d3.getDrawable()).getPaint().getAlpha()); }
@TestTargetNew( level = TestLevel.COMPLETE, method = "setAlpha", args = {int.class}) public void testSetAlpha() { mRotateDrawable.setAlpha(100); assertEquals(100, ((BitmapDrawable) mRotateDrawable.getDrawable()).getPaint().getAlpha()); mRotateDrawable.setAlpha(255); assertEquals(255, ((BitmapDrawable) mRotateDrawable.getDrawable()).getPaint().getAlpha()); }
@TestTargetNew( level = TestLevel.COMPLETE, method = "setColorFilter", args = {android.graphics.ColorFilter.class}) public void testSetColorFilter() { ColorFilter filter = new ColorFilter(); mRotateDrawable.setColorFilter(filter); assertSame( filter, ((BitmapDrawable) mRotateDrawable.getDrawable()).getPaint().getColorFilter()); mRotateDrawable.setColorFilter(null); assertNull(((BitmapDrawable) mRotateDrawable.getDrawable()).getPaint().getColorFilter()); }