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

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

Merge "Make custom ShadowInputDevice#getDeviceIds return ids from deviceMap" into main

parents 68682827 ebfead07
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ import com.android.settingslib.search.SearchIndexableRaw;

import com.google.common.truth.Correspondence;

import org.bouncycastle.util.Arrays;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -1096,26 +1095,13 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
                enabled ? ON : OFF);
    }

    private static void addShadowInputDeviceId(int deviceId) {
        if (ShadowInputDevice.sDeviceIds == null) {
            ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        } else {
            int curLength = ShadowInputDevice.sDeviceIds.length;
            ShadowInputDevice.sDeviceIds = Arrays.copyOf(ShadowInputDevice.sDeviceIds,
                    curLength + 1);
            ShadowInputDevice.sDeviceIds[curLength] = deviceId;
        }
    }

    private static void addMouseDevice() {
        addShadowInputDeviceId(SHADOW_MOUSE_DEVICE_ID);
        InputDevice device = ShadowInputDevice
                .makeInputDevicebyIdWithSources(SHADOW_MOUSE_DEVICE_ID, InputDevice.SOURCE_MOUSE);
        ShadowInputDevice.addDevice(SHADOW_MOUSE_DEVICE_ID, device);
    }

    private static void addKeyboardDevice() {
        addShadowInputDeviceId(SHADOW_KEYBOARD_DEVICE_ID);
        InputDevice device = ShadowInputDevice
                .makeFullKeyboardInputDevicebyId(SHADOW_KEYBOARD_DEVICE_ID);
        ShadowInputDevice.addDevice(SHADOW_KEYBOARD_DEVICE_ID, device);
+0 −1
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ public class ActionCornerPreferenceControllerTest {

    private void addTouchpad() {
        int deviceId = 1;
        ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        InputDevice device = ShadowInputDevice.makeInputDevicebyIdWithSources(deviceId,
                InputDevice.SOURCE_TOUCHPAD);
        ShadowInputDevice.addDevice(deviceId, device);
+0 −2
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ public class MouseSettingsControllerTest {
    @DisableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
    public void getAvailabilityStatus_flagIsDisable_returnsUnavailable() {
        int deviceId = 1;
        ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        ShadowInputDevice.addDevice(deviceId, ShadowInputDevice.makeInputDevicebyId(deviceId));
        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
@@ -77,7 +76,6 @@ public class MouseSettingsControllerTest {
    @EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
    public void getAvailabilityStatus_isMouse_returnsAvailable() {
        int deviceId = 1;
        ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        InputDevice device = ShadowInputDevice.makeInputDevicebyIdWithSources(deviceId,
                InputDevice.SOURCE_MOUSE);
        ShadowInputDevice.addDevice(deviceId, device);
+0 −2
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ public class PhysicalKeyboardA11yPreferenceControllerTest {
    @EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
    public void getAvailabilityStatus_expected() {
        int deviceId = 1;
        ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        when(mInputDevice.isVirtual()).thenReturn(false);
        when(mInputDevice.isFullKeyboard()).thenReturn(true);

@@ -83,7 +82,6 @@ public class PhysicalKeyboardA11yPreferenceControllerTest {
    @EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
    public void getAvailabilityStatus_deviceIsNotAsExpected_unavailable() {
        int deviceId = 1;
        ShadowInputDevice.sDeviceIds = new int[]{deviceId};
        when(mInputDevice.isVirtual()).thenReturn(true);
        when(mInputDevice.isFullKeyboard()).thenReturn(false);

+0 −2
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public class PhysicalKeyboardPreferenceControllerTest {
    @Test
    @Config(shadows = ShadowInputDevice.class)
    public void updateState_noKeyboard_setPreferenceVisibleFalse() {
        ShadowInputDevice.sDeviceIds = new int[0];
        mController.updateState(mPreference);

        verify(mPreference).setVisible(false);
@@ -120,7 +119,6 @@ public class PhysicalKeyboardPreferenceControllerTest {
        when(device.isVirtual()).thenReturn(false);
        when(device.isFullKeyboard()).thenReturn(true);
        when(device.getName()).thenReturn("test_keyboard");
        ShadowInputDevice.sDeviceIds = new int[]{0};
        ShadowInputDevice.addDevice(0, device);

        mController.updateState(mPreference);
Loading