Merge "Skip battery saver related tests on unsupported devices." into qt-dev am: f8eb2722ff

am: bec485ec90

Change-Id: I4423117a8636ce63431873f4f5edf0fe2832f97e
This commit is contained in:
Sudheer Shanka
2019-06-14 10:46:35 -07:00
committed by android-build-merger
4 changed files with 51 additions and 5 deletions

View File

@@ -150,6 +150,11 @@ abstract class AbstractAppIdleTestCase extends AbstractRestrictBackgroundNetwork
}
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) return;
// Check that app is paroled when charging

View File

@@ -16,6 +16,7 @@
package com.android.cts.net.hostside;
import android.text.TextUtils;
import android.util.Log;
/**
@@ -52,12 +53,19 @@ abstract class AbstractBatterySaverModeTestCase extends AbstractRestrictBackgrou
@Override
protected boolean isSupported() throws Exception {
boolean supported = isDozeModeEnabled();
if (!supported) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Doze Mode");
String unSupported = "";
if (!isDozeModeEnabled()) {
unSupported += "Doze mode,";
}
return supported;
if (!isBatterySaverSupported()) {
unSupported += "Battery saver mode,";
}
if (!TextUtils.isEmpty(unSupported)) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support " + unSupported);
return false;
}
return true;
}
/**

View File

@@ -34,6 +34,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
@@ -43,12 +44,15 @@ import android.os.BatteryManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.test.InstrumentationTestCase;
import android.text.TextUtils;
import android.util.Log;
import com.android.compatibility.common.util.BatteryUtils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -311,6 +315,10 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
return mSupported;
}
protected boolean isBatterySaverSupported() {
return BatteryUtils.isBatterySaverSupported();
}
/**
* Asserts that an app always have access while on foreground or running a foreground service.
*

View File

@@ -71,6 +71,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
* Tests all DS ON and BS ON scenarios from network-policy-restrictions.md on metered networks.
*/
public void testDataAndBatterySaverModes_meteredNetwork() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) return;
Log.i(TAG, "testDataAndBatterySaverModes_meteredNetwork() tests");
@@ -141,6 +146,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
* networks.
*/
public void testDataAndBatterySaverModes_nonMeteredNetwork() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) return;
if (!setUnmeteredNetwork()) {
@@ -206,6 +216,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
* are enabled.
*/
public void testDozeAndBatterySaverMode_powerSaveWhitelists() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) {
return;
}
@@ -285,6 +300,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
}
public void testAppIdleAndBatterySaver_tempPowerSaveWhitelists() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) {
return;
}
@@ -361,6 +381,11 @@ public class MixedModesTest extends AbstractRestrictBackgroundNetworkTestCase {
}
public void testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists() throws Exception {
if (!isBatterySaverSupported()) {
Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ "() because device does not support Battery saver mode");
return;
}
if (!isSupported()) {
return;
}