• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.robolectric.shadows;
2 
3 import static com.google.common.truth.Truth.assertThat;
4 import static org.robolectric.Shadows.shadowOf;
5 
6 import android.app.Activity;
7 import androidx.test.ext.junit.runners.AndroidJUnit4;
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.junit.runner.RunWith;
11 import org.robolectric.shadow.api.Shadow;
12 
13 @RunWith(AndroidJUnit4.class)
14 public class ShadowTest {
15 
16   private ClassLoader myClassLoader;
17 
18   @Before
setUp()19   public void setUp() throws Exception {
20     myClassLoader = getClass().getClassLoader();
21   }
22 
23   @Test
newInstanceOf()24   public void newInstanceOf() throws Exception {
25     assertThat(Shadow.newInstanceOf(Activity.class.getName()).getClass().getClassLoader())
26         .isSameInstanceAs(myClassLoader);
27   }
28 
29   @Test
extractor()30   public void extractor() throws Exception {
31     Activity activity = new Activity();
32     assertThat((ShadowActivity) Shadow.extract(activity)).isSameInstanceAs(shadowOf(activity));
33   }
34 
35   @Test
otherDeprecated_extractor()36   public void otherDeprecated_extractor() throws Exception {
37     Activity activity = new Activity();
38     assertThat(Shadow.<Object>extract(activity)).isSameInstanceAs(shadowOf(activity));
39   }
40 }
41