Пример #1
0
  @Test(expected = IllegalArgumentException.class)
  public void shouldNotBeAbleToExitTheWrongScope() {
    final ContextScope scope =
        RoboGuice.getOrCreateBaseApplicationInjector(Robolectric.application)
            .getInstance(ContextScope.class);
    final Activity a = Robolectric.buildActivity(A.class).get();
    final Activity b = Robolectric.buildActivity(B.class).get();

    scope.enter(a);
    scope.enter(b);
    scope.exit(a);
  }
Пример #2
0
 protected void glueInjections() {
   addBindings();
   if (!module.isEmpty()) {
     Injector injector =
         RoboGuice.getOrCreateBaseApplicationInjector(
             RuntimeEnvironment.application,
             RoboGuice.DEFAULT_STAGE,
             (Module) RoboGuice.newDefaultRoboModule(RuntimeEnvironment.application),
             module);
     inject(injector);
   }
 }
Пример #3
0
  @Test
  public void shouldBeAbleToOpenMultipleScopes() {
    final ContextScope scope =
        RoboGuice.getOrCreateBaseApplicationInjector(Robolectric.application)
            .getInstance(ContextScope.class);
    final Activity a = Robolectric.buildActivity(A.class).get();
    final Activity b = Robolectric.buildActivity(B.class).get();

    scope.enter(a);
    scope.enter(b);
    scope.exit(b);
    scope.exit(a);
  }