ToggleImageButton extends ImageButton { @Override public boolean performClick() { if (toggleOnClick) { toggle(); } return super.performClick(); } 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 testPerformClick() { final ToggleImageButton button = createDefaultButton(); assertTrue(button.toggleOnClick); assertFalse(button.isToggledOn()); button.performClick(); assertTrue(button.isToggledOn()); }