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

Commit 9efc269b authored by David Saff's avatar David Saff Committed by Android (Google) Code Review
Browse files

Merge "Use factory for all cases to prevent test crash." into main

parents 30ac454e 01662cde
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -547,7 +547,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            return;
        }

        final SystemUIDialog d = new SystemUIDialog(mContext, R.style.Theme_SystemUI_Dialog_Alert);
        final SystemUIDialog d = mSystemUIDialogFactory.create();
        d.setCancelable(false);
        d.setIconAttribute(android.R.attr.alertDialogIcon);
        d.setTitle(R.string.high_temp_alarm_title);
+7 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.testing.TestableLooper;
import android.view.Window;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -97,6 +98,10 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
    @Mock
    private SystemUIDialog mSystemUIDialog;

    @Mock
    private Window mDialogWindow;

    @Mock
    private BroadcastReceiver mReceiver;

    @Before
@@ -123,6 +128,7 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
        when(mUserTracker.getUserHandle()).thenReturn(
                UserHandle.of(ActivityManager.getCurrentUser()));
        when(mSystemUIDialogFactory.create()).thenReturn(mSystemUIDialog);
        when(mSystemUIDialog.getWindow()).thenReturn(mDialogWindow);
        mPowerNotificationWarnings = new PowerNotificationWarnings(
                wrapper,
                starter,
@@ -236,6 +242,7 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
        assertThat(mPowerNotificationWarnings.mUsbHighTempDialog).isNotNull();

        mPowerNotificationWarnings.mUsbHighTempDialog.dismiss();
        waitForIdleSync(mContext.getMainThreadHandler());
    }

    @Test