本文整理汇总了Java中org.robolectric.Robolectric类的典型用法代码示例。如果您正苦于以下问题:Java Robolectric类的具体用法?Java Robolectric怎么用?Java Robolectric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Robolectric类属于org.robolectric包,在下文中一共展示了Robolectric类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWindowsFocusChanged
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testWindowsFocusChanged() throws Exception {
BaseChromiumApplication app = (BaseChromiumApplication) Robolectric.application;
WindowFocusChangedListener mock = mock(WindowFocusChangedListener.class);
app.registerWindowFocusChangedListener(mock);
ActivityController<Activity> controller =
Robolectric.buildActivity(Activity.class).create().start().visible();
TrackingShadowActivity shadow =
(TrackingShadowActivity) Robolectric.shadowOf(controller.get());
controller.get().getWindow().getCallback().onWindowFocusChanged(true);
// Assert that listeners were notified.
verify(mock).onWindowFocusChanged(controller.get(), true);
// Also ensure that the original activity is forwarded the notification.
Assert.assertEquals(1, shadow.mWindowFocusCalls);
}
示例2: startWithMissingProperty
import org.robolectric.Robolectric; //导入依赖的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);
}
示例3: startWithoutProperty
import org.robolectric.Robolectric; //导入依赖的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);
}
示例4: testBindActivity
import org.robolectric.Robolectric; //导入依赖的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);
}
示例5: setUp
import org.robolectric.Robolectric; //导入依赖的package包/类
@Before public void setUp() throws Exception {
activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
timeZone = TimeZone.getTimeZone("GMT+06:00");
locale = Locale.US;
view = new CalendarPickerView(activity, null);
today = Calendar.getInstance(timeZone, locale);
today.set(2012, NOVEMBER, 16, 0, 0);
minDate = today.getTime();
today.set(2013, NOVEMBER, 16, 0, 0);
maxDate = today.getTime();
today.set(2012, NOVEMBER, 16, 0, 0);
Date startDate = today.getTime();
view.init(minDate, maxDate, timeZone, locale) //
.inMode(SINGLE) //
.withSelectedDate(startDate);
// Do not change the internal state of the CalendarPickerView until init() has run.
view.today.setTime(startDate);
}
示例6: setUp
import org.robolectric.Robolectric; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Context context = ShadowApplication.getInstance().getApplicationContext();
Robolectric.getBackgroundThreadScheduler().pause();
recipientMvpView = mock(RecipientMvpView.class);
account = mock(Account.class);
composePgpInlineDecider = mock(ComposePgpInlineDecider.class);
composePgpEnableByDefaultDecider = mock(ComposePgpEnableByDefaultDecider.class);
autocryptStatusInteractor = mock(AutocryptStatusInteractor.class);
replyToParser = mock(ReplyToParser.class);
LoaderManager loaderManager = mock(LoaderManager.class);
listener = mock(RecipientPresenter.RecipientsChangedListener.class);
recipientPresenter = new RecipientPresenter(
context, loaderManager, recipientMvpView, account, composePgpInlineDecider,
composePgpEnableByDefaultDecider, autocryptStatusInteractor, replyToParser, listener);
runBackgroundTask();
noRecipientsAutocryptResult = new RecipientAutocryptStatus(RecipientAutocryptStatusType.NO_RECIPIENTS, null);
}
示例7: setUp
import org.robolectric.Robolectric; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
RecipeMainActivity recipeMainActivity = new RecipeMainActivity() {
public ImageLoader getImageLoader() {
return imageLoader;
}
public RecipeMainPresenter getPresenter() {
return presenter;
}
};
controller = ActivityController.of(Robolectric.getShadowsAdapter(), recipeMainActivity).create().visible();
activity = controller.get();
view = (RecipeMainView) activity;
shadowAcivity = shadowOf(activity);
}
示例8: startWithProperty
import org.robolectric.Robolectric; //导入依赖的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(PropertyProjectionsActivity.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;
}
示例9: startWithoutProperty
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
Intent intent = new Intent();
final Bundle bundle = new Bundle();
intent.putExtras(bundle);
ActivityController controller = Robolectric.buildActivity(PropertyWorksheetActivity.class, intent).create();
Activity activity = (Activity)controller.get();
controller.start();
assertTrue(activity.isFinishing());
String latestToast = ShadowToast.getTextOfLatestToast();
assertNotNull(latestToast);
}
示例10: startWithMissingProperty
import org.robolectric.Robolectric; //导入依赖的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(PropertyProjectionsActivity.class, intent).create();
Activity activity = (Activity)controller.get();
controller.start();
controller.visible();
controller.resume();
assertTrue(activity.isFinishing());
String latestToast = ShadowToast.getTextOfLatestToast();
assertNotNull(latestToast);
}
示例11: testFirstRunStartsIntro
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testFirstRunStartsIntro()
{
prefs.edit().remove("firstrun").commit();
ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
Activity activity = (Activity)controller.get();
assertTrue(activity.isFinishing() == false);
Intent next = shadowOf(activity).getNextStartedActivity();
ComponentName componentName = next.getComponent();
String name = componentName.flattenToShortString();
assertEquals("protect.rentalcalc/.IntroActivity", name);
Bundle extras = next.getExtras();
assertNull(extras);
assertEquals(false, prefs.getBoolean("firstrun", true));
}
示例12: testSetResize
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetResize() throws Exception {
ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
mWXImage.mHost = imageView;
mWXImage.setResize("cover");
ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);
}
示例13: testSetResizeMode
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetResizeMode() throws Exception {
ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
mWXImage.mHost = imageView;
mWXImage.setResizeMode("cover");
ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);
}
示例14: startWithoutProperty
import org.robolectric.Robolectric; //导入依赖的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);
}
示例15: testSetImageBitmap
import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetImageBitmap(){
ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
imageView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
imageView.setImageBitmap(null);
assertNull(imageView.getDrawable());
imageView.setImageBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
assertNotNull(imageView.getDrawable());
}