Merge "Fix CtsNetTestCases in instant mode" am: 81be2bd036

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1753823

Change-Id: I84ec31354974c4913d6c4ac94a955054697180ff
This commit is contained in:
Remi NGUYEN VAN
2021-07-02 04:19:02 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ import android.os.BatteryStatsManager;
import android.os.Build; import android.os.Build;
import android.os.connectivity.CellularBatteryStats; import android.os.connectivity.CellularBatteryStats;
import android.os.connectivity.WifiBatteryStats; import android.os.connectivity.WifiBatteryStats;
import android.platform.test.annotations.AppModeFull;
import android.util.Log; import android.util.Log;
import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4;
@@ -80,6 +81,7 @@ public class BatteryStatsManagerTest{
} }
@Test @Test
@AppModeFull(reason = "Cannot get CHANGE_NETWORK_STATE to request wifi/cell in instant mode")
@SkipPresubmit(reason = "Virtual hardware does not support wifi battery stats") @SkipPresubmit(reason = "Virtual hardware does not support wifi battery stats")
public void testReportNetworkInterfaceForTransports() throws Exception { public void testReportNetworkInterfaceForTransports() throws Exception {
try { try {
@@ -132,6 +134,7 @@ public class BatteryStatsManagerTest{
} }
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R) @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
@Test @Test
public void testReportNetworkInterfaceForTransports_throwsSecurityException() public void testReportNetworkInterfaceForTransports_throwsSecurityException()
throws Exception { throws Exception {

View File

@@ -101,6 +101,7 @@ import com.android.testutils.RecorderCallback.CallbackEntry.Lost
import com.android.testutils.TestableNetworkCallback import com.android.testutils.TestableNetworkCallback
import org.junit.After import org.junit.After
import org.junit.Assert.assertArrayEquals import org.junit.Assert.assertArrayEquals
import org.junit.Assume.assumeFalse
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -1034,6 +1035,9 @@ class NetworkAgentTest {
@Test @Test
fun testQosCallbackRegisterWithUnregister() { fun testQosCallbackRegisterWithUnregister() {
// Instant apps can't bind sockets to localhost
// TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting() val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback() val qosCallback = TestableQosCallback()
@@ -1060,6 +1064,9 @@ class NetworkAgentTest {
@Test @Test
fun testQosCallbackOnQosSession() { fun testQosCallbackOnQosSession() {
// Instant apps can't bind sockets to localhost
// TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting() val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback() val qosCallback = TestableQosCallback()
Executors.newSingleThreadExecutor().let { executor -> Executors.newSingleThreadExecutor().let { executor ->
@@ -1104,6 +1111,9 @@ class NetworkAgentTest {
@Test @Test
fun testQosCallbackOnError() { fun testQosCallbackOnError() {
// Instant apps can't bind sockets to localhost
// TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting() val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback() val qosCallback = TestableQosCallback()
Executors.newSingleThreadExecutor().let { executor -> Executors.newSingleThreadExecutor().let { executor ->
@@ -1142,6 +1152,9 @@ class NetworkAgentTest {
@Test @Test
fun testQosCallbackIdsAreMappedCorrectly() { fun testQosCallbackIdsAreMappedCorrectly() {
// Instant apps can't bind sockets to localhost
// TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting() val (agent, socket) = setupForQosCallbackTesting()
val qosCallback1 = TestableQosCallback() val qosCallback1 = TestableQosCallback()
val qosCallback2 = TestableQosCallback() val qosCallback2 = TestableQosCallback()
@@ -1182,6 +1195,9 @@ class NetworkAgentTest {
@Test @Test
fun testQosCallbackWhenNetworkReleased() { fun testQosCallbackWhenNetworkReleased() {
// Instant apps can't bind sockets to localhost
// TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting() val (agent, socket) = setupForQosCallbackTesting()
Executors.newSingleThreadExecutor().let { executor -> Executors.newSingleThreadExecutor().let { executor ->
try { try {

View File

@@ -35,6 +35,7 @@ import android.net.Proxy;
import android.net.ProxyInfo; import android.net.ProxyInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.platform.test.annotations.AppModeFull;
import android.util.Log; import android.util.Log;
import android.util.Range; import android.util.Range;
@@ -145,6 +146,7 @@ public final class PacProxyManagerTest {
} }
} }
@AppModeFull(reason = "Instant apps can't bind sockets to localhost for a test proxy server")
@Test @Test
public void testSetCurrentProxyScriptUrl() throws Exception { public void testSetCurrentProxyScriptUrl() throws Exception {
// Register a PacProxyInstalledListener // Register a PacProxyInstalledListener