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

Commit 3a4edc74 authored by Chris Ye's avatar Chris Ye
Browse files

Add test coverage for android.hardware.lights.LightsRequest and hide...

Add test coverage for android.hardware.lights.LightsRequest and hide android.hardware.lights.LightsManager.LightsSession constructor.

Add core CTS test coverage for android.hardware.lights.LightsRequest
API getLights() and getLightStates().
Hide android.hardware.lights.LightsManager.LightsSession constructor.

Bug: 183239763
Bug: 183239666
Test: atest FrameworksCoreTests:InputDeviceLightsManagerTest

Change-Id: I41e0272e64a55b631eda387af0645af077d025be
parent 1700fa9e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -18992,7 +18992,6 @@ package android.hardware.lights {
  }
  public abstract static class LightsManager.LightsSession implements java.lang.AutoCloseable {
    ctor public LightsManager.LightsSession();
    method public abstract void close();
    method public abstract void requestLights(@NonNull android.hardware.lights.LightsRequest);
  }
+6 −0
Original line number Diff line number Diff line
@@ -112,6 +112,12 @@ public abstract class LightsManager {
    public abstract static class LightsSession implements AutoCloseable {
        private final IBinder mToken = new Binder();

        /**
         * @hide to prevent subclassing from outside of the framework
         */
        public LightsSession() {
        }

        /**
         * Sends a request to modify the states of multiple lights.
         *
+22 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static org.mockito.Mockito.when;
import android.hardware.lights.Light;
import android.hardware.lights.LightState;
import android.hardware.lights.LightsManager;
import android.hardware.lights.LightsRequest;
import android.os.IBinder;
import android.platform.test.annotations.Presubmit;
import android.util.ArrayMap;
@@ -224,4 +225,25 @@ public class InputDeviceLightsManagerTest {
        session.close();
        verify(mIInputManagerMock).closeLightSession(eq(DEVICE_ID), eq(token));
    }

    @Test
    public void testLightsRequest() throws Exception {
        Light light = new Light(1 /* id */, 0 /* ordinal */,  Light.LIGHT_TYPE_INPUT_PLAYER_ID);
        LightState state = new LightState(0xf1);
        LightsRequest request = new Builder().addLight(light, state).build();

        // Covers the LightsRequest.getLights
        assertThat(request.getLights().size()).isEqualTo(1);
        assertThat(request.getLights().get(0)).isEqualTo(1);

        // Covers the LightsRequest.getLightStates
        assertThat(request.getLightStates().size()).isEqualTo(1);
        assertThat(request.getLightStates().get(0)).isEqualTo(state);

        // Covers the LightsRequest.getLightsAndStates
        assertThat(request.getLightsAndStates().size()).isEqualTo(1);
        assertThat(request.getLightsAndStates().containsKey(1)).isTrue();
        assertThat(request.getLightsAndStates().get(1)).isEqualTo(state);
    }

}