本文整理匯總了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());
}