| Index: content/public/android/junit/src/org/chromium/content/browser/input/GamepadMappingsTest.java
|
| diff --git a/content/public/android/junit/src/org/chromium/content/browser/input/GamepadMappingsTest.java b/content/public/android/junit/src/org/chromium/content/browser/input/GamepadMappingsTest.java
|
| index 58e16e7eb6d2ee511f37607e80a48d86732eb0d7..154e33a5b82a31a6ca1e855cf9307f87793b95ee 100644
|
| --- a/content/public/android/junit/src/org/chromium/content/browser/input/GamepadMappingsTest.java
|
| +++ b/content/public/android/junit/src/org/chromium/content/browser/input/GamepadMappingsTest.java
|
| @@ -93,11 +93,11 @@ public class GamepadMappingsTest {
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.QUATERNARY],
|
| mRawButtons[KeyEvent.KEYCODE_BUTTON_B], ERROR_TOLERANCE);
|
|
|
| - assertMappedCommonTriggerButtons();
|
| + assertMappedTriggerButtonsToTopShoulder();
|
| assertMappedCommonThumbstickButtons();
|
| assertMappedCommonDpadButtons();
|
| assertMappedCommonStartSelectMetaButtons();
|
| - assertMappedTriggerAxexToShoulderButtons();
|
| + assertMappedTriggerAxesToBottomShoulder();
|
| assertMappedXYAxes();
|
| assertMappedZAndRZAxesToRightStick();
|
|
|
| @@ -111,7 +111,7 @@ public class GamepadMappingsTest {
|
| GamepadMappings.SAMSUNG_EI_GP20_DEVICE_NAME);
|
|
|
| assertMappedCommonXYABButtons();
|
| - assertMappedCommonTriggerButtons();
|
| + assertMappedUpperTriggerButtonsToBottomShoulder();
|
| assertMappedCommonThumbstickButtons();
|
| assertMappedCommonStartSelectMetaButtons();
|
| assertMappedHatAxisToDpadButtons();
|
| @@ -142,22 +142,96 @@ public class GamepadMappingsTest {
|
|
|
| @Test
|
| @Feature({"Gamepad"})
|
| - public void testUnknownGamepadMappings() throws Exception {
|
| + public void testUnknownGamepadMappingA() throws Exception {
|
| GamepadMappings.mapToStandardGamepad(
|
| mMappedAxes, mMappedButtons, mRawAxes, mRawButtons, "");
|
|
|
| assertMappedCommonXYABButtons();
|
| - assertMappedCommonTriggerButtons();
|
| + assertMappedTriggerButtonsToTopShoulder();
|
| assertMappedCommonThumbstickButtons();
|
| assertMappedCommonStartSelectMetaButtons();
|
| - assertMappedTriggerAxexToShoulderButtons();
|
| + assertMappedTriggerAxesToBottomShoulder();
|
| + assertMappedHatAxisToDpadButtons();
|
| + assertMappedXYAxes();
|
| + assertMappedZAndRZAxesToRightStick();
|
| +
|
| + assertMapping();
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"Gamepad"})
|
| + public void testUnknownGamepadMappingB() throws Exception {
|
| + mRawAxes[MotionEvent.AXIS_LTRIGGER] = 0;
|
| + mRawAxes[MotionEvent.AXIS_RTRIGGER] = 0;
|
| +
|
| + mRawAxes[MotionEvent.AXIS_HAT_X] = 0;
|
| + mRawAxes[MotionEvent.AXIS_HAT_Y] = 0;
|
| +
|
| + GamepadMappings.mapToStandardGamepad(
|
| + mMappedAxes, mMappedButtons, mRawAxes, mRawButtons, "");
|
| +
|
| + assertMappedCommonXYABButtons();
|
| + assertMappedTriggerButtonsToTopShoulder();
|
| + assertMappedCommonThumbstickButtons();
|
| + assertMappedCommonStartSelectMetaButtons();
|
| + assertMappedPedalAxesToBottomShoulder();
|
| assertMappedCommonDpadButtons();
|
| assertMappedXYAxes();
|
| + assertMappedZAndRZAxesToRightStick();
|
| +
|
| + assertMapping();
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"Gamepad"})
|
| + public void testUnknownGamepadMappingC() throws Exception {
|
| + mRawAxes[MotionEvent.AXIS_LTRIGGER] = 0;
|
| + mRawAxes[MotionEvent.AXIS_RTRIGGER] = 0;
|
| + mRawAxes[MotionEvent.AXIS_BRAKE] = 0;
|
| + mRawAxes[MotionEvent.AXIS_GAS] = 0;
|
| +
|
| + mRawAxes[MotionEvent.AXIS_Z] = 0;
|
| + mRawAxes[MotionEvent.AXIS_RZ] = 0;
|
| +
|
| + GamepadMappings.mapToStandardGamepad(
|
| + mMappedAxes, mMappedButtons, mRawAxes, mRawButtons, "");
|
| +
|
| + assertMappedCommonXYABButtons();
|
| + assertMappedTriggerButtonsToTopShoulder();
|
| + assertMappedCommonThumbstickButtons();
|
| + assertMappedCommonStartSelectMetaButtons();
|
| + assertMappedAltPedalAxesToBottomShoulder();
|
| + assertMappedHatAxisToDpadButtons();
|
| + assertMappedXYAxes();
|
| assertMappedRXAndRYAxesToRightStick();
|
|
|
| assertMapping();
|
| }
|
|
|
| + @Test
|
| + @Feature({"Gamepad"})
|
| + public void testUnknownGamepadMappingD() throws Exception {
|
| + mRawAxes[MotionEvent.AXIS_LTRIGGER] = 0;
|
| + mRawAxes[MotionEvent.AXIS_RTRIGGER] = 0;
|
| + mRawAxes[MotionEvent.AXIS_BRAKE] = 0;
|
| + mRawAxes[MotionEvent.AXIS_GAS] = 0;
|
| + mRawAxes[MotionEvent.AXIS_THROTTLE] = 0;
|
| +
|
| + GamepadMappings.mapToStandardGamepad(
|
| + mMappedAxes, mMappedButtons, mRawAxes, mRawButtons, "");
|
| +
|
| + assertMappedCommonXYABButtons();
|
| + assertMappedTriggerButtonsToTopShoulder();
|
| + assertMappedCommonThumbstickButtons();
|
| + assertMappedCommonStartSelectMetaButtons();
|
| + assertMappedLowerTriggerButtonsToBottomShoulder();
|
| + assertMappedHatAxisToDpadButtons();
|
| + assertMappedXYAxes();
|
| + assertMappedZAndRZAxesToRightStick();
|
| +
|
| + assertMapping();
|
| + }
|
| +
|
| /**
|
| * Asserts that the current gamepad mapping being tested matches the shield mappings.
|
| */
|
| @@ -200,13 +274,20 @@ public class GamepadMappingsTest {
|
| }
|
| }
|
|
|
| - private void assertMappedCommonTriggerButtons() {
|
| + private void assertMappedUpperTriggerButtonsToBottomShoulder() {
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_TRIGGER],
|
| mRawButtons[KeyEvent.KEYCODE_BUTTON_L1], ERROR_TOLERANCE);
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER],
|
| mRawButtons[KeyEvent.KEYCODE_BUTTON_R1], ERROR_TOLERANCE);
|
| }
|
|
|
| + private void assertMappedLowerTriggerButtonsToBottomShoulder() {
|
| + Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_TRIGGER],
|
| + mRawButtons[KeyEvent.KEYCODE_BUTTON_L2], ERROR_TOLERANCE);
|
| + Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER],
|
| + mRawButtons[KeyEvent.KEYCODE_BUTTON_R2], ERROR_TOLERANCE);
|
| + }
|
| +
|
| private void assertMappedCommonDpadButtons() {
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.DPAD_DOWN],
|
| mRawButtons[KeyEvent.KEYCODE_DPAD_DOWN], ERROR_TOLERANCE);
|
| @@ -218,13 +299,6 @@ public class GamepadMappingsTest {
|
| mRawButtons[KeyEvent.KEYCODE_DPAD_RIGHT], ERROR_TOLERANCE);
|
| }
|
|
|
| - private void assertMappedTriggerAxexToShoulderButtons() {
|
| - Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_SHOULDER],
|
| - mRawAxes[MotionEvent.AXIS_LTRIGGER], ERROR_TOLERANCE);
|
| - Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.RIGHT_SHOULDER],
|
| - mRawAxes[MotionEvent.AXIS_RTRIGGER], ERROR_TOLERANCE);
|
| - }
|
| -
|
| private void assertMappedTriggerButtonsToTopShoulder() {
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_SHOULDER],
|
| mRawButtons[KeyEvent.KEYCODE_BUTTON_L1], ERROR_TOLERANCE);
|
| @@ -266,6 +340,13 @@ public class GamepadMappingsTest {
|
| mRawAxes[MotionEvent.AXIS_GAS], ERROR_TOLERANCE);
|
| }
|
|
|
| + private void assertMappedAltPedalAxesToBottomShoulder() {
|
| + Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_TRIGGER],
|
| + mRawAxes[MotionEvent.AXIS_BRAKE], ERROR_TOLERANCE);
|
| + Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER],
|
| + mRawAxes[MotionEvent.AXIS_THROTTLE], ERROR_TOLERANCE);
|
| + }
|
| +
|
| private void assertMappedTriggerAxesToBottomShoulder() {
|
| Assert.assertEquals(mMappedButtons[CanonicalButtonIndex.LEFT_TRIGGER],
|
| mRawAxes[MotionEvent.AXIS_LTRIGGER], ERROR_TOLERANCE);
|
|
|