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

Commit d65fdb1f authored by Steven Ng's avatar Steven Ng Committed by Android (Google) Code Review
Browse files

Merge "Mock isDeviceEligibleForDesktopMode in WallpaperManagerServiceTests" into main

parents ec27be70 04c486e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public final class DesktopModeHelper {
    }

    @VisibleForTesting
    static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) {
    public static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) {
        if (!shouldEnforceDeviceRestrictions()) {
            return true;
        }
+4 −7
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.graphics.Color;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
@@ -95,6 +94,7 @@ import com.android.internal.R;
import com.android.modules.utils.TypedXmlPullParser;
import com.android.modules.utils.TypedXmlSerializer;
import com.android.server.LocalServices;
import com.android.server.wm.DesktopModeHelper;
import com.android.server.wm.WindowManagerInternal;

import org.hamcrest.CoreMatchers;
@@ -155,8 +155,6 @@ public class WallpaperManagerServiceTests {

    private IPackageManager mIpm = AppGlobals.getPackageManager();

    private Resources mResources = sContext.getResources();

    @Mock
    private DisplayManager mDisplayManager;

@@ -178,6 +176,7 @@ public class WallpaperManagerServiceTests {
                .spyStatic(WallpaperUtils.class)
                .spyStatic(LocalServices.class)
                .spyStatic(WallpaperManager.class)
                .spyStatic(DesktopModeHelper.class)
                .startMocking();

        sWindowManagerInternal = mock(WindowManagerInternal.class);
@@ -246,6 +245,8 @@ public class WallpaperManagerServiceTests {
            int userId = (invocation.getArgument(0));
            return getWallpaperTestDir(userId);
        }).when(() -> WallpaperUtils.getWallpaperDir(anyInt()));
        ExtendedMockito.doAnswer(invocation -> true).when(
                () -> DesktopModeHelper.isDeviceEligibleForDesktopMode(any()));

        sContext.addMockSystemService(DisplayManager.class, mDisplayManager);

@@ -257,10 +258,6 @@ public class WallpaperManagerServiceTests {
        doReturn(displays).when(mDisplayManager).getDisplays();

        spyOn(mIpm);
        spyOn(mResources);
        doReturn(true).when(mResources).getBoolean(eq(R.bool.config_isDesktopModeSupported));
        doReturn(true).when(mResources).getBoolean(
                eq(R.bool.config_canInternalDisplayHostDesktops));
        mService = new TestWallpaperManagerService(sContext);
        spyOn(mService);
        mService.systemReady();