LocationReceiverTest.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:mapbox-events-android 作者:
@Test
public void checksSendEventNotCalledWhenAltitudeNaN() throws Exception {
  Context mockedContext = mock(Context.class);
  Intent mockedIntent = mock(Intent.class);
  when(mockedIntent.getStringExtra(eq("location_received"))).thenReturn("onLocation");
  Bundle mockedBundle = mock(Bundle.class);
  when(mockedIntent.getExtras()).thenReturn(mockedBundle);
  Location mockedLocation = mock(Location.class);
  when(mockedBundle.get(eq(LocationManager.KEY_LOCATION_CHANGED))).thenReturn(mockedLocation);
  when(mockedLocation.getAltitude()).thenReturn(Double.NaN);
  EventSender mockedEventSender = mock(EventSender.class);
  LocationReceiver theLocationReceiver = new LocationReceiver(mockedEventSender);

  theLocationReceiver.onReceive(mockedContext, mockedIntent);

  verify(mockedEventSender, never()).send(any(LocationEvent.class));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号