1 package com.xtremelabs.robolectric.shadows; 2 3 import android.net.NetworkInfo; 4 import com.xtremelabs.robolectric.Robolectric; 5 import com.xtremelabs.robolectric.WithTestDefaultsRunner; 6 import org.junit.Test; 7 import org.junit.runner.RunWith; 8 9 import static com.xtremelabs.robolectric.Robolectric.shadowOf; 10 import static org.hamcrest.CoreMatchers.equalTo; 11 import static org.hamcrest.MatcherAssert.assertThat; 12 13 @RunWith(WithTestDefaultsRunner.class) 14 public class NetworkInfoTest { 15 16 @Test 17 public void getDetailedState_shouldReturnTheAssignedState() throws Exception { 18 NetworkInfo networkInfo = Robolectric.newInstanceOf(NetworkInfo.class); 19 shadowOf(networkInfo).setDetailedState(NetworkInfo.DetailedState.SCANNING); 20 assertThat(networkInfo.getDetailedState(), equalTo(NetworkInfo.DetailedState.SCANNING)); 21 } 22 } 23