1 package com.xtremelabs.robolectric.shadows; 2 3 import android.widget.CheckBox; 4 import com.xtremelabs.robolectric.WithTestDefaultsRunner; 5 import org.junit.Test; 6 import org.junit.runner.RunWith; 7 8 import static org.hamcrest.CoreMatchers.equalTo; 9 import static org.junit.Assert.assertThat; 10 11 @RunWith(WithTestDefaultsRunner.class) 12 public class CheckBoxTest { 13 @Test testWorks()14 public void testWorks() throws Exception { 15 CheckBox checkBox = new CheckBox(null); 16 assertThat(checkBox.isChecked(), equalTo(false)); 17 18 checkBox.setChecked(true); 19 assertThat(checkBox.isChecked(), equalTo(true)); 20 21 checkBox.performClick(); 22 assertThat(checkBox.isChecked(), equalTo(false)); 23 24 checkBox.toggle(); 25 assertThat(checkBox.isChecked(), equalTo(true)); 26 } 27 } 28