use of org.robolectric.annotation.LooperMode in project robolectric by robolectric.
the class ShadowContextWrapperTest method sendBroadcast_shouldSendIntentUsingHandlerIfOneIsProvided_legacy.
@Test
@LooperMode(LEGACY)
public void sendBroadcast_shouldSendIntentUsingHandlerIfOneIsProvided_legacy() {
HandlerThread handlerThread = new HandlerThread("test");
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());
assertNotSame(handler.getLooper(), Looper.getMainLooper());
BroadcastReceiver receiver = broadcastReceiver("Larry");
contextWrapper.registerReceiver(receiver, intentFilter("foo", "baz"), null, handler);
assertThat(shadowOf(handler.getLooper()).getScheduler().size()).isEqualTo(0);
contextWrapper.sendBroadcast(new Intent("foo"));
assertThat(shadowOf(handler.getLooper()).getScheduler().size()).isEqualTo(1);
shadowOf(handlerThread.getLooper()).idle();
assertThat(shadowOf(handler.getLooper()).getScheduler().size()).isEqualTo(0);
asyncAssertThat(transcript).containsExactly("Larry notified of foo");
}
use of org.robolectric.annotation.LooperMode in project materialistic by hidroh.
the class NavFloatingActionButtonTest method testKonami.
@LooperMode(LooperMode.Mode.LEGACY)
@Test
public void testKonami() {
// down, invalid, should ignore
gestureListener.onFling(null, null, 0f, 1f);
// up
gestureListener.onFling(null, null, 0f, -1f);
// down, invalid, should reset
gestureListener.onFling(null, null, 0f, 1f);
// up
gestureListener.onFling(null, null, 0f, -1f);
// up
gestureListener.onFling(null, null, 0f, -1f);
// down
gestureListener.onFling(null, null, 0f, 1f);
// down
gestureListener.onFling(null, null, 0f, 1f);
// left
gestureListener.onFling(null, null, -1f, 0f);
// right
gestureListener.onFling(null, null, 1f, 0f);
// left
gestureListener.onFling(null, null, -1f, 0f);
// right
gestureListener.onFling(null, null, 1f, 0f);
gestureListener.onDoubleTap(null);
Dialog dialog = ShadowDialog.getLatestDialog();
assertNotNull(dialog);
// BUTTON_POSITIVE
shadowOf(dialog).clickOn(android.R.id.button1);
assertThat(shadowOf(RuntimeEnvironment.application).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
use of org.robolectric.annotation.LooperMode in project prebid-mobile-android by prebid.
the class InterstitialManagerTest method displayViewAsInterstitialSuccess_ShowInterstitialAdView.
@Test
@LooperMode(LooperMode.Mode.PAUSED)
public void displayViewAsInterstitialSuccess_ShowInterstitialAdView() {
VideoCreative mockVideoCreative = mock(VideoCreative.class);
when(mockVideoCreative.isResolved()).thenReturn(true);
BaseJSInterface mockJsInterface = mock(BaseJSInterface.class);
when(mockJsInterface.getJsExecutor()).thenReturn(mock(JsExecutor.class));
WebViewBase mockWebViewBase = mock(WebViewBase.class);
when(mockWebViewBase.getMRAIDInterface()).thenReturn(mockJsInterface);
PrebidWebViewInterstitial mockPrebidWebViewInterstitial = mock(PrebidWebViewInterstitial.class);
when(mockPrebidWebViewInterstitial.getWebView()).thenReturn(mockWebViewBase);
InterstitialView mockInterstitialView = mock(InterstitialView.class);
when(mockInterstitialView.getCreativeView()).thenReturn(mockPrebidWebViewInterstitial);
mSpyInterstitialManager.displayAdViewInInterstitial(mContext, mockInterstitialView);
verify(mMockAdViewDelegate).showInterstitial();
}
Aggregations