@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); }
void dispatchNetworkStateChange(NetworkInfo info) { handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info)); }
Dispatcher { void dispatchNetworkStateChange(NetworkInfo info) { handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info)); } }
Dispatcher { void dispatchNetworkStateChange(NetworkInfo info) { handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info)); } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats); }
Dispatcher { void dispatchNetworkStateChange(NetworkInfo info) { handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info)); } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats);  }
Dispatcher { void dispatchNetworkStateChange(NetworkInfo info) { handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info)); } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats);   }