本文整理汇总了Java中org.robolectric.android.controller.ActivityController.stop方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityController.stop方法的具体用法?Java ActivityController.stop怎么用?Java ActivityController.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.android.controller.ActivityController
的用法示例。
在下文中一共展示了ActivityController.stop方法的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();
}
示例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());
}
示例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();
}
示例4: 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());
}
示例5: 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);
}
示例6: 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();
}
示例7: 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);
}
示例8: 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();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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);
}
示例12: 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());
}
示例13: 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);
}
示例14: 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);
}
示例15: startWithItemsClickedDone
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithItemsClickedDone()
{
Map<String, Integer> initialValues = ImmutableMap.of
(
"test name", 12345,
"test name 2", 44444,
"test name 3", 75412,
"test name 4", 951,
"test name 5", 1
);
ActivityController controller = startWithMap(initialValues);
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, initialValues);
}