Merge "cts: Re-launch the desired activity after screen-on on TVs."
This commit is contained in:
commit
422c7dd460
2 changed files with 13 additions and 2 deletions
|
|
@ -881,6 +881,11 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected void startActivity() throws Exception {
|
||||
final Intent launchIntent = getIntentForComponent(TYPE_COMPONENT_ACTIVTIY);
|
||||
mContext.startActivity(launchIntent);
|
||||
}
|
||||
|
||||
private void startForegroundService() throws Exception {
|
||||
final Intent launchIntent = getIntentForComponent(TYPE_COMPONENT_FOREGROUND_SERVICE);
|
||||
mContext.startForegroundService(launchIntent);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLE
|
|||
import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED;
|
||||
import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED;
|
||||
|
||||
import static com.android.compatibility.common.util.FeatureUtil.isTV;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.setRestrictBackground;
|
||||
import static com.android.cts.net.hostside.Property.DATA_SAVER_MODE;
|
||||
import static com.android.cts.net.hostside.Property.METERED_NETWORK;
|
||||
|
|
@ -27,14 +28,14 @@ import static com.android.cts.net.hostside.Property.NO_DATA_SAVER_MODE;
|
|||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
import com.android.compatibility.common.util.CddTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
@RequiredProperties({DATA_SAVER_MODE, METERED_NETWORK})
|
||||
@LargeTest
|
||||
public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase {
|
||||
|
|
@ -113,6 +114,11 @@ public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase
|
|||
turnScreenOff();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnScreenOn();
|
||||
// On some TVs, it is possible that the activity on top may change after the screen is
|
||||
// turned off and on again, so relaunch the activity in the test app again.
|
||||
if (isTV()) {
|
||||
startActivity();
|
||||
}
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
// Goes back to background state.
|
||||
|
|
|
|||
Loading…
Reference in a new issue