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

Commit 5497fdbb authored by Santos Cordon's avatar Santos Cordon Committed by Android (Google) Code Review
Browse files

Merge "Mock config to fix DreamControllerTest failures" into main

parents 141f1e44 8fb07381
Loading
Loading
Loading
Loading
+13 −6
Original line number Original line Diff line number Diff line
@@ -46,7 +46,6 @@ import android.os.RemoteException;
import android.os.test.TestLooper;
import android.os.test.TestLooper;
import android.service.dreams.IDreamService;
import android.service.dreams.IDreamService;


import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.runner.AndroidJUnit4;


@@ -108,10 +107,8 @@ public class DreamControllerTest {
                .thenReturn(Context.ACTIVITY_TASK_SERVICE);
                .thenReturn(Context.ACTIVITY_TASK_SERVICE);


        final PowerManager powerManager = new PowerManager(mContext, mPowerManager, null, null);
        final PowerManager powerManager = new PowerManager(mContext, mPowerManager, null, null);
        when(mContext.getSystemService(Context.POWER_SERVICE))
        when(mContext.getSystemService(PowerManager.class))
                .thenReturn(powerManager);
                .thenReturn(powerManager);
        when(mContext.getSystemServiceName(PowerManager.class))
                .thenReturn(Context.POWER_SERVICE);
        when(mContext.getResources()).thenReturn(mResources);
        when(mContext.getResources()).thenReturn(mResources);


        mToken = new Binder();
        mToken = new Binder();
@@ -234,8 +231,13 @@ public class DreamControllerTest {
    }
    }


    @Test
    @Test
    @FlakyTest(bugId = 293109503)
    public void serviceDisconnect_resetsScreenTimeout() throws RemoteException {
    public void serviceDisconnect_resetsScreenTimeout() throws RemoteException {
        when(mResources.getBoolean(
                com.android.internal.R.bool.config_resetScreenTimeoutOnUnexpectedDreamExit))
                .thenReturn(true);
        // Recreate DreamManager because the configuration gets retrieved in the constructor
        mDreamController = new DreamController(mContext, mHandler, mListener);

        // Start dream.
        // Start dream.
        mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
        mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
                0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);
                0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);
@@ -254,8 +256,13 @@ public class DreamControllerTest {
    }
    }


    @Test
    @Test
    @FlakyTest(bugId = 293109503)
    public void binderDied_resetsScreenTimeout() throws RemoteException {
    public void binderDied_resetsScreenTimeout() throws RemoteException {
        when(mResources.getBoolean(
                com.android.internal.R.bool.config_resetScreenTimeoutOnUnexpectedDreamExit))
                .thenReturn(true);
        // Recreate DreamManager because the configuration gets retrieved in the constructor
        mDreamController = new DreamController(mContext, mHandler, mListener);

        // Start dream.
        // Start dream.
        mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
        mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
                0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);
                0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);