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


Java Robolectric.buildActivity方法代码示例

本文整理汇总了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;
}
 
开发者ID:seven332,项目名称:Stage,代码行数:23,代码来源:ActivityProxy.java

示例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();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:DialogModuleTest.java

示例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);
}
 
开发者ID:uber,项目名称:RIBs,代码行数:21,代码来源:RibActivityTest.java

示例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);

}
 
开发者ID:mohamad-amin,项目名称:RxActivityResults,代码行数:16,代码来源:RxActivityResultsTest.java

示例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);
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:8,代码来源:ExpandedViewTest.java

示例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);
}
 
开发者ID:seven332,项目名称:conductor-attacher,代码行数:8,代码来源:ActivityProxy.java

示例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);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:8,代码来源:TestMainActivityWithRobolectricExample.java

示例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);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:15,代码来源:TestMainActivityWithRobolectricExample.java

示例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);
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:15,代码来源:TestMainActivityWithRobolectricExample.java

示例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;
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:10,代码来源:AndroidLifecycleFragmentTest.java

示例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();
}
 
开发者ID:uber,项目名称:RIBs,代码行数:9,代码来源:RibActivityTest.java

示例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();
}
 
开发者ID:uber,项目名称:RIBs,代码行数:13,代码来源:RibActivityTest.java

示例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);
}
 
开发者ID:uber,项目名称:RIBs,代码行数:11,代码来源:RibActivityTest.java

示例15: ActivityProxy

import org.robolectric.Robolectric; //导入方法依赖的package包/类
public ActivityProxy() {
  controller = Robolectric.buildActivity(TestActivity.class);
}
 
开发者ID:seven332,项目名称:Stage,代码行数:4,代码来源:ActivityProxy.java


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