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


Java ActivityController.destroy方法代码示例

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


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

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

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

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

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

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

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

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

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

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

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

示例14: filledOutItemsClickedDone

import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void filledOutItemsClickedDone()
{
    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,
        "test name 2", 44444,
        "test name 3", 75412,
        "test name 4", 951,
        "test name 5", 1
    );

    addItems(activity, addedValues);

    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, addedValues);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:31,代码来源:ItemizationActivityTest.java

示例15: filledOutItemsWithDuplicatesClickedDone

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

    final String TEST_NAME = "test name";
    final int TEST_VALUE = 12345;

    for(int index = 0; index < 10; index++)
    {
        addItem(activity, TEST_NAME, TEST_VALUE);
    }

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

    controller.pause();
    controller.stop();
    controller.destroy();

    // As all the items were duplicates, only one item
    // should result.
    Map<String, Integer> expectedValues = ImmutableMap.of
    (
        TEST_NAME, TEST_VALUE
    );

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


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