Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(841)

Unified Diff: device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java

Issue 2674613003: git cl format //device/sensors (Closed)
Patch Set: git cl format //device/sensors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java
diff --git a/device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java b/device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java
index 988f09211e180ca5f4e7572c27df27e4e2ee78cc..faf41374d41044fa09450f346938d4377da6fb7b 100644
--- a/device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java
+++ b/device/sensors/android/javatests/src/org/chromium/device/sensors/DeviceSensorsTest.java
@@ -19,7 +19,6 @@ import java.util.Set;
* Test suite for DeviceSensors.
*/
public class DeviceSensorsTest extends AndroidTestCase {
-
private DeviceSensorsForTests mDeviceSensors;
private MockSensorManager mMockSensorManager;
@@ -37,14 +36,12 @@ public class DeviceSensorsTest extends AndroidTestCase {
assertTrue(start);
assertTrue("should contain all motion sensors",
- mDeviceSensors.mActiveSensors.containsAll(
- DeviceSensors.DEVICE_MOTION_SENSORS));
+ mDeviceSensors.mActiveSensors.containsAll(DeviceSensors.DEVICE_MOTION_SENSORS));
assertTrue(mDeviceSensors.mDeviceMotionIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
assertFalse(mDeviceSensors.mDeviceLightIsActive);
- assertEquals(DeviceSensors.DEVICE_MOTION_SENSORS.size(),
- mMockSensorManager.mNumRegistered);
+ assertEquals(DeviceSensors.DEVICE_MOTION_SENSORS.size(), mMockSensorManager.mNumRegistered);
assertEquals(0, mMockSensorManager.mNumUnRegistered);
assertEquals(DeviceSensors.DEVICE_MOTION_SENSORS.size(),
mDeviceSensors.getNumberActiveDeviceMotionSensors());
@@ -126,8 +123,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActiveWithBackupSensors);
assertTrue(mDeviceSensors.mActiveSensors.isEmpty());
- assertEquals(OrientationSensorType.NOT_AVAILABLE,
- mDeviceSensors.getOrientationSensorTypeUsed());
+ assertEquals(
+ OrientationSensorType.NOT_AVAILABLE, mDeviceSensors.getOrientationSensorTypeUsed());
assertEquals(0, mockSensorManager.mNumRegistered);
assertEquals(0, mockSensorManager.mNumUnRegistered);
@@ -141,8 +138,7 @@ public class DeviceSensorsTest extends AndroidTestCase {
assertTrue(startOrientation);
assertTrue(startMotion);
assertTrue("should contain all motion sensors",
- mDeviceSensors.mActiveSensors.containsAll(
- DeviceSensors.DEVICE_MOTION_SENSORS));
+ mDeviceSensors.mActiveSensors.containsAll(DeviceSensors.DEVICE_MOTION_SENSORS));
assertTrue("should contain all orientation sensors",
mDeviceSensors.mActiveSensors.containsAll(
DeviceSensors.DEVICE_ORIENTATION_SENSORS_A));
@@ -184,8 +180,7 @@ public class DeviceSensorsTest extends AndroidTestCase {
mDeviceSensors.start(0, ConsumerType.ORIENTATION_ABSOLUTE, 100);
mDeviceSensors.stop(ConsumerType.ORIENTATION_ABSOLUTE);
- assertTrue("should contain no sensors",
- mDeviceSensors.mActiveSensors.isEmpty());
+ assertTrue("should contain no sensors", mDeviceSensors.mActiveSensors.isEmpty());
assertFalse(mDeviceSensors.mDeviceMotionIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActiveWithBackupSensors);
@@ -197,8 +192,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
@SmallTest
public void testRegisterSensorsDeviceOrientationAndOrientationAbsolute() {
boolean startOrientation = mDeviceSensors.start(0, ConsumerType.ORIENTATION, 100);
- boolean startOrientationAbsolute = mDeviceSensors.start(0,
- ConsumerType.ORIENTATION_ABSOLUTE, 100);
+ boolean startOrientationAbsolute =
+ mDeviceSensors.start(0, ConsumerType.ORIENTATION_ABSOLUTE, 100);
assertTrue(startOrientation);
assertTrue(startOrientationAbsolute);
@@ -230,8 +225,7 @@ public class DeviceSensorsTest extends AndroidTestCase {
assertFalse(mDeviceSensors.mDeviceMotionIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
- assertEquals(DeviceSensors.DEVICE_LIGHT_SENSORS.size(),
- mMockSensorManager.mNumRegistered);
+ assertEquals(DeviceSensors.DEVICE_LIGHT_SENSORS.size(), mMockSensorManager.mNumRegistered);
assertEquals(0, mMockSensorManager.mNumUnRegistered);
}
@@ -240,13 +234,12 @@ public class DeviceSensorsTest extends AndroidTestCase {
mDeviceSensors.start(0, ConsumerType.MOTION, 100);
mDeviceSensors.stop(ConsumerType.MOTION);
- assertTrue("should contain no sensors",
- mDeviceSensors.mActiveSensors.isEmpty());
+ assertTrue("should contain no sensors", mDeviceSensors.mActiveSensors.isEmpty());
assertFalse(mDeviceSensors.mDeviceMotionIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
assertFalse(mDeviceSensors.mDeviceLightIsActive);
- assertEquals(DeviceSensors.DEVICE_MOTION_SENSORS.size(),
- mMockSensorManager.mNumUnRegistered);
+ assertEquals(
+ DeviceSensors.DEVICE_MOTION_SENSORS.size(), mMockSensorManager.mNumUnRegistered);
assertEquals(0, mDeviceSensors.getNumberActiveDeviceMotionSensors());
}
@@ -255,8 +248,7 @@ public class DeviceSensorsTest extends AndroidTestCase {
mDeviceSensors.start(0, ConsumerType.ORIENTATION, 100);
mDeviceSensors.stop(ConsumerType.ORIENTATION);
- assertTrue("should contain no sensors",
- mDeviceSensors.mActiveSensors.isEmpty());
+ assertTrue("should contain no sensors", mDeviceSensors.mActiveSensors.isEmpty());
assertFalse(mDeviceSensors.mDeviceMotionIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActive);
assertFalse(mDeviceSensors.mDeviceOrientationIsActiveWithBackupSensors);
@@ -316,8 +308,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
* Helper method to trigger an orientation change using the given sensorType.
*/
private void changeOrientation(int sensorType, boolean absolute, String expectedChange) {
- boolean startOrientation = mDeviceSensors.start(0,
- absolute ? ConsumerType.ORIENTATION_ABSOLUTE : ConsumerType.ORIENTATION, 100);
+ boolean startOrientation = mDeviceSensors.start(
+ 0, absolute ? ConsumerType.ORIENTATION_ABSOLUTE : ConsumerType.ORIENTATION, 100);
assertTrue(startOrientation);
assertTrue(absolute ? mDeviceSensors.mDeviceOrientationAbsoluteIsActive
@@ -345,8 +337,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
@SmallTest
public void testSensorChangedGotOrientationAbsoluteViaRotationVector() {
- changeOrientation(Sensor.TYPE_ROTATION_VECTOR, true /* absolute */,
- "gotOrientationAbsolute");
+ changeOrientation(
+ Sensor.TYPE_ROTATION_VECTOR, true /* absolute */, "gotOrientationAbsolute");
}
@SmallTest
@@ -357,8 +349,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
@SmallTest
public void testSensorChangedGotOrientationAndOrientationAbsolute() {
changeOrientation(Sensor.TYPE_GAME_ROTATION_VECTOR, false /* absolute */, "gotOrientation");
- changeOrientation(Sensor.TYPE_ROTATION_VECTOR, true /* absolute */,
- "gotOrientation" + "gotOrientationAbsolute");
+ changeOrientation(Sensor.TYPE_ROTATION_VECTOR, true /* absolute */, "gotOrientation"
+ + "gotOrientationAbsolute");
}
@SmallTest
@@ -368,8 +360,9 @@ public class DeviceSensorsTest extends AndroidTestCase {
mDeviceSensors.setSensorManagerProxy(mockSensorManager);
changeOrientation(Sensor.TYPE_ROTATION_VECTOR, false /* absolute */, "gotOrientation");
- changeOrientation(Sensor.TYPE_ROTATION_VECTOR, true /* absolute */,
- "gotOrientation" + "gotOrientationAbsolute" + "gotOrientation");
+ changeOrientation(Sensor.TYPE_ROTATION_VECTOR, true /* absolute */, "gotOrientation"
+ + "gotOrientationAbsolute"
+ + "gotOrientation");
}
@SmallTest
@@ -420,7 +413,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
float[] values2 = {1, 2, 3};
mDeviceSensors.sensorChanged(Sensor.TYPE_ACCELEROMETER, values2);
- mDeviceSensors.verifyCalls("gotOrientation" + "gotAccelerationIncludingGravity");
+ mDeviceSensors.verifyCalls("gotOrientation"
+ + "gotAccelerationIncludingGravity");
mDeviceSensors.verifyValues(1, 2, 3);
}
@@ -466,7 +460,7 @@ public class DeviceSensorsTest extends AndroidTestCase {
public void testOrientationAnglesFromRotationMatrixGimbalLock() {
float[] gravity = {0, 1, 0};
float[] magnetic = {(float) Math.sin(Math.PI / 4), 0, -(float) Math.cos(Math.PI / 4)};
- double[] expectedAngles = {Math.PI / 4, Math.PI / 2, 0}; // favor yaw instead of roll
+ double[] expectedAngles = {Math.PI / 4, Math.PI / 2, 0}; // favor yaw instead of roll
verifyOrientationAngles(gravity, magnetic, expectedAngles);
}
@@ -503,8 +497,8 @@ public class DeviceSensorsTest extends AndroidTestCase {
* expectedAngles[1] rotation angle in radians around the X-axis
* expectedAngles[2] rotation angle in radians around the Y-axis
*/
- private void verifyOrientationAngles(float[] gravity, float[] magnetic,
- double[] expectedAngles) {
+ private void verifyOrientationAngles(
+ float[] gravity, float[] magnetic, double[] expectedAngles) {
float[] r = new float[9];
double[] values = new double[3];
SensorManager.getRotationMatrix(r, null, gravity, magnetic);
@@ -515,13 +509,11 @@ public class DeviceSensorsTest extends AndroidTestCase {
for (int i = 0; i < expectedAngles.length; ++i) {
assertEquals(expectedAngles[i], values[i], epsilon);
}
-
}
// -- End Tests for correct Device Orientation angles.
private static class DeviceSensorsForTests extends DeviceSensors {
-
private double mValue1 = 0;
private double mValue2 = 0;
private double mValue3 = 0;
@@ -603,15 +595,13 @@ public class DeviceSensorsTest extends AndroidTestCase {
}
private static class MockSensorManager implements DeviceSensors.SensorManagerProxy {
-
private int mNumRegistered = 0;
private int mNumUnRegistered = 0;
private boolean mRotationVectorAvailable = true;
private boolean mGameRotationVectorAvailable = true;
private boolean mAccelerometerAvailable = true;
- private MockSensorManager() {
- }
+ private MockSensorManager() {}
public void setGameRotationVectorAvailable(boolean available) {
mGameRotationVectorAvailable = available;
@@ -627,16 +617,19 @@ public class DeviceSensorsTest extends AndroidTestCase {
private boolean isSensorTypeAvailable(int sensorType) {
switch (sensorType) {
- case Sensor.TYPE_ROTATION_VECTOR : return mRotationVectorAvailable;
- case Sensor.TYPE_GAME_ROTATION_VECTOR : return mGameRotationVectorAvailable;
- case Sensor.TYPE_ACCELEROMETER : return mAccelerometerAvailable;
+ case Sensor.TYPE_ROTATION_VECTOR:
+ return mRotationVectorAvailable;
+ case Sensor.TYPE_GAME_ROTATION_VECTOR:
+ return mGameRotationVectorAvailable;
+ case Sensor.TYPE_ACCELEROMETER:
+ return mAccelerometerAvailable;
}
return true;
}
@Override
- public boolean registerListener(SensorEventListener listener, int sensorType, int rate,
- Handler handler) {
+ public boolean registerListener(
+ SensorEventListener listener, int sensorType, int rate, Handler handler) {
if (isSensorTypeAvailable(sensorType)) {
mNumRegistered++;
return true;

Powered by Google App Engine
This is Rietveld 408576698