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

Commit b4e65e6e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix ProfileSelectDialogTest" into main

parents 43e89fdf 82d3e105
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo;
import android.content.pm.UserProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.widget.TextView;
import android.widget.TextView;
@@ -42,16 +43,19 @@ import com.android.settingslib.drawer.Tile;
import com.google.android.collect.Lists;
import com.google.android.collect.Lists;


import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RobolectricTestRunner;


@RunWith(RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class ProfileSelectDialogTest {
public class ProfileSelectDialogTest {
    @Rule
    public final MockitoRule mMockitoRule = MockitoJUnit.rule();


    private static final UserHandle NORMAL_USER = new UserHandle(1111);
    private static final UserHandle NORMAL_USER = new UserHandle(1111);
    private static final UserHandle REMOVED_USER = new UserHandle(2222);
    private static final UserHandle REMOVED_USER = new UserHandle(2222);
@@ -67,11 +71,12 @@ public class ProfileSelectDialogTest {


    @Before
    @Before
    public void setUp() {
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
        final UserInfo userInfo = new UserInfo(
        final UserInfo userInfo = new UserInfo(
                NORMAL_USER.getIdentifier(), "test_user", UserInfo.FLAG_RESTRICTED);
                NORMAL_USER.getIdentifier(), "test_user", UserInfo.FLAG_RESTRICTED);
        when(mUserManager.getUserInfo(NORMAL_USER.getIdentifier())).thenReturn(userInfo);
        when(mUserManager.getUserInfo(NORMAL_USER.getIdentifier())).thenReturn(userInfo);
        final UserProperties userProperties = new UserProperties.Builder().build();
        when(mUserManager.getUserProperties(NORMAL_USER)).thenReturn(userProperties);
        mActivityInfo = new ActivityInfo();
        mActivityInfo = new ActivityInfo();
        mActivityInfo.packageName = "pkg";
        mActivityInfo.packageName = "pkg";
        mActivityInfo.name = "cls";
        mActivityInfo.name = "cls";
@@ -89,7 +94,6 @@ public class ProfileSelectDialogTest {
        verify(mUserManager, never()).getUserInfo(NORMAL_USER.getIdentifier());
        verify(mUserManager, never()).getUserInfo(NORMAL_USER.getIdentifier());
    }
    }


    @Ignore("b/313569889")
    @Test
    @Test
    public void updateUserHandlesIfNeeded_Remove() {
    public void updateUserHandlesIfNeeded_Remove() {
        final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
        final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
@@ -105,7 +109,6 @@ public class ProfileSelectDialogTest {
        verify(mUserManager, times(2)).getUserInfo(REMOVED_USER.getIdentifier());
        verify(mUserManager, times(2)).getUserInfo(REMOVED_USER.getIdentifier());
    }
    }


    @Ignore("b/313569889")
    @Test
    @Test
    public void updateUserHandlesIfNeeded_removesCloneProfile() {
    public void updateUserHandlesIfNeeded_removesCloneProfile() {
        final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,
        final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,
@@ -122,7 +125,6 @@ public class ProfileSelectDialogTest {
        verify(mUserManager, times(1)).getUserInfo(CLONE_USER.getIdentifier());
        verify(mUserManager, times(1)).getUserInfo(CLONE_USER.getIdentifier());
    }
    }


    @Ignore("b/313569889")
    @Test
    @Test
    public void updatePendingIntentsIfNeeded_removesUsersWithNoPendingIntentsAndCloneProfile() {
    public void updatePendingIntentsIfNeeded_removesUsersWithNoPendingIntentsAndCloneProfile() {
        final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,
        final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,