Code example for NetworkInfo

Methods: getDetailedState

0
    public void getNetworkInfoShouldReturnAssignedValue() throws Exception { 
        NetworkInfo networkInfo = ShadowNetworkInfo.newInstance(NetworkInfo.DetailedState.CONNECTING);
        shadowConnectivityManager.setNetworkInfo(ConnectivityManager.TYPE_WIFI, networkInfo);
        NetworkInfo actual = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        assertThat(actual).isSameAs(networkInfo);
        assertThat(actual.getDetailedState()).isEqualTo(NetworkInfo.DetailedState.CONNECTING);
    } 
 
    @Test 
    public void networkInfoShouldReturnFalseCorrectly() { 
        shadowOfActiveNetworkInfo.setConnectionStatus(false);
 
        assertFalse(connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting());
        assertFalse(connectivityManager.getActiveNetworkInfo().isConnected());
    } 
 
    @Test 
    public void networkInfoShouldReturnTypeCorrectly(){ 
    	shadowOfActiveNetworkInfo.setConnectionType(ConnectivityManager.TYPE_MOBILE);
    	assertEquals(ConnectivityManager.TYPE_MOBILE, shadowOfActiveNetworkInfo.getType());