コード例 #1
0
ファイル: DispatcherTest.java プロジェクト: JayH5/picasso
 @Test
 public void nullExtrasOnReceiveAirplaneDoesNothing() {
   Dispatcher dispatcher = mock(Dispatcher.class);
   NetworkBroadcastReceiver receiver = new NetworkBroadcastReceiver(dispatcher);
   receiver.onReceive(context, new Intent(ACTION_AIRPLANE_MODE_CHANGED));
   verifyZeroInteractions(dispatcher);
 }
コード例 #2
0
ファイル: DispatcherTest.java プロジェクト: JayH5/picasso
 @Test
 public void nullIntentOnReceiveDoesNothing() {
   Dispatcher dispatcher = mock(Dispatcher.class);
   NetworkBroadcastReceiver receiver = new NetworkBroadcastReceiver(dispatcher);
   receiver.onReceive(context, null);
   verifyZeroInteractions(dispatcher);
 }
コード例 #3
0
ファイル: DispatcherTest.java プロジェクト: JayH5/picasso
 private void setAndVerifyAirplaneMode(boolean airplaneOn) {
   Dispatcher dispatcher = mock(Dispatcher.class);
   NetworkBroadcastReceiver receiver = new NetworkBroadcastReceiver(dispatcher);
   final Intent intent = new Intent(ACTION_AIRPLANE_MODE_CHANGED);
   intent.putExtra(EXTRA_AIRPLANE_STATE, airplaneOn);
   receiver.onReceive(context, intent);
   verify(dispatcher).dispatchAirplaneModeChange(airplaneOn);
 }
コード例 #4
0
ファイル: DispatcherTest.java プロジェクト: JayH5/picasso
 @Test
 public void nullExtrasOnReceiveConnectivityAreOk() {
   ConnectivityManager connectivityManager = mock(ConnectivityManager.class);
   NetworkInfo networkInfo = mockNetworkInfo();
   when(connectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo);
   when(context.getSystemService(CONNECTIVITY_SERVICE)).thenReturn(connectivityManager);
   Dispatcher dispatcher = mock(Dispatcher.class);
   NetworkBroadcastReceiver receiver = new NetworkBroadcastReceiver(dispatcher);
   receiver.onReceive(context, new Intent(CONNECTIVITY_ACTION));
   verify(dispatcher).dispatchNetworkStateChange(networkInfo);
 }