Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 834179b2 authored by Tetiana Meronyk's avatar Tetiana Meronyk
Browse files

Fix UserManagerTest for automotive to include checking whether profiles are allowed

Bug: 266801863
Test: atest UserManagerTest
Change-Id: I1fb7c516b4a29a5c65469d9f94707be287868789
parent adc9ba1a
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -144,7 +144,9 @@ public final class UserManagerTest {

    @Test
    public void testCloneUser() throws Exception {

        assumeCloneEnabled();
        UserHandle mainUser = mUserManager.getMainUser();
        assumeTrue("Main user is null", mainUser != null);
        // Get the default properties for clone user type.
        final UserTypeDetails userTypeDetails =
                UserTypeFactory.getUserTypes().get(UserManager.USER_TYPE_PROFILE_CLONE);
@@ -153,7 +155,7 @@ public final class UserManagerTest {
        final UserProperties typeProps = userTypeDetails.getDefaultUserPropertiesReference();

        // Test that only one clone user can be created
        final int mainUserId = mUserManager.getMainUser().getIdentifier();
        final int mainUserId = mainUser.getIdentifier();
        UserInfo userInfo = createProfileForUser("Clone user1",
                UserManager.USER_TYPE_PROFILE_CLONE,
                mainUserId);
@@ -536,6 +538,7 @@ public final class UserManagerTest {
    @Test
    public void testRemoveUserWhenPossible_withProfiles() throws Exception {
        assumeHeadlessModeEnabled();
        assumeCloneEnabled();
        final UserInfo parentUser = createUser("Human User", /* flags= */ 0);
        final UserInfo cloneProfileUser = createProfileForUser("Clone Profile user",
                UserManager.USER_TYPE_PROFILE_CLONE,
@@ -1539,6 +1542,12 @@ public final class UserManagerTest {
                UserManager.isHeadlessSystemUserMode());
    }

    private void assumeCloneEnabled() {
        // assume clone profile is supported on the device
        assumeTrue("Device doesn't support clone profiles ",
                mUserManager.isUserTypeEnabled(UserManager.USER_TYPE_PROFILE_CLONE));
    }

    private boolean isAutomotive() {
        return mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
    }