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


Java ActivityController.pause方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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,代码来源:PropertyOverviewActivityTest.java

示例4: startWithPropertyNotItemizeChangeValues

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithPropertyNotItemizeChangeValues() throws Exception
{
    Property property = new Property();
    preloadProperty(property);

    ActivityController controller = startWithProperty(property);
    Activity activity = (Activity)controller.get();

    checkFields(activity, property);

    property = new Property();
    setFields(activity, property);

    // Check that the values are still valid after a pause and resume.
    controller.pause();
    controller.resume();

    checkFields(activity, property);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:21,代码来源:PropertyWorksheetActivityTest.java

示例5: checkOpenActivity

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
private void checkOpenActivity(ActivityController controller, int viewId, HashMap<String, Integer> items)
{
    Activity activity = (Activity)controller.get();
    activity.findViewById(viewId).performClick();

    assertTrue(activity.isFinishing() == false);

    ShadowActivity.IntentForResult next = shadowOf(activity).getNextStartedActivityForResult();

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

    Bundle extras = next.intent.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("title"));
    assertTrue(extras.getInt("title") > 0);
    assertTrue(extras.containsKey("description"));
    assertTrue(extras.getInt("description") > 0);
    assertTrue(extras.containsKey("items"));
    assertEquals(items, extras.getSerializable("items"));

    // As the next activity is started, this activity is paused
    controller.pause();
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:26,代码来源:PropertyWorksheetActivityTest.java

示例6: clickBackFinishes

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void clickBackFinishes()
{
    ActivityController controller = startWithMap(new HashMap<String, Integer>());
    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,代码行数:22,代码来源:ItemizationActivityTest.java

示例7: 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

示例8: startWithPropertyChangeValues

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithPropertyChangeValues() throws Exception
{
    Property property = new Property();
    preloadProperty(property);

    ActivityController controller = startWithProperty(property);
    Activity activity = (Activity)controller.get();

    checkFields(activity, property);

    property = new Property();
    setFields(activity, property);

    // Check that the values are still valid after a pause and resume.
    controller.pause();
    controller.resume();

    checkFields(activity, property);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:21,代码来源:PropertyViewActivityTest.java

示例9: clickBackFinishes

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void clickBackFinishes()
{
    ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class).create();
    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,代码来源:PropertyViewActivityTest.java

示例10: removesLocationUpdatesInOnStop

import org.robolectric.android.controller.ActivityController; //导入方法依赖的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: clickBackFinishes

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

    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,代码行数:16,代码来源:PropertyPicturesActivityTest.java

示例12: clickBackFinishes

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void clickBackFinishes()
{
    ActivityController controller = startWithRequest(new DictionaryItem(R.string.addressTitle, R.string.addressTitle));
    Activity activity = (Activity)controller.get();

    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,代码行数:16,代码来源:DictionaryActivityTest.java

示例13: clickBackFinishes

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

    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,代码行数:16,代码来源:PropertyNotesActivityTest.java

示例14: doneBlankItem

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

    ListView list = (ListView)activity.findViewById(R.id.list);
    assertNotNull(list);

    ShadowListView shadowList = shadowOf(list);
    shadowList.populateItems();

    assertEquals(0, list.getCount());
    shadowActivity.clickMenuItem(R.id.action_add);
    assertEquals(1, list.getCount());

    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,代码行数:30,代码来源:ItemizationActivityTest.java

示例15: filledOutItemsNotSaved

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

    Map<String, Integer> addedValues = ImmutableMap.of
    (
        "test name", 12345
    );

    addItems(activity, addedValues);

    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,代码行数:30,代码来源:ItemizationActivityTest.java


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