Code example for CheckBox

Methods: isChecked, setChecked

0
public class CompoundButtonListenersTest 
{ 
	@Test 
	public void shouldSupportMultipleOnCheckedChangeListeners() 
	{ 
		CheckBox view = new CheckBox(null);
		CompoundButtonListeners viewListeners = new CompoundButtonListeners(view);
 
		MockOnCheckedChangeListener listener1 = new MockOnCheckedChangeListener();
		MockOnCheckedChangeListener listener2 = new MockOnCheckedChangeListener();
 
		viewListeners.addOnCheckedChangeListener(listener1);
		viewListeners.addOnCheckedChangeListener(listener2);
 
		view.setChecked(!view.isChecked());
 
		assertTrue(listener1.checkedChangeEventFired);
		assertTrue(listener2.checkedChangeEventFired);
	} 
 
	private static class MockOnCheckedChangeListener implements OnCheckedChangeListener