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

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

Merge "Fix Flaky UiModeManagerServiceTest" into main

parents e5d366f9 c353915d
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import org.mockito.Spy;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
@@ -232,7 +233,8 @@ public class UiModeManagerServiceTest extends UiServiceTestCase {
                any(AlarmManager.OnAlarmListener.class), any(Handler.class));

        doAnswer(inv -> {
            mCustomListener = () -> {};
            mCustomListener = () -> {
            };
            return null;
        }).when(mAlarmManager).cancel(eq(mCustomListener));
        when(mContext.getSystemService(eq(Context.POWER_SERVICE)))
@@ -1473,12 +1475,13 @@ public class UiModeManagerServiceTest extends UiServiceTestCase {
            assertFalse(mUiManagerService.getConfiguration().isNightModeActive());
        }

        // attention modes with expected night modes
        Map<Integer, Boolean> modes = Map.of(
                MODE_ATTENTION_THEME_OVERLAY_OFF, initialNightMode,
                MODE_ATTENTION_THEME_OVERLAY_DAY, false,
                MODE_ATTENTION_THEME_OVERLAY_NIGHT, true
        );
        // Attention modes with expected night modes.
        // Important to keep modes.put(MODE_ATTENTION_THEME_OVERLAY_OFF, initialNightMode) in the
        // first position, hence LinkedHashMap.
        Map<Integer, Boolean> modes = new LinkedHashMap<>();
        modes.put(MODE_ATTENTION_THEME_OVERLAY_OFF, initialNightMode);
        modes.put(MODE_ATTENTION_THEME_OVERLAY_DAY, false);
        modes.put(MODE_ATTENTION_THEME_OVERLAY_NIGHT, true);

        // test
        for (int attentionMode : modes.keySet()) {