本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}