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 #include <SensorsApi.h> | 5 #include <SensorsApi.h> |
6 #include <Sensors.h> // NOLINT | 6 #include <Sensors.h> // NOLINT |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 PlatformSensorProviderWin::GetInstance()->CreateSensor( | 217 PlatformSensorProviderWin::GetInstance()->CreateSensor( |
218 type, base::Bind(&PlatformSensorAndProviderTestWin::SensorCreated, | 218 type, base::Bind(&PlatformSensorAndProviderTestWin::SensorCreated, |
219 base::Unretained(this))); | 219 base::Unretained(this))); |
220 run_loop_->Run(); | 220 run_loop_->Run(); |
221 scoped_refptr<PlatformSensor> sensor; | 221 scoped_refptr<PlatformSensor> sensor; |
222 sensor.swap(platform_sensor_); | 222 sensor.swap(platform_sensor_); |
223 run_loop_ = nullptr; | 223 run_loop_ = nullptr; |
224 return sensor; | 224 return sensor; |
225 } | 225 } |
226 | 226 |
227 // Listening the sensor is asynchronous, therefore inner loop is used to wait | |
228 // for SetEventSink to be called. | |
229 bool StartListening(scoped_refptr<PlatformSensor> sensor, | |
230 PlatformSensor::Client* client, | |
231 const PlatformSensorConfiguration& config) { | |
232 run_loop_ = base::MakeUnique<base::RunLoop>(); | |
233 bool ret = sensor->StartListening(client, config); | |
234 run_loop_->Run(); | |
235 run_loop_ = nullptr; | |
236 return ret; | |
237 } | |
238 | |
239 void QuitInnerLoop() { run_loop_->Quit(); } | |
240 | |
227 // Sets sensor with REFSENSOR_TYPE_ID |sensor| to be supported by mocked | 241 // Sets sensor with REFSENSOR_TYPE_ID |sensor| to be supported by mocked |
228 // ISensorMager and it will be present in ISensorCollection. | 242 // ISensorMager and it will be present in ISensorCollection. |
229 void SetSupportedSensor(REFSENSOR_TYPE_ID sensor) { | 243 void SetSupportedSensor(REFSENSOR_TYPE_ID sensor) { |
230 // Returns mock ISensorCollection. | 244 // Returns mock ISensorCollection. |
231 EXPECT_CALL(*sensor_manager_, GetSensorsByType(sensor, _)) | 245 EXPECT_CALL(*sensor_manager_, GetSensorsByType(sensor, _)) |
232 .WillOnce(Invoke( | 246 .WillOnce(Invoke( |
233 [this](REFSENSOR_TYPE_ID type, ISensorCollection** collection) { | 247 [this](REFSENSOR_TYPE_ID type, ISensorCollection** collection) { |
234 sensor_collection_->QueryInterface( | 248 sensor_collection_->QueryInterface( |
235 __uuidof(ISensorCollection), | 249 __uuidof(ISensorCollection), |
236 reinterpret_cast<void**>(collection)); | 250 reinterpret_cast<void**>(collection)); |
(...skipping 17 matching lines...) Expand all Loading... | |
254 })); | 268 })); |
255 | 269 |
256 // Handles |SetEventSink| call that is used to subscribe to sensor events | 270 // Handles |SetEventSink| call that is used to subscribe to sensor events |
257 // through ISensorEvents interface. ISensorEvents is stored and attached to | 271 // through ISensorEvents interface. ISensorEvents is stored and attached to |
258 // |sensor_events_| that is used later to generate fake error, state and | 272 // |sensor_events_| that is used later to generate fake error, state and |
259 // data change events. | 273 // data change events. |
260 ON_CALL(*sensor_, SetEventSink(NotNull())) | 274 ON_CALL(*sensor_, SetEventSink(NotNull())) |
261 .WillByDefault(Invoke([this](ISensorEvents* events) { | 275 .WillByDefault(Invoke([this](ISensorEvents* events) { |
262 events->AddRef(); | 276 events->AddRef(); |
263 sensor_events_.Attach(events); | 277 sensor_events_.Attach(events); |
278 if (this->run_loop_) { | |
279 message_loop_.task_runner()->PostTask( | |
280 FROM_HERE, | |
281 base::Bind(&PlatformSensorAndProviderTestWin::QuitInnerLoop, | |
282 base::Unretained(this))); | |
283 } | |
264 return S_OK; | 284 return S_OK; |
265 })); | 285 })); |
266 | 286 |
267 // When |SetEventSink| is called with nullptr, it means that client is no | 287 // When |SetEventSink| is called with nullptr, it means that client is no |
268 // longer interested in sensor events and ISensorEvents can be released. | 288 // longer interested in sensor events and ISensorEvents can be released. |
269 ON_CALL(*sensor_, SetEventSink(IsNull())) | 289 ON_CALL(*sensor_, SetEventSink(IsNull())) |
270 .WillByDefault(Invoke([this](ISensorEvents* events) { | 290 .WillByDefault(Invoke([this](ISensorEvents* events) { |
271 sensor_events_.Release(); | 291 sensor_events_.Release(); |
292 if (this->run_loop_) { | |
293 message_loop_.task_runner()->PostTask( | |
294 FROM_HERE, | |
295 base::Bind(&PlatformSensorAndProviderTestWin::QuitInnerLoop, | |
296 base::Unretained(this))); | |
297 } | |
272 return S_OK; | 298 return S_OK; |
273 })); | 299 })); |
274 } | 300 } |
275 | 301 |
276 // Sets minimal reporting frequency for the mock sensor. | 302 // Sets minimal reporting frequency for the mock sensor. |
277 void SetSupportedReportingFrequency(double frequency) { | 303 void SetSupportedReportingFrequency(double frequency) { |
278 ON_CALL(*sensor_, GetProperty(SENSOR_PROPERTY_MIN_REPORT_INTERVAL, _)) | 304 ON_CALL(*sensor_, GetProperty(SENSOR_PROPERTY_MIN_REPORT_INTERVAL, _)) |
279 .WillByDefault( | 305 .WillByDefault( |
280 Invoke([frequency](REFPROPERTYKEY key, PROPVARIANT* pProperty) { | 306 Invoke([frequency](REFPROPERTYKEY key, PROPVARIANT* pProperty) { |
281 pProperty->vt = VT_UI4; | 307 pProperty->vt = VT_UI4; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 | 452 |
427 // Tests that PlatformSensor::StartListening succeeds and notification about | 453 // Tests that PlatformSensor::StartListening succeeds and notification about |
428 // modified sensor reading is sent to the PlatformSensor::Client interface. | 454 // modified sensor reading is sent to the PlatformSensor::Client interface. |
429 TEST_F(PlatformSensorAndProviderTestWin, SensorStarted) { | 455 TEST_F(PlatformSensorAndProviderTestWin, SensorStarted) { |
430 SetSupportedReportingFrequency(10); | 456 SetSupportedReportingFrequency(10); |
431 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); | 457 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); |
432 | 458 |
433 EXPECT_CALL(*sensor_, SetEventSink(NotNull())).Times(1); | 459 EXPECT_CALL(*sensor_, SetEventSink(NotNull())).Times(1); |
434 EXPECT_CALL(*sensor_, SetEventSink(IsNull())).Times(1); | 460 EXPECT_CALL(*sensor_, SetEventSink(IsNull())).Times(1); |
435 EXPECT_CALL(*sensor_, SetProperties(NotNull(), _)) | 461 EXPECT_CALL(*sensor_, SetProperties(NotNull(), _)) |
436 .WillOnce(Invoke( | 462 .WillRepeatedly(Invoke( |
437 [](IPortableDeviceValues* props, IPortableDeviceValues** result) { | 463 [](IPortableDeviceValues* props, IPortableDeviceValues** result) { |
438 ULONG value = 0; | 464 ULONG value = 0; |
439 HRESULT hr = props->GetUnsignedIntegerValue( | 465 HRESULT hr = props->GetUnsignedIntegerValue( |
440 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, &value); | 466 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, &value); |
441 EXPECT_TRUE(SUCCEEDED(hr)); | 467 EXPECT_TRUE(SUCCEEDED(hr)); |
442 // 10Hz is 100msec | 468 // 10Hz is 100msec |
443 EXPECT_THAT(value, 100); | 469 EXPECT_THAT(value, 100); |
444 return hr; | 470 return hr; |
445 })); | 471 })); |
446 | 472 |
447 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); | 473 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); |
448 EXPECT_TRUE(sensor); | 474 EXPECT_TRUE(sensor); |
449 | 475 |
450 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 476 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
451 PlatformSensorConfiguration configuration(10); | 477 PlatformSensorConfiguration configuration(10); |
452 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 478 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
453 | 479 |
454 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); | 480 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); |
455 GenerateDataUpdatedEvent({{SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, 3.14}}); | 481 GenerateDataUpdatedEvent({{SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, 3.14}}); |
456 base::RunLoop().RunUntilIdle(); | 482 base::RunLoop().RunUntilIdle(); |
457 EXPECT_TRUE(sensor->StopListening(client.get(), configuration)); | 483 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); |
Reilly Grant (use Gerrit)
2016/11/29 16:06:57
StopListening became StartListening here.
| |
458 } | 484 } |
459 | 485 |
460 // Tests that OnSensorError is called when sensor is disconnected. | 486 // Tests that OnSensorError is called when sensor is disconnected. |
461 TEST_F(PlatformSensorAndProviderTestWin, SensorRemoved) { | 487 TEST_F(PlatformSensorAndProviderTestWin, SensorRemoved) { |
462 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); | 488 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); |
463 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); | 489 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); |
464 EXPECT_TRUE(sensor); | 490 EXPECT_TRUE(sensor); |
465 | 491 |
466 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 492 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
467 PlatformSensorConfiguration configuration(10); | 493 PlatformSensorConfiguration configuration(10); |
468 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 494 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
469 EXPECT_CALL(*client, OnSensorError()).Times(1); | 495 EXPECT_CALL(*client, OnSensorError()).Times(1); |
470 | 496 |
471 GenerateLeaveEvent(); | 497 GenerateLeaveEvent(); |
472 base::RunLoop().RunUntilIdle(); | 498 base::RunLoop().RunUntilIdle(); |
473 } | 499 } |
474 | 500 |
475 // Tests that OnSensorError is called when sensor is in an error state. | 501 // Tests that OnSensorError is called when sensor is in an error state. |
476 TEST_F(PlatformSensorAndProviderTestWin, SensorStateChangedToError) { | 502 TEST_F(PlatformSensorAndProviderTestWin, SensorStateChangedToError) { |
477 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); | 503 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); |
478 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); | 504 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); |
479 EXPECT_TRUE(sensor); | 505 EXPECT_TRUE(sensor); |
480 | 506 |
481 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 507 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
482 PlatformSensorConfiguration configuration(10); | 508 PlatformSensorConfiguration configuration(10); |
483 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 509 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
484 EXPECT_CALL(*client, OnSensorError()).Times(1); | 510 EXPECT_CALL(*client, OnSensorError()).Times(1); |
485 | 511 |
486 GenerateStateChangeEvent(SENSOR_STATE_ERROR); | 512 GenerateStateChangeEvent(SENSOR_STATE_ERROR); |
487 base::RunLoop().RunUntilIdle(); | 513 base::RunLoop().RunUntilIdle(); |
488 } | 514 } |
489 | 515 |
490 // Tests that OnSensorError is not called when sensor is in a ready state. | 516 // Tests that OnSensorError is not called when sensor is in a ready state. |
491 TEST_F(PlatformSensorAndProviderTestWin, SensorStateChangedToReady) { | 517 TEST_F(PlatformSensorAndProviderTestWin, SensorStateChangedToReady) { |
492 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); | 518 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); |
493 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); | 519 auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); |
494 EXPECT_TRUE(sensor); | 520 EXPECT_TRUE(sensor); |
495 | 521 |
496 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 522 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
497 PlatformSensorConfiguration configuration(10); | 523 PlatformSensorConfiguration configuration(10); |
498 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 524 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
499 EXPECT_CALL(*client, OnSensorError()).Times(0); | 525 EXPECT_CALL(*client, OnSensorError()).Times(0); |
500 | 526 |
501 GenerateStateChangeEvent(SENSOR_STATE_READY); | 527 GenerateStateChangeEvent(SENSOR_STATE_READY); |
502 base::RunLoop().RunUntilIdle(); | 528 base::RunLoop().RunUntilIdle(); |
503 } | 529 } |
504 | 530 |
505 // Tests that GetMaximumSupportedFrequency provides correct value. | 531 // Tests that GetMaximumSupportedFrequency provides correct value. |
506 TEST_F(PlatformSensorAndProviderTestWin, GetMaximumSupportedFrequency) { | 532 TEST_F(PlatformSensorAndProviderTestWin, GetMaximumSupportedFrequency) { |
507 SetSupportedReportingFrequency(20); | 533 SetSupportedReportingFrequency(20); |
508 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); | 534 SetSupportedSensor(SENSOR_TYPE_AMBIENT_LIGHT); |
(...skipping 18 matching lines...) Expand all Loading... | |
527 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( | 553 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( |
528 sizeof(SensorReadingSharedBuffer), | 554 sizeof(SensorReadingSharedBuffer), |
529 SensorReadingSharedBuffer::GetOffset(SensorType::ACCELEROMETER)); | 555 SensorReadingSharedBuffer::GetOffset(SensorType::ACCELEROMETER)); |
530 | 556 |
531 SetSupportedSensor(SENSOR_TYPE_ACCELEROMETER_3D); | 557 SetSupportedSensor(SENSOR_TYPE_ACCELEROMETER_3D); |
532 auto sensor = CreateSensor(SensorType::ACCELEROMETER); | 558 auto sensor = CreateSensor(SensorType::ACCELEROMETER); |
533 EXPECT_TRUE(sensor); | 559 EXPECT_TRUE(sensor); |
534 | 560 |
535 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 561 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
536 PlatformSensorConfiguration configuration(10); | 562 PlatformSensorConfiguration configuration(10); |
537 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 563 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
538 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); | 564 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); |
539 | 565 |
540 double x_accel = 0.25; | 566 double x_accel = 0.25; |
541 double y_accel = -0.25; | 567 double y_accel = -0.25; |
542 double z_accel = -0.5; | 568 double z_accel = -0.5; |
543 GenerateDataUpdatedEvent({{SENSOR_DATA_TYPE_ACCELERATION_X_G, x_accel}, | 569 GenerateDataUpdatedEvent({{SENSOR_DATA_TYPE_ACCELERATION_X_G, x_accel}, |
544 {SENSOR_DATA_TYPE_ACCELERATION_Y_G, y_accel}, | 570 {SENSOR_DATA_TYPE_ACCELERATION_Y_G, y_accel}, |
545 {SENSOR_DATA_TYPE_ACCELERATION_Z_G, z_accel}}); | 571 {SENSOR_DATA_TYPE_ACCELERATION_Z_G, z_accel}}); |
546 | 572 |
547 base::RunLoop().RunUntilIdle(); | 573 base::RunLoop().RunUntilIdle(); |
(...skipping 12 matching lines...) Expand all Loading... | |
560 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( | 586 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( |
561 sizeof(SensorReadingSharedBuffer), | 587 sizeof(SensorReadingSharedBuffer), |
562 SensorReadingSharedBuffer::GetOffset(SensorType::GYROSCOPE)); | 588 SensorReadingSharedBuffer::GetOffset(SensorType::GYROSCOPE)); |
563 | 589 |
564 SetSupportedSensor(SENSOR_TYPE_GYROMETER_3D); | 590 SetSupportedSensor(SENSOR_TYPE_GYROMETER_3D); |
565 auto sensor = CreateSensor(SensorType::GYROSCOPE); | 591 auto sensor = CreateSensor(SensorType::GYROSCOPE); |
566 EXPECT_TRUE(sensor); | 592 EXPECT_TRUE(sensor); |
567 | 593 |
568 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 594 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
569 PlatformSensorConfiguration configuration(10); | 595 PlatformSensorConfiguration configuration(10); |
570 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 596 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
571 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); | 597 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); |
572 | 598 |
573 double x_ang_accel = 0.0; | 599 double x_ang_accel = 0.0; |
574 double y_ang_accel = -1.8; | 600 double y_ang_accel = -1.8; |
575 double z_ang_accel = -98.7; | 601 double z_ang_accel = -98.7; |
576 | 602 |
577 GenerateDataUpdatedEvent( | 603 GenerateDataUpdatedEvent( |
578 {{SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_X_DEGREES_PER_SECOND_SQUARED, | 604 {{SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_X_DEGREES_PER_SECOND_SQUARED, |
579 x_ang_accel}, | 605 x_ang_accel}, |
580 {SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_Y_DEGREES_PER_SECOND_SQUARED, | 606 {SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_Y_DEGREES_PER_SECOND_SQUARED, |
(...skipping 20 matching lines...) Expand all Loading... | |
601 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( | 627 mojo::ScopedSharedBufferMapping mapping = handle->MapAtOffset( |
602 sizeof(SensorReadingSharedBuffer), | 628 sizeof(SensorReadingSharedBuffer), |
603 SensorReadingSharedBuffer::GetOffset(SensorType::MAGNETOMETER)); | 629 SensorReadingSharedBuffer::GetOffset(SensorType::MAGNETOMETER)); |
604 | 630 |
605 SetSupportedSensor(SENSOR_TYPE_COMPASS_3D); | 631 SetSupportedSensor(SENSOR_TYPE_COMPASS_3D); |
606 auto sensor = CreateSensor(SensorType::MAGNETOMETER); | 632 auto sensor = CreateSensor(SensorType::MAGNETOMETER); |
607 EXPECT_TRUE(sensor); | 633 EXPECT_TRUE(sensor); |
608 | 634 |
609 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); | 635 auto client = base::MakeUnique<NiceMock<MockPlatformSensorClient>>(sensor); |
610 PlatformSensorConfiguration configuration(10); | 636 PlatformSensorConfiguration configuration(10); |
611 EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); | 637 EXPECT_TRUE(StartListening(sensor, client.get(), configuration)); |
612 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); | 638 EXPECT_CALL(*client, OnSensorReadingChanged()).Times(1); |
613 | 639 |
614 double x_magn_field = 112.0; | 640 double x_magn_field = 112.0; |
615 double y_magn_field = -162.0; | 641 double y_magn_field = -162.0; |
616 double z_magn_field = 457.0; | 642 double z_magn_field = 457.0; |
617 | 643 |
618 GenerateDataUpdatedEvent( | 644 GenerateDataUpdatedEvent( |
619 {{SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS, x_magn_field}, | 645 {{SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS, x_magn_field}, |
620 {SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS, y_magn_field}, | 646 {SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS, y_magn_field}, |
621 {SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS, z_magn_field}}); | 647 {SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS, z_magn_field}}); |
622 | 648 |
623 base::RunLoop().RunUntilIdle(); | 649 base::RunLoop().RunUntilIdle(); |
624 SensorReadingSharedBuffer* buffer = | 650 SensorReadingSharedBuffer* buffer = |
625 static_cast<SensorReadingSharedBuffer*>(mapping.get()); | 651 static_cast<SensorReadingSharedBuffer*>(mapping.get()); |
626 EXPECT_THAT(buffer->reading.values[0], | 652 EXPECT_THAT(buffer->reading.values[0], |
627 -x_magn_field * kMicroteslaInMilligauss); | 653 -x_magn_field * kMicroteslaInMilligauss); |
628 EXPECT_THAT(buffer->reading.values[1], | 654 EXPECT_THAT(buffer->reading.values[1], |
629 -y_magn_field * kMicroteslaInMilligauss); | 655 -y_magn_field * kMicroteslaInMilligauss); |
630 EXPECT_THAT(buffer->reading.values[2], | 656 EXPECT_THAT(buffer->reading.values[2], |
631 -z_magn_field * kMicroteslaInMilligauss); | 657 -z_magn_field * kMicroteslaInMilligauss); |
632 EXPECT_TRUE(sensor->StopListening(client.get(), configuration)); | 658 EXPECT_TRUE(sensor->StopListening(client.get(), configuration)); |
633 } | 659 } |
634 | 660 |
635 } // namespace device | 661 } // namespace device |
OLD | NEW |