| Index: device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
|
| diff --git a/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc b/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
|
| index fbe917fe68b439ac74b5a8aab3f7751f6668909b..0112175e6192919c59b37275738fd82571e978bb 100644
|
| --- a/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
|
| +++ b/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include <SensorsApi.h>
|
| +#include <SensorsDef.h>
|
| #include <objbase.h>
|
| #include <propvarutil.h>
|
| #include <sensors.h>
|
| @@ -675,7 +676,7 @@ TEST_F(PlatformSensorAndProviderTestWin, CheckMagnetometerReadingConversion) {
|
|
|
| // Tests that AbsoluteOrientation sensor readings are correctly converted.
|
| TEST_F(PlatformSensorAndProviderTestWin,
|
| - CheckDeviceOrientationReadingConversion) {
|
| + CheckAbsoluteOrientationReadingConversion) {
|
| mojo::ScopedSharedBufferHandle handle =
|
| PlatformSensorProviderWin::GetInstance()->CloneSharedBufferHandle();
|
| mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset(
|
| @@ -720,4 +721,49 @@ TEST_F(PlatformSensorAndProviderTestWin,
|
| EXPECT_TRUE(sensor->StopListening(client.get(), configuration));
|
| }
|
|
|
| +// Tests that RelativeOrientation sensor readings are correctly converted.
|
| +TEST_F(PlatformSensorAndProviderTestWin,
|
| + CheckRelativeOrientationReadingConversion) {
|
| + mojo::ScopedSharedBufferHandle handle =
|
| + PlatformSensorProviderWin::GetInstance()->CloneSharedBufferHandle();
|
| + mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset(
|
| + sizeof(SensorReadingSharedBuffer),
|
| + SensorReadingSharedBuffer::GetOffset(SensorType::RELATIVE_ORIENTATION));
|
| +
|
| + SetSupportedSensor(GUID_SensorType_RelativeOrientation);
|
| + auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION);
|
| + EXPECT_TRUE(sensor);
|
| +
|
| + auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor);
|
| + PlatformSensorConfiguration configuration(10);
|
| + EXPECT_TRUE(StartListening(sensor, client.get(), configuration));
|
| + EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1);
|
| +
|
| + double x = -0.5;
|
| + double y = -0.5;
|
| + double z = 0.5;
|
| + double w = 0.5;
|
| +
|
| + base::win::ScopedPropVariant pv_x, pv_y, pv_z, pv_w;
|
| + InitPropVariantFromDouble(x, pv_x.Receive());
|
| + InitPropVariantFromDouble(y, pv_y.Receive());
|
| + InitPropVariantFromDouble(z, pv_z.Receive());
|
| + InitPropVariantFromDouble(w, pv_w.Receive());
|
| +
|
| + GenerateDataUpdatedEvent({{PKEY_SensorData_QuaternionX, pv_x.ptr()},
|
| + {PKEY_SensorData_QuaternionY, pv_y.ptr()},
|
| + {PKEY_SensorData_QuaternionZ, pv_z.ptr()},
|
| + {PKEY_SensorData_QuaternionW, pv_w.ptr()}});
|
| +
|
| + base::RunLoop().RunUntilIdle();
|
| + SensorReadingSharedBuffer* buffer =
|
| + static_cast<SensorReadingSharedBuffer*>(mapping.get());
|
| +
|
| + EXPECT_THAT(buffer->reading.values[0], -x);
|
| + EXPECT_THAT(buffer->reading.values[1], -y);
|
| + EXPECT_THAT(buffer->reading.values[2], -z);
|
| + EXPECT_THAT(buffer->reading.values[3], w);
|
| + EXPECT_TRUE(sensor->StopListening(client.get(), configuration));
|
| +}
|
| +
|
| } // namespace device
|
|
|