• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ActivityController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ActivityController类属于org.robolectric.android.controller包,在下文中一共展示了ActivityController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: rxActivity_shouldCallback_onLowMemory

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void rxActivity_shouldCallback_onLowMemory() {
  ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
  RibActivity activity = activityController.setup().get();
  TestObserver<ActivityCallbackEvent> testSub = new TestObserver<>();
  activity
      .callbacks()
      .filter(
          new Predicate<ActivityCallbackEvent>() {
            @Override
            public boolean test(ActivityCallbackEvent activityEvent) throws Exception {
              return activityEvent.getType() == ActivityCallbackEvent.Type.LOW_MEMORY;
            }
          })
      .subscribe(testSub);

  activity.onLowMemory();

  testSub.assertValue(ActivityCallbackEvent.create(ActivityCallbackEvent.Type.LOW_MEMORY));
}
 
开发者ID:uber,项目名称:RIBs,代码行数:21,代码来源:RibActivityTest.java


示例5: ribActivity_onSaveInstanceStateAndCallbackFlagEnabled_shouldEmitToCallbacks

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void ribActivity_onSaveInstanceStateAndCallbackFlagEnabled_shouldEmitToCallbacks() {
  ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
  RibActivity activity = activityController.setup().get();
  TestObserver<ActivityCallbackEvent.SaveInstanceState> testSub = new TestObserver<>();
  activity.callbacks(ActivityCallbackEvent.SaveInstanceState.class).subscribe(testSub);

  android.os.Bundle state = new android.os.Bundle();
  state.putString("hello", "seattle");
  activity.onSaveInstanceState(state);

  testSub.assertValueCount(1);
  ActivityCallbackEvent.SaveInstanceState receivedEvent = testSub.values().get(0);
  assertThat(receivedEvent.getType()).isEqualTo(ActivityCallbackEvent.Type.SAVE_INSTANCE_STATE);
  assertThat(receivedEvent.getOutState()).isNotNull();
  assertThat(receivedEvent.getOutState().getString("hello")).isEqualTo("seattle");
}
 
开发者ID:uber,项目名称:RIBs,代码行数:18,代码来源:RibActivityTest.java


示例6: rxActivity_shouldCallback_onActivityResult

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void rxActivity_shouldCallback_onActivityResult() {
  ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
  RibActivity activity = activityController.setup().get();
  TestObserver<ActivityCallbackEvent.ActivityResult> testSub = new TestObserver<>();
  activity.callbacks(ActivityCallbackEvent.ActivityResult.class).subscribe(testSub);

  android.os.Bundle data = new android.os.Bundle();
  data.putString("hello", "seattle");
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.putExtras(data);
  int requestCode = 2;
  int resultCode = Activity.RESULT_OK;
  activity.onActivityResult(requestCode, resultCode, intent);

  testSub.assertValueCount(1);
  ActivityCallbackEvent.ActivityResult receivedEvent = testSub.values().get(0);
  assertThat(receivedEvent.getType()).isEqualTo(ActivityCallbackEvent.Type.ACTIVITY_RESULT);
  assertThat(receivedEvent.getRequestCode()).isEqualTo(requestCode);
  assertThat(receivedEvent.getResultCode()).isEqualTo(resultCode);
  assertThat(receivedEvent.getData()).isNotNull();
  assertThat(receivedEvent.getData().getExtras()).isNotNull();
  assertThat(receivedEvent.getData().getExtras().getString("hello")).isEqualTo("seattle");
}
 
开发者ID:uber,项目名称:RIBs,代码行数:25,代码来源:RibActivityTest.java


示例7: startWithoutTitle

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithoutTitle()
{
    Intent intent = new Intent();

    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PictureViewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:18,代码来源:PictureViewActivityTest.java


示例8: startWithFile

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
private ActivityController startWithFile(File file) throws IOException
{
    Intent intent = new Intent();

    final Bundle bundle = new Bundle();
    bundle.putString("file", file.getAbsolutePath());
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PictureViewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing() == false);

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNull(latestToast);

    return controller;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:22,代码来源:PictureViewActivityTest.java


示例9: clickBackFinishes

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void clickBackFinishes() throws IOException
{
    File file = new File(Environment.getExternalStorageDirectory(), "test.jpg");
    file.createNewFile();

    ActivityController controller = startWithFile(file);
    Activity activity = (Activity)controller.get();
    ShadowActivity shadowActivity = shadowOf(activity);

    assertTrue(shadowActivity.isFinishing() == false);
    shadowActivity.clickMenuItem(android.R.id.home);
    assertTrue(shadowActivity.isFinishing());

    // Check that can finish out the lifecycle
    controller.pause();
    controller.stop();
    controller.destroy();

    // The done menu item was not clicked, so the result should be that
    // the activity was canceled
    assertEquals(Activity.RESULT_CANCELED, shadowActivity.getResultCode());
    assertNull(shadowActivity.getResultIntent());
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:25,代码来源:PictureViewActivityTest.java


示例10: doneNoItems

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void doneNoItems()
{
    HashMap<String, Integer> emptyMap = new HashMap<>();
    ActivityController controller = startWithMap(emptyMap);
    Activity activity = (Activity)controller.get();
    ShadowActivity shadowActivity = shadowOf(activity);

    assertTrue(shadowActivity.isFinishing() == false);
    shadowActivity.clickMenuItem(R.id.action_done);
    assertTrue(shadowActivity.isFinishing());

    // Check that can finish out the lifecycle
    controller.pause();
    controller.stop();
    controller.destroy();

    checkReturnedMap(activity, emptyMap);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:ItemizationActivityTest.java


示例11: startWithoutProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyOverviewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:19,代码来源:PropertyOverviewActivityTest.java


示例12: startWithMissingProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyOverviewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:PropertyOverviewActivityTest.java


示例13: checkOpenActivity

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
private void checkOpenActivity(int viewId, String nextActivity)
{
    ActivityController controller = startWithProperty(new Property());
    Activity activity = (Activity)controller.get();

    View propertyView = activity.findViewById(viewId);
    propertyView.performClick();

    assertTrue(activity.isFinishing() == false);
    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals(nextActivity, name);

    Bundle extras = next.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("id"));
    long id = extras.getLong("id", -1);
    assertEquals(DatabaseTestHelper.FIRST_ID, id);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:22,代码来源:PropertyOverviewActivityTest.java


示例14: clickBackFinishes

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void clickBackFinishes()
{
    ActivityController controller = startWithProperty(new Property());
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();

    assertTrue(shadowOf(activity).isFinishing() == false);
    shadowOf(activity).clickMenuItem(android.R.id.home);
    assertTrue(shadowOf(activity).isFinishing());

    // Check that can finish out the lifecycle
    controller.pause();
    controller.stop();
    controller.destroy();
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:PropertySummaryActivityTest.java


示例15: startWithMissingProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertySummaryActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:PropertySummaryActivityTest.java


示例16: startWithProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
private ActivityController startWithProperty(Property property)
{
    long id = db.insertProperty(property);

    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", id);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertySummaryActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing() == false);

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNull(latestToast);

    return controller;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:23,代码来源:PropertySummaryActivityTest.java


示例17: startWithProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
private ActivityController startWithProperty(Property property)
{
    long id = db.insertProperty(property);

    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", id);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyPicturesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing() == false);

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNull(latestToast);

    return controller;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:23,代码来源:PropertyPicturesActivityTest.java


示例18: startWithoutProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyPicturesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:17,代码来源:PropertyPicturesActivityTest.java


示例19: startWithMissingProperty

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyPicturesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:18,代码来源:PropertyPicturesActivityTest.java


示例20: clickAddLaunchesActivity

import org.robolectric.android.controller.ActivityController; //导入依赖的package包/类
@Test
public void clickAddLaunchesActivity()
{
    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();

    shadowOf(activity).clickMenuItem(R.id.action_add);
    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.PropertyViewActivity", name);

    Bundle extras = next.getExtras();
    assertNull(extras);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:23,代码来源:PropertiesListActivityTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuiYesNo类代码示例发布时间:2022-05-21
下一篇:
Java IOUtils类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap