diff options
Diffstat (limited to 'hostsidetests')
8 files changed, 56 insertions, 40 deletions
diff --git a/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java b/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java index 08dc7add514..75915b631df 100644 --- a/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java +++ b/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java @@ -150,7 +150,9 @@ public class Utils { } private static long getAllocatedSize(File f) throws Exception { - return Os.lstat(f.getAbsolutePath()).st_blocks * 512; + return Os.lstat(f.getAbsolutePath()).st_blocks * 512 / + Os.lstat(f.getAbsolutePath()).st_blksize * + Os.lstat(f.getAbsolutePath()).st_blksize ; } public static boolean deleteContents(File dir) { diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java index ef51156a26f..6589b224b58 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java @@ -150,7 +150,18 @@ public class BaseDevicePolicyTest extends DeviceTestCase implements IBuildReceiv if (mPrimaryUserId != USER_SYSTEM) { mFixedUsers.add(USER_SYSTEM); } - switchUser(mPrimaryUserId); + + if (mHasFeature) { + // Switching to primary is only needed when we're testing device admin features. + switchUser(mPrimaryUserId); + } else { + // Otherwise, all the tests can be executed in any of the Android users, so remain in + // current user, and don't delete it. This enables testing in secondary users. + if (getDevice().getCurrentUser() != mPrimaryUserId) { + mFixedUsers.add(getDevice().getCurrentUser()); + } + } + removeOwners(); removeTestUsers(); // Unlock keyguard before test diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java index ed885c5bcb0..53db4137d39 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java @@ -35,10 +35,9 @@ public class BaseLauncherAppsTest extends BaseDevicePolicyTest { "com.android.cts.launchertests.support"; protected static final String LAUNCHER_TESTS_SUPPORT_APK = "CtsLauncherAppsTestsSupport.apk"; - protected void installTestApps() throws Exception { - uninstallTestApps(); - installAppAsUser(LAUNCHER_TESTS_APK, mPrimaryUserId); - installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mPrimaryUserId); + protected void installTestApps(int userId) throws Exception { + installAppAsUser(LAUNCHER_TESTS_APK, userId); + installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, userId); } protected void uninstallTestApps() throws Exception { @@ -47,8 +46,8 @@ public class BaseLauncherAppsTest extends BaseDevicePolicyTest { getDevice().uninstallPackage(SIMPLE_APP_PKG); } - protected void startCallbackService() throws Exception { - String command = "am startservice --user " + mPrimaryUserId + protected void startCallbackService(int userId) throws Exception { + String command = "am startservice --user " + userId + " -a " + LAUNCHER_TESTS_SUPPORT_PKG + ".REGISTER_CALLBACK " + LAUNCHER_TESTS_SUPPORT_PKG + "/.LauncherCallbackTestsService"; CLog.d("Output for command " + command + ": " + getDevice().executeShellCommand(command)); diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java index 9205ff7373b..8ae7184f970 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java @@ -42,7 +42,8 @@ public class LauncherAppsMultiUserTest extends BaseLauncherAppsTest { if (mMultiUserSupported) { removeTestUsers(); - installTestApps(); + uninstallTestApps(); + installTestApps(mPrimaryUserId); // Create a secondary user. mSecondaryUserId = createUser(); mSecondaryUserSerialNumber = Integer.toString(getUserSerialNumber(mSecondaryUserId)); @@ -75,7 +76,7 @@ public class LauncherAppsMultiUserTest extends BaseLauncherAppsTest { if (!mMultiUserSupported) { return; } - startCallbackService(); + startCallbackService(mPrimaryUserId); installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java index 1596b3cbd4e..7df242d93fb 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java @@ -53,12 +53,9 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest { mMainUserSerialNumber = Integer.toString(getUserSerialNumber(mParentUserId)); startUser(mProfileUserId); - // Install test APK. - installTestApps(); - - // Also install on the managed profile too. - installAppAsUser(LAUNCHER_TESTS_APK, mProfileUserId); - installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mProfileUserId); + // Install test APK on primary user and the managed profile. + installTestApps(mPrimaryUserId); + installTestApps(mProfileUserId); } } @@ -110,7 +107,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest { if (!mHasFeature) { return; } - startCallbackService(); + startCallbackService(mPrimaryUserId); installAppAsUser(SIMPLE_APP_APK, mProfileUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, @@ -123,7 +120,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest { return; } installAppAsUser(SIMPLE_APP_APK, mProfileUserId); - startCallbackService(); + startCallbackService(mPrimaryUserId); getDevice().uninstallPackage(SIMPLE_APP_PKG); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, @@ -136,7 +133,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest { return; } installAppAsUser(SIMPLE_APP_APK, mProfileUserId); - startCallbackService(); + startCallbackService(mPrimaryUserId); installAppAsUser(SIMPLE_APP_APK, mProfileUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java index 0481777f8f9..5d67a468d7d 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java @@ -29,6 +29,7 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest { private boolean mHasLauncherApps; private String mSerialNumber; + private int mCurrentUserId; @Override protected void setUp() throws Exception { @@ -36,8 +37,10 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest { mHasLauncherApps = getDevice().getApiLevel() >= 21; if (mHasLauncherApps) { - mSerialNumber = Integer.toString(getUserSerialNumber(USER_SYSTEM)); - installTestApps(); + mCurrentUserId = getDevice().getCurrentUser(); + mSerialNumber = Integer.toString(getUserSerialNumber(mCurrentUserId)); + uninstallTestApps(); + installTestApps(mCurrentUserId); } } @@ -53,78 +56,78 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testSimpleAppInstalledForUser", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLauncherCallbackPackageAddedMainUser() throws Exception { if (!mHasLauncherApps) { return; } - startCallbackService(); - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + startCallbackService(mCurrentUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testPackageAddedCallbackForUser", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLauncherCallbackPackageRemovedMainUser() throws Exception { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); - startCallbackService(); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); + startCallbackService(mCurrentUserId); getDevice().uninstallPackage(SIMPLE_APP_PKG); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testPackageRemovedCallbackForUser", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLauncherCallbackPackageChangedMainUser() throws Exception { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); - startCallbackService(); - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); + startCallbackService(mCurrentUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testPackageChangedCallbackForUser", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLauncherNonExportedAppFails() throws Exception { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testLaunchNonExportActivityFails", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLaunchNonExportActivityFails() throws Exception { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testLaunchNonExportLauncherFails", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } public void testLaunchMainActivity() throws Exception { if (!mHasLauncherApps) { return; } - installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId); + installAppAsUser(SIMPLE_APP_APK, mCurrentUserId); runDeviceTestsAsUser(LAUNCHER_TESTS_PKG, LAUNCHER_TESTS_CLASS, "testLaunchMainActivity", - mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); + mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber)); } } diff --git a/hostsidetests/incident/AndroidTest.xml b/hostsidetests/incident/AndroidTest.xml index 641b516feb8..18a73fa2acd 100644 --- a/hostsidetests/incident/AndroidTest.xml +++ b/hostsidetests/incident/AndroidTest.xml @@ -16,6 +16,9 @@ <configuration description="Config for CTS Incident host test cases"> <option name="test-suite-tag" value="cts" /> <option name="config-descriptor:metadata" key="component" value="metrics" /> + <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer"> + <option name="user-type" value="system" /> + </target_preparer> <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" > <option name="jar" value="CtsIncidentHostTestCases.jar" /> </test> diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml index ae95f999473..11683fc5381 100644 --- a/hostsidetests/securitybulletin/AndroidTest.xml +++ b/hostsidetests/securitybulletin/AndroidTest.xml @@ -183,6 +183,6 @@ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" > <option name="jar" value="CtsSecurityBulletinHostTestCases.jar" /> - <option name="runtime-hint" value="8m40s" /> + <option name="runtime-hint" value="18m26s" /> </test> </configuration> |