本文整理汇总了Java中org.robolectric.Robolectric.buildActivity方法的典型用法代码示例。如果您正苦于以下问题:Java Robolectric.buildActivity方法的具体用法?Java Robolectric.buildActivity怎么用?Java Robolectric.buildActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.Robolectric
的用法示例。
在下文中一共展示了Robolectric.buildActivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restoreFromSavedState
import org.robolectric.Robolectric; //导入方法依赖的package包/类
public ActivityProxy restoreFromSavedState() {
if (!isCreated) {
throw new IllegalStateException("The activity isn't created");
}
savedInstanceState = new Bundle();
controller.saveInstanceState(savedInstanceState);
if (isResumed) {
pause();
}
if (isStarted) {
stop();
}
destroy();
controller = Robolectric.buildActivity(TestActivity.class);
create();
return this;
}
示例2: setUp
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
mActivityController = Robolectric.buildActivity(Activity.class);
mActivity = mActivityController
.create()
.start()
.resume()
.get();
final ReactApplicationContext context = PowerMockito.mock(ReactApplicationContext.class);
PowerMockito.when(context.hasActiveCatalystInstance()).thenReturn(true);
PowerMockito.when(context, "getCurrentActivity").thenReturn(mActivity);
mDialogModule = new DialogModule(context);
mDialogModule.onHostResume();
}
示例3: onCreate_withSaveInstanceState_shouldForwardToRootRiblet
import org.robolectric.Robolectric; //导入方法依赖的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: setUp
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Before
public void setUp() {
ActivityController<Activity> activityController =
Robolectric.buildActivity(Activity.class);
activity = spy(activityController.setup().get());
rxActivityResults = spy(new RxActivityResults(activity));
rxActivityResults.mRxActivityResultsFragment =
spy(rxActivityResults.mRxActivityResultsFragment);
when(rxActivityResults.mRxActivityResultsFragment.getActivity())
.thenReturn(activity);
}
示例5: setUp
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
activityController = Robolectric.buildActivity(Activity.class);
activityController.create();
view = new ExpandedView(activityController.get());
activityController.get().setContentView(view);
}
示例6: ActivityProxy
import org.robolectric.Robolectric; //导入方法依赖的package包/类
public ActivityProxy() {
activityController = Robolectric.buildActivity(TestActivity.class);
@IdRes int containerId = 4;
view = new AttachFakingFrameLayout(activityController.get());
view.setId(containerId);
}
示例7: mockForecastViewModelGetsInjected
import org.robolectric.Robolectric; //导入方法依赖的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
示例8: mockPagerAdapterGetsInjected
import org.robolectric.Robolectric; //导入方法依赖的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);
}
示例9: requestsLocationUpdatesInOnStart
import org.robolectric.Robolectric; //导入方法依赖的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);
}
示例10: removesLocationUpdatesInOnStop
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void removesLocationUpdatesInOnStop() {
decorate().componentSingleton().withLocationService(() -> locationService);
app().onCreate();
final ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class);
controller.setup();
reset(locationService);
controller.pause();
verify(locationService, times(0)).removeUpdates();
controller.stop();
verify(locationService).removeUpdates();
controller.destroy();
verifyNoMoreInteractions(locationService);
}
示例11: startFragment
import org.robolectric.Robolectric; //导入方法依赖的package包/类
private ActivityController<FragmentActivity> startFragment(Fragment fragment) {
ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class);
controller.create();
controller.get().getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, fragment)
.commitNow();
return controller;
}
示例12: onCreate_withNullSaveInstanceState_shouldForwardNullToRootRiblet
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void onCreate_withNullSaveInstanceState_shouldForwardNullToRootRiblet() {
ActivityController<EmptyActivity> activityController =
Robolectric.buildActivity(EmptyActivity.class);
activityController.create();
assertThat(activityController.get().getTestInteractor().getSavedInstanceState()).isNull();
}
示例13: onSaveInstanceState_shouldPropagate
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void onSaveInstanceState_shouldPropagate() {
ActivityController<EmptyActivity> activityController =
Robolectric.buildActivity(EmptyActivity.class);
EmptyActivity activity = activityController.setup().get();
android.os.Bundle bundle = new android.os.Bundle();
activity.onSaveInstanceState(bundle);
android.os.Bundle interactorBundle = bundle.getBundle(Router.KEY_INTERACTOR);
assertThat(interactorBundle).isNotNull();
}
示例14: bind_afterDestroy_shouldError
import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void bind_afterDestroy_shouldError() {
ActivityController<EmptyActivity> activityController =
Robolectric.buildActivity(EmptyActivity.class);
EmptyActivity activity = activityController.setup().pause().stop().destroy().get();
AndroidRecordingRx2Observer<Object> o = new AndroidRecordingRx2Observer<>();
Observable.just(new Object()).to(new ObservableScoper<>(activity)).subscribe(o);
assertThat(o.takeError()).isInstanceOf(LifecycleEndedException.class);
}
示例15: ActivityProxy
import org.robolectric.Robolectric; //导入方法依赖的package包/类
public ActivityProxy() {
controller = Robolectric.buildActivity(TestActivity.class);
}