1 package org.robolectric.shadows; 2 3 import static org.robolectric.shadow.api.Shadow.directlyOn; 4 import static org.robolectric.util.ReflectionHelpers.ClassParameter.from; 5 6 import android.graphics.drawable.Drawable; 7 import android.widget.CompoundButton; 8 import org.robolectric.annotation.Implementation; 9 import org.robolectric.annotation.Implements; 10 import org.robolectric.annotation.RealObject; 11 12 @SuppressWarnings({"UnusedDeclaration"}) 13 @Implements(CompoundButton.class) 14 public class ShadowCompoundButton extends ShadowTextView { 15 @RealObject CompoundButton realObject; 16 private int buttonDrawableId; 17 private Drawable buttonDrawable; 18 19 @Implementation 20 public void setButtonDrawable(int buttonDrawableId) { 21 this.buttonDrawableId = buttonDrawableId; 22 directlyOn(realObject, CompoundButton.class, "setButtonDrawable", from(int.class, buttonDrawableId)); 23 } 24 25 @Implementation 26 public void setButtonDrawable(Drawable buttonDrawable) { 27 this.buttonDrawable = buttonDrawable; 28 directlyOn(realObject, CompoundButton.class, "setButtonDrawable", from(Drawable.class, buttonDrawable)); 29 } 30 31 public int getButtonDrawableId() { 32 return buttonDrawableId; 33 } 34 35 public Drawable getButtonDrawable() { 36 return buttonDrawable; 37 } 38 } 39