diff options
author | Tianjie Xu <xunchang@google.com> | 2022-02-10 19:01:23 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-02-10 19:01:23 +0000 |
commit | 9c2ae39ec8e34f45d369f60dac6fa813e90987ce (patch) | |
tree | cfeda201bb2cf8c2ba1e1976cf2ead25a01c186b | |
parent | 034d61e3cfa15220068df41d1f691ce453b18ba5 (diff) | |
parent | ea932a560c115735da9fea197c7ef0dbf63bef3b (diff) | |
download | cts-android-t-preview-1.tar.gz |
Merge "Switch all RoR CTS tests to server based"android-t-preview-2android-t-preview-1android-t-beta-3android-t-preview-1
-rw-r--r-- | hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java | 89 |
1 files changed, 13 insertions, 76 deletions
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java index db6124a02d3..be7ab002a62 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java @@ -86,6 +86,7 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { removeTestPackages(); deviceDisableDeviceConfigSync(); + deviceSetupServerBasedParameter(); } @After @@ -95,46 +96,8 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { } @Test - public void resumeOnReboot_SingleUser_Success() throws Exception { - if (!isSupportedDevice()) { - CLog.v(TAG, "Device not supported; skipping test"); - return; - } - - int[] users = Utils.prepareSingleUser(getDevice()); - int initialUser = users[0]; - - // Clean up the server based parameters for HAL based test. - deviceCleanupServerBasedParameter(); - - try { - installTestPackages(); - - deviceSetup(initialUser); - deviceRequestLskf(); - deviceLock(initialUser); - deviceEnterLskf(initialUser); - deviceRebootAndApply(); - - runDeviceTestsAsUser("testVerifyUnlockedAndDismiss", initialUser); - } finally { - try { - // Remove secure lock screens and tear down test app - runDeviceTestsAsUser("testTearDown", initialUser); - - deviceClearLskf(); - } finally { - removeTestPackages(); - } - } - } - - @Test public void resumeOnReboot_ManagedProfile_Success() throws Exception { - if (!isSupportedDevice()) { - CLog.v(TAG, "Device not supported; skipping test"); - return; - } + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); if (!getDevice().hasFeature("android.software.managed_users")) { CLog.v(TAG, "Device doesn't support managed users; skipping test"); @@ -146,8 +109,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { int managedUserId = createManagedProfile(initialUser); - deviceCleanupServerBasedParameter(); - try { // Set up test app and secure lock screens installTestPackages(); @@ -177,10 +138,7 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { @Test public void resumeOnReboot_TwoUsers_SingleUserUnlock_Success() throws Exception { - if (!isSupportedDevice()) { - CLog.v(TAG, "Device not supported; skipping test"); - return; - } + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); if (!mSupportsMultiUser) { CLog.v(TAG, "Device doesn't support multi-user; skipping test"); @@ -191,8 +149,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { int initialUser = users[0]; int secondaryUser = users[1]; - deviceCleanupServerBasedParameter(); - try { // Set up test app and secure lock screens installTestPackages(); @@ -234,10 +190,7 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { @Test public void resumeOnReboot_TwoUsers_BothUserUnlock_Success() throws Exception { - if (!isSupportedDevice()) { - CLog.v(TAG, "Device not supported; skipping test"); - return; - } + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); if (!mSupportsMultiUser) { CLog.v(TAG, "Device doesn't support multi-user; skipping test"); @@ -248,8 +201,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { int initialUser = users[0]; int secondaryUser = users[1]; - deviceCleanupServerBasedParameter(); - try { installTestPackages(); @@ -291,23 +242,13 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { } } - private boolean isSupportedSDevice() throws Exception { - // The following tests targets API level >= S. - boolean isAtleastS = ApiLevelUtil.isAfter(getDevice(), 30 /* BUILD.VERSION_CODES.R */) - || ApiLevelUtil.codenameEquals(getDevice(), "S"); - - return isAtleastS && getDevice().hasFeature(FEATURE_SECURE_LOCK_SCREEN); - } - @Test public void resumeOnReboot_SingleUser_ServerBased_Success() throws Exception { - assumeTrue("Device isn't at least S or have no lock screen", isSupportedSDevice()); + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); int[] users = Utils.prepareSingleUser(getDevice()); int initialUser = users[0]; - deviceSetupServerBasedParameter(); - try { installTestPackages(); @@ -327,7 +268,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { deviceClearLskf(); } finally { removeTestPackages(); - deviceCleanupServerBasedParameter(); getDevice().rebootUntilOnline(); getDevice().waitForDeviceAvailable(); @@ -337,13 +277,11 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { @Test public void resumeOnReboot_SingleUser_MultiClient_ClientASuccess() throws Exception { - assumeTrue("Device isn't at least S or have no lock screen", isSupportedSDevice()); + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); int[] users = Utils.prepareSingleUser(getDevice()); int initialUser = users[0]; - deviceSetupServerBasedParameter(); - final String clientA = "ClientA"; final String clientB = "ClientB"; try { @@ -370,7 +308,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { deviceClearLskf(); } finally { removeTestPackages(); - deviceCleanupServerBasedParameter(); getDevice().rebootUntilOnline(); getDevice().waitForDeviceAvailable(); @@ -380,13 +317,11 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { @Test public void resumeOnReboot_SingleUser_MultiClient_ClientBSuccess() throws Exception { - assumeTrue("Device isn't at least S or have no lock screen", isSupportedSDevice()); + assumeTrue("Device isn't at least S or has no lock screen", isSupportedSDevice()); int[] users = Utils.prepareSingleUser(getDevice()); int initialUser = users[0]; - deviceSetupServerBasedParameter(); - final String clientA = "ClientA"; final String clientB = "ClientB"; try { @@ -412,7 +347,6 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { deviceClearLskf(); } finally { removeTestPackages(); - deviceCleanupServerBasedParameter(); getDevice().rebootUntilOnline(); getDevice().waitForDeviceAvailable(); @@ -631,9 +565,12 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, CLASS, testMethodName); } - private boolean isSupportedDevice() throws Exception { - return getDevice().hasFeature(FEATURE_DEVICE_ADMIN) - && getDevice().hasFeature(FEATURE_REBOOT_ESCROW); + private boolean isSupportedSDevice() throws Exception { + // The following tests targets API level >= S. + boolean isAtleastS = ApiLevelUtil.isAfter(getDevice(), 30 /* BUILD.VERSION_CODES.R */) + || ApiLevelUtil.codenameEquals(getDevice(), "S"); + + return isAtleastS && getDevice().hasFeature(FEATURE_SECURE_LOCK_SCREEN); } private class InstallMultiple extends BaseInstallMultiple<InstallMultiple> { |