本文整理汇总了Java中org.robolectric.android.controller.ActivityController.get方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityController.get方法的具体用法?Java ActivityController.get怎么用?Java ActivityController.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.android.controller.ActivityController
的用法示例。
在下文中一共展示了ActivityController.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: startWithRequest
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
private ActivityController startWithRequest(DictionaryItem item)
{
Intent intent = new Intent();
final Bundle bundle = new Bundle();
bundle.putInt("title", item.titleId);
bundle.putInt("definition", item.definitionId);
if(item.formulaId != null)
{
bundle.putInt("formula", item.formulaId);
}
intent.putExtras(bundle);
ActivityController controller = Robolectric.buildActivity(DictionaryActivity.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;
}
示例3: 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);
}
示例4: updateNotes
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void updateNotes()
{
final String ORIGINAL_MESSAGE = "Multi\nLine\nMessage\n";
ActivityController controller = startWithNotes(ORIGINAL_MESSAGE);
Activity activity = (Activity)controller.get();
EditText notes = (EditText)activity.findViewById(R.id.notes);
final String NEW_MESSAGE = "This is the new message";
notes.setText(NEW_MESSAGE);
assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.action_save));
shadowOf(activity).clickMenuItem(R.id.action_save);
assertTrue(activity.isFinishing());
Property property = db.getProperty(DatabaseTestHelper.FIRST_ID);
assertNotNull(property);
assertEquals(NEW_MESSAGE, property.notes);
}
示例5: startWithMap
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
private ActivityController startWithMap(Map<String, Integer> map)
{
Intent intent = new Intent();
final Bundle bundle = new Bundle();
bundle.putInt("title", R.string.app_name);
bundle.putInt("description", R.string.app_name);
bundle.putSerializable("items", new HashMap<>(map));
intent.putExtras(bundle);
ActivityController controller = Robolectric.buildActivity(ItemizeActivity.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;
}
示例6: cancelDoesNotUpdateNotes
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void cancelDoesNotUpdateNotes()
{
final String ORIGINAL_MESSAGE = "Multi\nLine\nMessage\n";
ActivityController controller = startWithNotes(ORIGINAL_MESSAGE);
Activity activity = (Activity)controller.get();
EditText notes = (EditText)activity.findViewById(R.id.notes);
final String NEW_MESSAGE = "This is the new message";
notes.setText(NEW_MESSAGE);
shadowOf(activity).clickMenuItem(android.R.id.home);
assertTrue(activity.isFinishing());
Property property = db.getProperty(DatabaseTestHelper.FIRST_ID);
assertNotNull(property);
assertEquals(ORIGINAL_MESSAGE, property.notes);
}
示例7: startWithoutBundle
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithoutBundle()
{
ActivityController controller = Robolectric.buildActivity(PropertyProjectionsActivity.class).create();
Activity activity = (Activity)controller.get();
controller.start();
controller.visible();
controller.resume();
assertTrue(activity.isFinishing());
String latestToast = ShadowToast.getTextOfLatestToast();
assertNotNull(latestToast);
}
示例8: startWithNullNotes
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithNullNotes()
{
ActivityController controller = startWithNotes(null);
Activity activity = (Activity)controller.get();
EditText notes = (EditText)activity.findViewById(R.id.notes);
assertEquals("", notes.getText().toString());
}
示例9: startWithoutPropertyAndSave
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithoutPropertyAndSave() throws IllegalAccessException
{
Intent intent = new Intent();
final Bundle bundle = new Bundle();
intent.putExtras(bundle);
ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
Activity activity = (Activity)controller.get();
controller.start();
controller.visible();
controller.resume();
Property property = new Property();
preloadProperty(property);
setFields(activity, property);
assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.action_save));
shadowOf(activity).clickMenuItem(R.id.action_save);
assertTrue(activity.isFinishing());
Intent next = shadowOf(activity).getNextStartedActivity();
ComponentName componentName = next.getComponent();
String name = componentName.flattenToShortString();
assertEquals("protect.rentalcalc/.PropertyOverviewActivity", name);
Bundle nextBundle = next.getExtras();
assertNotNull(nextBundle);
assertTrue(nextBundle.containsKey("id"));
assertEquals(DatabaseTestHelper.FIRST_ID, nextBundle.getLong("id"));
Property updatedProperty = db.getProperty(DatabaseTestHelper.FIRST_ID);
compareRelevantPropertyFields(property, updatedProperty);
}
示例10: checkActionBar
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void checkActionBar() throws Exception
{
ActivityController controller = startWithProperty(new Property());
Activity activity = (Activity)controller.get();
final Menu menu = shadowOf(activity).getOptionsMenu();
assertNotNull(menu);
assertEquals(menu.size(), 1);
MenuItem item = menu.findItem(R.id.action_save);
assertNotNull(item);
assertEquals("Save", item.getTitle().toString());
}
示例11: mockPagerAdapterGetsInjected
import org.robolectric.android.controller.ActivityController; //导入方法依赖的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);
}
示例12: rxActivity_delaySubscription_shouldIgnoreOtherEvents
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void rxActivity_delaySubscription_shouldIgnoreOtherEvents() {
ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
final RibActivity activity = activityController.get();
final PublishSubject<Object> subject = PublishSubject.create();
AndroidRecordingRx2Observer<Object> o = new AndroidRecordingRx2Observer<>();
subject
.hide()
.delaySubscription(
activity
.lifecycle()
.filter(
new Predicate<ActivityLifecycleEvent>() {
@Override
public boolean test(ActivityLifecycleEvent activityEvent) throws Exception {
return activityEvent.getType() == ActivityLifecycleEvent.Type.RESUME;
}
}))
.subscribe(o);
subject.onNext(new Object());
activityController.create();
subject.onNext(new Object());
o.assertNoMoreEvents();
activityController.start();
subject.onNext(new Object());
o.assertNoMoreEvents();
activityController.postCreate(null);
subject.onNext(new Object());
o.assertNoMoreEvents();
activityController.resume();
subject.onNext(new Object());
assertThat(o.takeNext()).isNotNull();
o.assertNoMoreEvents();
}
示例13: startWithoutBundle
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithoutBundle()
{
ActivityController controller = Robolectric.buildActivity(PictureViewActivity.class).create();
Activity activity = (Activity)controller.get();
controller.start();
assertTrue(activity.isFinishing());
String latestToast = ShadowToast.getTextOfLatestToast();
assertNotNull(latestToast);
}
示例14: startWithPropertyWithItemizeCheckInitialLoad
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithPropertyWithItemizeCheckInitialLoad() throws Exception
{
Property property = new Property();
preloadPropertyWithItemize(property);
ActivityController controller = startWithProperty(property);
Activity activity = (Activity)controller.get();
checkFields(activity, property);
}
示例15: startWithoutBundle
import org.robolectric.android.controller.ActivityController; //导入方法依赖的package包/类
@Test
public void startWithoutBundle()
{
ActivityController controller = Robolectric.buildActivity(PropertyOverviewActivity.class).create();
Activity activity = (Activity)controller.get();
controller.start();
controller.visible();
controller.resume();
assertTrue(activity.isFinishing());
String latestToast = ShadowToast.getTextOfLatestToast();
assertNotNull(latestToast);
}