ToggleImageButton extends ImageButton { public void toggle() { setToggledOn(!isToggledOn); } ToggleImageButton(Context context);  ToggleImageButton(Context context, AttributeSet attrs);  ToggleImageButton(Context context, AttributeSet attrs, int defStyle); @Override int[] onCreateDrawableState(int extraSpace); @Override boolean performClick(); void setToggledOn(boolean isToggledOn); void toggle(); boolean isToggledOn();  }
@Test public void testToggle() { final ToggleImageButton button = createDefaultButton(); assertFalse(button.isToggledOn()); button.toggle(); assertTrue(button.isToggledOn()); }