Merge "Add test for ConnectivityManager.setGlobalProxy()"

This commit is contained in:
Chiachang Wang
2021-05-13 09:30:25 +00:00
committed by Gerrit Code Review

View File

@@ -102,6 +102,7 @@ import android.net.NetworkInfo.DetailedState;
import android.net.NetworkInfo.State;
import android.net.NetworkRequest;
import android.net.NetworkUtils;
import android.net.ProxyInfo;
import android.net.SocketKeepalive;
import android.net.TestNetworkInterface;
import android.net.TestNetworkManager;
@@ -1912,4 +1913,12 @@ public class ConnectivityManagerTest {
assertNull(NetworkInformationShimImpl.newInstance()
.getCapabilityCarrierName(ConstantsShim.NET_CAPABILITY_NOT_VCN_MANAGED));
}
@Test
public void testSetGlobalProxy() {
assumeTrue(TestUtils.shouldTestSApis());
// Behavior is verified in gts. Verify exception thrown w/o permission.
assertThrows(SecurityException.class, () -> mCm.setGlobalProxy(
ProxyInfo.buildDirectProxy("example.com" /* host */, 8080 /* port */)));
}
}