| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser.input; | 5 package org.chromium.device.gamepad; |
| 6 | 6 |
| 7 import android.view.KeyEvent; | 7 import android.view.KeyEvent; |
| 8 import android.view.MotionEvent; | 8 import android.view.MotionEvent; |
| 9 | 9 |
| 10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
| 11 import org.chromium.testing.local.LocalRobolectricTestRunner; | 11 import org.chromium.testing.local.LocalRobolectricTestRunner; |
| 12 | 12 |
| 13 import org.junit.Assert; | 13 import org.junit.Assert; |
| 14 import org.junit.Before; | 14 import org.junit.Before; |
| 15 import org.junit.Test; | 15 import org.junit.Test; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 35 * Set bits indicate that we don't expect the axis at mMappedAxes[index] to
be mapped. | 35 * Set bits indicate that we don't expect the axis at mMappedAxes[index] to
be mapped. |
| 36 */ | 36 */ |
| 37 private BitSet mUnmappedAxes = new BitSet(CanonicalAxisIndex.COUNT); | 37 private BitSet mUnmappedAxes = new BitSet(CanonicalAxisIndex.COUNT); |
| 38 private float[] mMappedButtons = new float[CanonicalButtonIndex.COUNT]; | 38 private float[] mMappedButtons = new float[CanonicalButtonIndex.COUNT]; |
| 39 private float[] mMappedAxes = new float[CanonicalAxisIndex.COUNT]; | 39 private float[] mMappedAxes = new float[CanonicalAxisIndex.COUNT]; |
| 40 private float[] mRawButtons = new float[GamepadDevice.MAX_RAW_BUTTON_VALUES]
; | 40 private float[] mRawButtons = new float[GamepadDevice.MAX_RAW_BUTTON_VALUES]
; |
| 41 private float[] mRawAxes = new float[GamepadDevice.MAX_RAW_AXIS_VALUES]; | 41 private float[] mRawAxes = new float[GamepadDevice.MAX_RAW_AXIS_VALUES]; |
| 42 | 42 |
| 43 @Before | 43 @Before |
| 44 public void setUp() throws Exception { | 44 public void setUp() throws Exception { |
| 45 | |
| 46 // By default, we expect every button and axis to be mapped. | 45 // By default, we expect every button and axis to be mapped. |
| 47 mUnmappedButtons.clear(); | 46 mUnmappedButtons.clear(); |
| 48 mUnmappedAxes.clear(); | 47 mUnmappedAxes.clear(); |
| 49 | 48 |
| 50 // Start with all the mapped values as unmapped. | 49 // Start with all the mapped values as unmapped. |
| 51 Arrays.fill(mMappedButtons, Float.NaN); | 50 Arrays.fill(mMappedButtons, Float.NaN); |
| 52 Arrays.fill(mMappedAxes, Float.NaN); | 51 Arrays.fill(mMappedAxes, Float.NaN); |
| 53 | 52 |
| 54 // Set each raw value to something unique. | 53 // Set each raw value to something unique. |
| 55 for (int i = 0; i < GamepadDevice.MAX_RAW_AXIS_VALUES; i++) { | 54 for (int i = 0; i < GamepadDevice.MAX_RAW_AXIS_VALUES; i++) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 mRawAxes[MotionEvent.AXIS_RY], ERROR_TOLERANCE); | 299 mRawAxes[MotionEvent.AXIS_RY], ERROR_TOLERANCE); |
| 301 } | 300 } |
| 302 | 301 |
| 303 private void assertMappedZAndRZAxesToRightStick() { | 302 private void assertMappedZAndRZAxesToRightStick() { |
| 304 Assert.assertEquals(mMappedAxes[CanonicalAxisIndex.RIGHT_STICK_X], | 303 Assert.assertEquals(mMappedAxes[CanonicalAxisIndex.RIGHT_STICK_X], |
| 305 mRawAxes[MotionEvent.AXIS_Z], ERROR_TOLERANCE); | 304 mRawAxes[MotionEvent.AXIS_Z], ERROR_TOLERANCE); |
| 306 Assert.assertEquals(mMappedAxes[CanonicalAxisIndex.RIGHT_STICK_Y], | 305 Assert.assertEquals(mMappedAxes[CanonicalAxisIndex.RIGHT_STICK_Y], |
| 307 mRawAxes[MotionEvent.AXIS_RZ], ERROR_TOLERANCE); | 306 mRawAxes[MotionEvent.AXIS_RZ], ERROR_TOLERANCE); |
| 308 } | 307 } |
| 309 } | 308 } |
| OLD | NEW |