| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.device.sensors; | 5 package org.chromium.device.sensors; |
| 6 | 6 |
| 7 import static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
| 8 import static org.junit.Assert.assertNotNull; | 8 import static org.junit.Assert.assertNotNull; |
| 9 import static org.junit.Assert.assertNull; | 9 import static org.junit.Assert.assertNull; |
| 10 import static org.mockito.ArgumentMatchers.any; | 10 import static org.mockito.ArgumentMatchers.any; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 */ | 250 */ |
| 251 @Test | 251 @Test |
| 252 @Feature({"PlatformSensor"}) | 252 @Feature({"PlatformSensor"}) |
| 253 public void testSensorOnChangeReportingMode() { | 253 public void testSensorOnChangeReportingMode() { |
| 254 PlatformSensor sensor = createPlatformSensor(50000, Sensor.TYPE_LIGHT, | 254 PlatformSensor sensor = createPlatformSensor(50000, Sensor.TYPE_LIGHT, |
| 255 SensorType.AMBIENT_LIGHT, Sensor.REPORTING_MODE_ON_CHANGE); | 255 SensorType.AMBIENT_LIGHT, Sensor.REPORTING_MODE_ON_CHANGE); |
| 256 assertEquals(ReportingMode.ON_CHANGE, sensor.getReportingMode()); | 256 assertEquals(ReportingMode.ON_CHANGE, sensor.getReportingMode()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 /** | 259 /** |
| 260 * Test that PlatformSensor correctly returns its maximum supported frequenc
y. |
| 261 */ |
| 262 @Test |
| 263 @Feature({"PlatformSensor"}) |
| 264 public void testSensorMaximumSupportedFrequency() { |
| 265 PlatformSensor sensor = createPlatformSensor(50000, Sensor.TYPE_LIGHT, |
| 266 SensorType.AMBIENT_LIGHT, Sensor.REPORTING_MODE_ON_CHANGE); |
| 267 assertEquals(20, sensor.getMaximumSupportedFrequency(), 0.001); |
| 268 |
| 269 sensor = createPlatformSensor( |
| 270 0, Sensor.TYPE_LIGHT, SensorType.AMBIENT_LIGHT, Sensor.REPORTING
_MODE_ON_CHANGE); |
| 271 assertEquals( |
| 272 sensor.getDefaultConfiguration(), sensor.getMaximumSupportedFreq
uency(), 0.001); |
| 273 } |
| 274 |
| 275 /** |
| 260 * Test that shared buffer is correctly populated from SensorEvent. | 276 * Test that shared buffer is correctly populated from SensorEvent. |
| 261 */ | 277 */ |
| 262 @Test | 278 @Test |
| 263 @Feature({"PlatformSensor"}) | 279 @Feature({"PlatformSensor"}) |
| 264 public void testSensorReadingFromEvent() { | 280 public void testSensorReadingFromEvent() { |
| 265 TestPlatformSensor sensor = createTestPlatformSensor( | 281 TestPlatformSensor sensor = createTestPlatformSensor( |
| 266 50000, Sensor.TYPE_LIGHT, 1, Sensor.REPORTING_MODE_ON_CHANGE); | 282 50000, Sensor.TYPE_LIGHT, 1, Sensor.REPORTING_MODE_ON_CHANGE); |
| 267 initPlatformSensor(sensor); | 283 initPlatformSensor(sensor); |
| 268 TestPlatformSensor spySensor = spy(sensor); | 284 TestPlatformSensor spySensor = spy(sensor); |
| 269 SensorEvent event = createFakeEvent(1); | 285 SensorEvent event = createFakeEvent(1); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 long minDelayUsec, int androidSensorType, int readingCount, int repo
rtingMode) { | 405 long minDelayUsec, int androidSensorType, int readingCount, int repo
rtingMode) { |
| 390 return new TestPlatformSensor( | 406 return new TestPlatformSensor( |
| 391 createMockSensor(minDelayUsec, androidSensorType, reportingMode)
, readingCount, | 407 createMockSensor(minDelayUsec, androidSensorType, reportingMode)
, readingCount, |
| 392 mPlatformSensorProvider); | 408 mPlatformSensorProvider); |
| 393 } | 409 } |
| 394 | 410 |
| 395 private float getFakeReadingValue(int valueNum) { | 411 private float getFakeReadingValue(int valueNum) { |
| 396 return (float) (valueNum + SECONDS_IN_NANOSECOND); | 412 return (float) (valueNum + SECONDS_IN_NANOSECOND); |
| 397 } | 413 } |
| 398 } | 414 } |
| OLD | NEW |