Search in sources :

Example 1 with NetworkBroadcastReceiver

use of com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver in project picasso by square.

the class DispatcherTest method nullExtrasOnReceiveConnectivityAreOk.

@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);
}
Also used : NetworkInfo(android.net.NetworkInfo) TestUtils.mockNetworkInfo(com.squareup.picasso.TestUtils.mockNetworkInfo) ConnectivityManager(android.net.ConnectivityManager) Intent(android.content.Intent) NetworkBroadcastReceiver(com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver) Test(org.junit.Test)

Example 2 with NetworkBroadcastReceiver

use of com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver in project picasso by square.

the class DispatcherTest method setAndVerifyAirplaneMode.

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);
}
Also used : Intent(android.content.Intent) NetworkBroadcastReceiver(com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver)

Example 3 with NetworkBroadcastReceiver

use of com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver in project picasso by square.

the class DispatcherTest method nullExtrasOnReceiveAirplaneDoesNothing.

@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);
}
Also used : Intent(android.content.Intent) NetworkBroadcastReceiver(com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver) Test(org.junit.Test)

Example 4 with NetworkBroadcastReceiver

use of com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver in project picasso by square.

the class DispatcherTest method nullIntentOnReceiveDoesNothing.

@Test
public void nullIntentOnReceiveDoesNothing() {
    Dispatcher dispatcher = mock(Dispatcher.class);
    NetworkBroadcastReceiver receiver = new NetworkBroadcastReceiver(dispatcher);
    receiver.onReceive(context, null);
    verifyZeroInteractions(dispatcher);
}
Also used : NetworkBroadcastReceiver(com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver) Test(org.junit.Test)

Aggregations

NetworkBroadcastReceiver (com.squareup.picasso.Dispatcher.NetworkBroadcastReceiver)4 Intent (android.content.Intent)3 Test (org.junit.Test)3 ConnectivityManager (android.net.ConnectivityManager)1 NetworkInfo (android.net.NetworkInfo)1 TestUtils.mockNetworkInfo (com.squareup.picasso.TestUtils.mockNetworkInfo)1