当前位置: 首页>>代码示例>>Java>>正文


Java ActivityController.create方法代码示例

本文整理汇总了Java中org.robolectric.android.controller.ActivityController.create方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityController.create方法的具体用法?Java ActivityController.create怎么用?Java ActivityController.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.android.controller.ActivityController的用法示例。


在下文中一共展示了ActivityController.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBindActivity

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test public void testBindActivity() throws Exception {
  ActivityController controller = Robolectric.buildActivity(TestActivity.class).create().start();
  NaviActivity activity = (NaviActivity) controller.get();

  this.presenter.bind(activity);

  controller.create();
  //before activity start view is unbound
  assertTrue(this.presenter.view == null);

  controller.start();
  //after activity started view has been bound automatically
  assertTrue(this.presenter.view != null);

  controller.destroy();
  //before activity destroyed view is unbound
  assertTrue(this.presenter.view == null);
}
 
开发者ID:ezhome,项目名称:Android-RxPresenter,代码行数:19,代码来源:RxPresenterTest.java

示例2: testActivityObservableBindLifecycle

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test public void testActivityObservableBindLifecycle() throws Exception {
  final Observable<Object> observable = PublishSubject.create().asObservable();

  TestSubscriber<Object> testSubscriber = TestSubscriber.create();

  ActivityController controller = Robolectric.buildActivity(TestActivity.class).create().start();
  NaviActivity activity = (NaviActivity) controller.get();
  this.presenter.bind(activity);

  this.presenter.bindLifecycle(observable, testSubscriber);

  controller.create();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.start();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.resume();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.pause();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.stop();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.destroy();
  testSubscriber.assertCompleted();
  testSubscriber.assertUnsubscribed();
}
 
开发者ID:ezhome,项目名称:Android-RxPresenter,代码行数:26,代码来源:RxPresenterTest.java

示例3: onCreate_withSaveInstanceState_shouldForwardToRootRiblet

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void onCreate_withSaveInstanceState_shouldForwardToRootRiblet() {
  android.os.Bundle interactorBundle = new android.os.Bundle();
  interactorBundle.putString(TEST_BUNDLE_KEY, TEST_BUNDLE_VALUE);

  android.os.Bundle testBundle = new android.os.Bundle();
  testBundle.putBundle(Router.KEY_INTERACTOR, interactorBundle);

  ActivityController<EmptyActivity> activityController =
      Robolectric.buildActivity(EmptyActivity.class);
  activityController.create(testBundle);

  assertThat(
          activityController
              .get()
              .getTestInteractor()
              .getSavedInstanceState()
              .getString(TEST_BUNDLE_KEY))
      .isEqualTo(TEST_BUNDLE_VALUE);
}
 
开发者ID:uber,项目名称:RIBs,代码行数:21,代码来源:RibActivityTest.java

示例4: onCreateWithPresentSavedInstanceState

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void onCreateWithPresentSavedInstanceState() {
    ActivityController<ForecastActivity> controller = Robolectric.buildActivity(ForecastActivity.class);
    controller.create(new Bundle());

    presenter = controller.get().getPresenter();
    verify(presenter, never()).loadLastForecast();
}
 
开发者ID:tobyhs,项目名称:WeatherWeight,代码行数:9,代码来源:ForecastActivityTest.java

示例5: mockForecastViewModelGetsInjected

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void mockForecastViewModelGetsInjected() {
    Intent intent = new Intent(app(), ForecastActivity.class);
    intent.putExtra(ForecastActivity.INTENT_KEY_FORECAST, "some value");
    final ActivityController<ForecastActivity> controller =
            Robolectric.buildActivity(ForecastActivity.class);
    controller.create(null);
    final ForecastActivity activity = controller.get();
    assertEquals(activity.vm, forecastViewModel);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:11,代码来源:TestForecastActivityWithRobolectricExample.java

示例6: mockPagerAdapterGetsInjected

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void mockPagerAdapterGetsInjected() {
    final ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
    controller.create(null);
    final MainActivity activity = controller.get();
    assertEquals(activity.mSectionsPagerAdapter, pagerAdapter);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:8,代码来源:TestMainActivityWithRobolectricExample.java

示例7: requestsLocationUpdatesInOnStart

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void requestsLocationUpdatesInOnStart() {
    decorate().componentSingleton().withLocationService(() -> locationService);
    app().onCreate();
    final ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
    controller.create(null);
    verify(locationService, times(0)).requestLocationUpdates();
    controller.start();
    verify(locationService).requestLocationUpdates();
    reset(locationService);
    controller.resume();
    controller.visible();
    verifyNoMoreInteractions(locationService);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:15,代码来源:TestMainActivityWithRobolectricExample.java

示例8: onCreate_withNullSaveInstanceState_shouldForwardNullToRootRiblet

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void onCreate_withNullSaveInstanceState_shouldForwardNullToRootRiblet() {
  ActivityController<EmptyActivity> activityController =
      Robolectric.buildActivity(EmptyActivity.class);
  activityController.create();

  assertThat(activityController.get().getTestInteractor().getSavedInstanceState()).isNull();
}
 
开发者ID:uber,项目名称:RIBs,代码行数:9,代码来源:RibActivityTest.java

示例9: rxActivity_delaySubscription_shouldIgnoreOtherEvents

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void rxActivity_delaySubscription_shouldIgnoreOtherEvents() {
  ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
  final RibActivity activity = activityController.get();

  final PublishSubject<Object> subject = PublishSubject.create();
  AndroidRecordingRx2Observer<Object> o = new AndroidRecordingRx2Observer<>();
  subject
      .hide()
      .delaySubscription(
          activity
              .lifecycle()
              .filter(
                  new Predicate<ActivityLifecycleEvent>() {
                    @Override
                    public boolean test(ActivityLifecycleEvent activityEvent) throws Exception {
                      return activityEvent.getType() == ActivityLifecycleEvent.Type.RESUME;
                    }
                  }))
      .subscribe(o);

  subject.onNext(new Object());
  activityController.create();
  subject.onNext(new Object());
  o.assertNoMoreEvents();
  activityController.start();
  subject.onNext(new Object());
  o.assertNoMoreEvents();
  activityController.postCreate(null);
  subject.onNext(new Object());
  o.assertNoMoreEvents();
  activityController.resume();
  subject.onNext(new Object());
  assertThat(o.takeNext()).isNotNull();
  o.assertNoMoreEvents();
}
 
开发者ID:uber,项目名称:RIBs,代码行数:37,代码来源:RibActivityTest.java


注:本文中的org.robolectric.android.controller.ActivityController.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。