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

Commit de360190 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8656240 from 5b8423e7 to tm-release

Change-Id: I58417562e073806327e47210d8c4d765dfd26949
parents faa83a5d 5b8423e7
Loading
Loading
Loading
Loading
+23 −15
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.documentsui.base.UserId;
import com.android.documentsui.testing.TestActionHandler;
import com.android.documentsui.testing.TestActionHandler;
import com.android.documentsui.testing.TestEnv;
import com.android.documentsui.testing.TestEnv;
import com.android.documentsui.testing.UserManagers;
import com.android.documentsui.testing.UserManagers;
import com.android.modules.utils.build.SdkLevel;


import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
@@ -60,7 +61,6 @@ public final class MessageTest {
    };
    };
    private UserManager mUserManager;
    private UserManager mUserManager;
    private DevicePolicyManager mDevicePolicyManager;
    private DevicePolicyManager mDevicePolicyManager;
    private DevicePolicyResourcesManager mDevicePolicyResourcesManager;
    private TestActionHandler mTestActionHandler;
    private TestActionHandler mTestActionHandler;


    @Before
    @Before
@@ -69,13 +69,11 @@ public final class MessageTest {
        mUserManager = UserManagers.create();
        mUserManager = UserManagers.create();
        mTestActionHandler = new TestActionHandler();
        mTestActionHandler = new TestActionHandler();
        mDevicePolicyManager = mock(DevicePolicyManager.class);
        mDevicePolicyManager = mock(DevicePolicyManager.class);
        mDevicePolicyResourcesManager = mock(DevicePolicyResourcesManager.class);
        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
        when(mContext.getSystemServiceName(DevicePolicyManager.class))
        when(mContext.getSystemServiceName(DevicePolicyManager.class))
                .thenReturn(Context.DEVICE_POLICY_SERVICE);
                .thenReturn(Context.DEVICE_POLICY_SERVICE);
        when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
        when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
                .thenReturn(mDevicePolicyManager);
                .thenReturn(mDevicePolicyManager);
        when(mDevicePolicyManager.getResources()).thenReturn(mDevicePolicyResourcesManager);
        when(mContext.getResources()).thenReturn(
        when(mContext.getResources()).thenReturn(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getResources());
                InstrumentationRegistry.getInstrumentation().getTargetContext().getResources());
        DocumentsAdapter.Environment env =
        DocumentsAdapter.Environment env =
@@ -91,12 +89,17 @@ public final class MessageTest {
        Model.Update error = new Model.Update(
        Model.Update error = new Model.Update(
                new CrossProfileNoPermissionException(),
                new CrossProfileNoPermissionException(),
                /* isRemoteActionsEnabled= */ true);
                /* isRemoteActionsEnabled= */ true);
        if (SdkLevel.isAtLeastT()) {
            String title = mContext.getString(R.string.cant_select_work_files_error_title);
            String title = mContext.getString(R.string.cant_select_work_files_error_title);
            String message = mContext.getString(R.string.cant_select_work_files_error_message);
            String message = mContext.getString(R.string.cant_select_work_files_error_message);
        when(mDevicePolicyResourcesManager.getString(eq(CANT_SELECT_WORK_FILES_TITLE), any()))
            DevicePolicyResourcesManager devicePolicyResourcesManager = mock(
                    DevicePolicyResourcesManager.class);
            when(mDevicePolicyManager.getResources()).thenReturn(devicePolicyResourcesManager);
            when(devicePolicyResourcesManager.getString(eq(CANT_SELECT_WORK_FILES_TITLE), any()))
                    .thenReturn(title);
                    .thenReturn(title);
        when(mDevicePolicyResourcesManager.getString(eq(CANT_SELECT_WORK_FILES_MESSAGE), any()))
            when(devicePolicyResourcesManager.getString(eq(CANT_SELECT_WORK_FILES_MESSAGE), any()))
                    .thenReturn(message);
                    .thenReturn(message);
        }


        mInflateMessage.update(error);
        mInflateMessage.update(error);


@@ -115,12 +118,17 @@ public final class MessageTest {
        Model.Update error = new Model.Update(
        Model.Update error = new Model.Update(
                new CrossProfileQuietModeException(mUserId),
                new CrossProfileQuietModeException(mUserId),
                /* isRemoteActionsEnabled= */ true);
                /* isRemoteActionsEnabled= */ true);
        if (SdkLevel.isAtLeastT()) {
            String title = mContext.getString(R.string.quiet_mode_error_title);
            String title = mContext.getString(R.string.quiet_mode_error_title);
            String text = mContext.getString(R.string.quiet_mode_button);
            String text = mContext.getString(R.string.quiet_mode_button);
        when(mDevicePolicyResourcesManager.getString(eq(WORK_PROFILE_OFF_ERROR_TITLE), any()))
            DevicePolicyResourcesManager devicePolicyResourcesManager = mock(
                    DevicePolicyResourcesManager.class);
            when(mDevicePolicyManager.getResources()).thenReturn(devicePolicyResourcesManager);
            when(devicePolicyResourcesManager.getString(eq(WORK_PROFILE_OFF_ERROR_TITLE), any()))
                    .thenReturn(title);
                    .thenReturn(title);
        when(mDevicePolicyResourcesManager.getString(eq(WORK_PROFILE_OFF_ENABLE_BUTTON), any()))
            when(devicePolicyResourcesManager.getString(eq(WORK_PROFILE_OFF_ENABLE_BUTTON), any()))
                    .thenReturn(text);
                    .thenReturn(text);
        }


        mInflateMessage.update(error);
        mInflateMessage.update(error);