1package com.xtremelabs.robolectric; 2 3import android.view.View; 4import com.xtremelabs.robolectric.internal.Implements; 5import com.xtremelabs.robolectric.shadows.ShadowView; 6import org.junit.Test; 7import org.junit.runner.RunWith; 8 9import static com.xtremelabs.robolectric.Robolectric.shadowOf; 10import static org.hamcrest.CoreMatchers.equalTo; 11import static org.junit.Assert.assertThat; 12 13@RunWith(WithTestDefaultsRunner.class) 14public class TemporaryBindingsTest { 15 16 @Test 17 public void overridingShadowBindingsShouldNotAffectBindingsInLaterTests() throws Exception { 18 assertThat(shadowOf(new View(null)).getClass().getSimpleName(), equalTo(ShadowView.class.getSimpleName())); 19 20 Robolectric.bindShadowClass(TemporaryShadowView.class); 21 22 assertThat(Robolectric.shadowOf_(new View(null)).getClass().getSimpleName(), 23 equalTo(TemporaryShadowView.class.getSimpleName())); 24 } 25 26 @Test 27 public void overridingShadowBindingsShouldNotAffectBindingsInLaterTestsAgain() throws Exception { 28 assertThat(shadowOf(new View(null)).getClass().getSimpleName(), equalTo(ShadowView.class.getSimpleName())); 29 30 Robolectric.bindShadowClass(TemporaryShadowView.class); 31 32 assertThat(Robolectric.shadowOf_(new View(null)).getClass().getSimpleName(), 33 equalTo(TemporaryShadowView.class.getSimpleName())); 34 } 35 36 @Implements(View.class) 37 public static class TemporaryShadowView { 38 } 39} 40