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

Commit 338ffb52 authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge "Report all conditions met when no conditions given."

parents 1544cd3c 3f093ba1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -81,6 +81,12 @@ public class Monitor implements CallbackController<Monitor.Callback> {
    public Monitor(Set<Condition> conditions) {
        mConditions = conditions;

        // If there is no condition, give green pass.
        if (mConditions.isEmpty()) {
            mAllConditionsMet = true;
            return;
        }

        // Initializes the conditions map and registers a callback for each condition.
        mConditions.forEach((condition -> mConditionsMap.put(condition, false)));
    }
+10 −0
Original line number Diff line number Diff line
@@ -96,6 +96,16 @@ public class ConditionMonitorTest extends SysuiTestCase {
        verify(callback2).onConditionsChanged(true);
    }

    @Test
    public void addCallback_noConditions_reportAllConditionsMet() {
        final Monitor monitor = new Monitor(new HashSet<>());
        final Monitor.Callback callback = mock(Monitor.Callback.class);

        monitor.addCallback(callback);

        verify(callback).onConditionsChanged(true);
    }

    @Test
    public void removeCallback_shouldNoLongerReceiveUpdate() {
        final Monitor.Callback callback =