Example #1
0
 @Ignore // todo we need to figure out a better way to deal with this...
 @Test // the shadow will still have its default constructor called; it would be duplicative to
       // call __constructor__() too.
 @Config(shadows = {ShadowForClassWithNoDefaultConstructor.class})
 public void forClassWithNoDefaultConstructor_generatedDefaultConstructorShouldNotCallShadow()
     throws Exception {
   Constructor<ClassWithNoDefaultConstructor> ctor =
       ClassWithNoDefaultConstructor.class.getDeclaredConstructor();
   ctor.setAccessible(true);
   ClassWithNoDefaultConstructor instance = ctor.newInstance();
   assertThat(Robolectric.shadowOf_(instance)).isNotNull();
   assertThat(Robolectric.shadowOf_(instance))
       .isInstanceOf(ShadowForClassWithNoDefaultConstructor.class);
   assertTrue(ShadowForClassWithNoDefaultConstructor.shadowDefaultConstructorCalled);
   assertFalse(ShadowForClassWithNoDefaultConstructor.shadowDefaultConstructorImplementorCalled);
 }
 public static <T> T inject(Resources resources, T instance) {
   Object shadow = Robolectric.shadowOf_(instance);
   if (shadow instanceof UsesResources) {
     ((UsesResources) shadow).injectResources(resources);
   }
   return instance;
 }
Example #3
0
 @Before
 public void setUp() {
   shadowManager = Robolectric.shadowOf_(AppWidgetManager.getInstance(Robolectric.application));
   viewId = 1234;
   views = mock(RemoteViews.class);
 }