1 package com.xtremelabs.robolectric.shadows; 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertNotNull; 5 import android.app.Activity; 6 import android.widget.Toast; 7 8 import com.xtremelabs.robolectric.WithTestDefaultsRunner; 9 10 import org.junit.Test; 11 import org.junit.runner.RunWith; 12 13 @RunWith(WithTestDefaultsRunner.class) 14 public class ToastTest { 15 16 @Test shouldHaveShortDuration()17 public void shouldHaveShortDuration() throws Exception { 18 Toast toast = Toast.makeText(new Activity(), "short toast", 19 Toast.LENGTH_SHORT); 20 assertNotNull(toast); 21 assertEquals(Toast.LENGTH_SHORT, toast.getDuration()); 22 } 23 24 @Test shouldHaveLongDuration()25 public void shouldHaveLongDuration() throws Exception { 26 Toast toast = Toast.makeText(new Activity(), "long toast", 27 Toast.LENGTH_LONG); 28 assertNotNull(toast); 29 assertEquals(Toast.LENGTH_LONG, toast.getDuration()); 30 } 31 } 32