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

Commit 0bf138d6 authored by Sarp Misoglu's avatar Sarp Misoglu Committed by Android (Google) Code Review
Browse files

Merge "Implement shadow for UserManager#getMainUser"

parents 4c58d93f 9a4da64c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import com.android.server.testing.shadows.ShadowBinder;
import com.android.server.testing.shadows.ShadowKeyValueBackupJob;
import com.android.server.testing.shadows.ShadowKeyValueBackupTask;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;
import com.android.server.testing.shadows.ShadowUserManager;

import org.junit.After;
import org.junit.Before;
@@ -101,7 +102,8 @@ import java.util.List;
        shadows = {
            ShadowBackupEligibilityRules.class,
            ShadowApplicationPackageManager.class,
            ShadowSystemServiceRegistry.class
            ShadowSystemServiceRegistry.class,
            ShadowUserManager.class
        })
@Presubmit
public class UserBackupManagerServiceTest {
+3 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.testing.BackupManagerServiceTestUtils;
import com.android.server.testing.shadows.ShadowApplicationPackageManager;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;
import com.android.server.testing.shadows.ShadowUserManager;

import org.junit.Before;
import org.junit.Test;
@@ -56,7 +57,8 @@ import java.io.File;
        shadows = {
            ShadowApplicationPackageManager.class,
            ShadowJobScheduler.class,
            ShadowSystemServiceRegistry.class
            ShadowSystemServiceRegistry.class,
            ShadowUserManager.class
        })
@Presubmit
public class SetupObserverTest {
+3 −1
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ import com.android.server.testing.shadows.ShadowBackupDataInput;
import com.android.server.testing.shadows.ShadowBackupDataOutput;
import com.android.server.testing.shadows.ShadowEventLog;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;
import com.android.server.testing.shadows.ShadowUserManager;

import com.google.common.base.Charsets;
import com.google.common.truth.IterableSubject;
@@ -175,7 +176,8 @@ import java.util.stream.Stream;
            ShadowBackupDataOutput.class,
            ShadowEventLog.class,
            ShadowQueuedWork.class,
            ShadowSystemServiceRegistry.class
            ShadowSystemServiceRegistry.class,
            ShadowUserManager.class
        })
@Presubmit
public class KeyValueBackupTaskTest  {
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.testing.shadows;

import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.os.UserHandle;
import android.os.UserManager;

import org.robolectric.annotation.Implementation;
@@ -50,6 +51,12 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
        return profileIds.get(userId).stream().mapToInt(Number::intValue).toArray();
    }

    /** @see UserManager#getMainUser() */
    @Implementation
    public UserHandle getMainUser() {
        return null;
    }

    /** Add a collection of profile IDs, all within the same profile group. */
    public void addProfileIds(@UserIdInt int... userIds) {
        final Set<Integer> profileGroup = new HashSet<>();