Merge "Implement shadow for UserManager#getMainUser"

This commit is contained in:
Sarp Misoglu
2022-12-30 13:51:18 +00:00
committed by Android (Google) Code Review
4 changed files with 16 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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<>();