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

Side by Side Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h" 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 11 matching lines...) Expand all
22 #include "device/bluetooth/bluetooth_uuid.h" 22 #include "device/bluetooth/bluetooth_uuid.h"
23 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 23 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
24 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" 24 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h"
25 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" 25 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h"
26 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" 26 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h"
27 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
28 28
29 using base::StringPiece; 29 using base::StringPiece;
30 using device::BluetoothAdapter; 30 using device::BluetoothAdapter;
31 using device::BluetoothDevice; 31 using device::BluetoothDevice;
32 using device::BluetoothGattCharacteristic; 32 using device::BluetoothRemoteGattCharacteristic;
33 using device::BluetoothGattService; 33 using device::BluetoothRemoteGattService;
34 using device::BluetoothUUID; 34 using device::BluetoothUUID;
35 using device::MockBluetoothAdapter; 35 using device::MockBluetoothAdapter;
36 using device::MockBluetoothDevice; 36 using device::MockBluetoothDevice;
37 using device::MockBluetoothDiscoverySession; 37 using device::MockBluetoothDiscoverySession;
38 using device::MockBluetoothGattCharacteristic; 38 using device::MockBluetoothGattCharacteristic;
39 using device::MockBluetoothGattConnection; 39 using device::MockBluetoothGattConnection;
40 using device::MockBluetoothGattNotifySession; 40 using device::MockBluetoothGattNotifySession;
41 using device::MockBluetoothGattService; 41 using device::MockBluetoothGattService;
42 using testing::ElementsAre; 42 using testing::ElementsAre;
43 using testing::Invoke; 43 using testing::Invoke;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // that task until GetGattServices is called. 452 // that task until GetGattServices is called.
453 ON_CALL(*device, CreateGattConnection(_, _)) 453 ON_CALL(*device, CreateGattConnection(_, _))
454 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( 454 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
455 [adapter_ptr, device_ptr]() { 455 [adapter_ptr, device_ptr]() {
456 return base::WrapUnique(new NiceMockBluetoothGattConnection( 456 return base::WrapUnique(new NiceMockBluetoothGattConnection(
457 adapter_ptr, device_ptr->GetAddress())); 457 adapter_ptr, device_ptr->GetAddress()));
458 })); 458 }));
459 459
460 ON_CALL(*device, GetGattServices()) 460 ON_CALL(*device, GetGattServices())
461 .WillByDefault(Invoke([adapter_ptr, device_ptr] { 461 .WillByDefault(Invoke([adapter_ptr, device_ptr] {
462 std::vector<BluetoothGattService*> services = 462 std::vector<BluetoothRemoteGattService*> services =
463 device_ptr->GetMockServices(); 463 device_ptr->GetMockServices();
464 464
465 if (services.size() > 0) { 465 if (services.size() > 0) {
466 return services; 466 return services;
467 } 467 }
468 468
469 std::unique_ptr<NiceMockBluetoothGattService> heart_rate( 469 std::unique_ptr<NiceMockBluetoothGattService> heart_rate(
470 GetBaseGATTService(device_ptr, kHeartRateServiceUUID)); 470 GetBaseGATTService(device_ptr, kHeartRateServiceUUID));
471 471
472 device_ptr->AddMockService(std::move(heart_rate)); 472 device_ptr->AddMockService(std::move(heart_rate));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 BluetoothDevice::UUIDList uuids; 550 BluetoothDevice::UUIDList uuids;
551 uuids.push_back(BluetoothUUID(errorsServiceUUID)); 551 uuids.push_back(BluetoothUUID(errorsServiceUUID));
552 552
553 std::unique_ptr<NiceMockBluetoothDevice> device( 553 std::unique_ptr<NiceMockBluetoothDevice> device(
554 GetConnectableDevice(adapter.get(), "Errors Device", uuids)); 554 GetConnectableDevice(adapter.get(), "Errors Device", uuids));
555 555
556 std::unique_ptr<NiceMockBluetoothGattService> service( 556 std::unique_ptr<NiceMockBluetoothGattService> service(
557 GetBaseGATTService(device.get(), errorsServiceUUID)); 557 GetBaseGATTService(device.get(), errorsServiceUUID));
558 558
559 for (int error = BluetoothGattService::GATT_ERROR_UNKNOWN; 559 for (int error = BluetoothRemoteGattService::GATT_ERROR_UNKNOWN;
560 error <= BluetoothGattService::GATT_ERROR_NOT_SUPPORTED; error++) { 560 error <= BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED; error++) {
561 service->AddMockCharacteristic(GetErrorCharacteristic( 561 service->AddMockCharacteristic(GetErrorCharacteristic(
562 service.get(), 562 service.get(),
563 static_cast<BluetoothGattService::GattErrorCode>(error))); 563 static_cast<BluetoothRemoteGattService::GattErrorCode>(error)));
564 } 564 }
565 565
566 device->AddMockService(std::move(service)); 566 device->AddMockService(std::move(service));
567 adapter->AddMockDevice(std::move(device)); 567 adapter->AddMockDevice(std::move(device));
568 568
569 return adapter; 569 return adapter;
570 } 570 }
571 571
572 // Discovery Sessions 572 // Discovery Sessions
573 573
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 std::unique_ptr<NiceMockBluetoothGattService> 724 std::unique_ptr<NiceMockBluetoothGattService>
725 LayoutTestBluetoothAdapterProvider::GetBlacklistTestService( 725 LayoutTestBluetoothAdapterProvider::GetBlacklistTestService(
726 device::MockBluetoothDevice* device) { 726 device::MockBluetoothDevice* device) {
727 std::unique_ptr<NiceMockBluetoothGattService> blacklist_test_service( 727 std::unique_ptr<NiceMockBluetoothGattService> blacklist_test_service(
728 GetBaseGATTService(device, kBlacklistTestServiceUUID)); 728 GetBaseGATTService(device, kBlacklistTestServiceUUID));
729 729
730 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 730 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
731 blacklist_exclude_reads_characteristic(GetBaseGATTCharacteristic( 731 blacklist_exclude_reads_characteristic(GetBaseGATTCharacteristic(
732 "Excluded Reads Characteristic", blacklist_test_service.get(), 732 "Excluded Reads Characteristic", blacklist_test_service.get(),
733 kBlacklistExcludeReadsCharacteristicUUID, 733 kBlacklistExcludeReadsCharacteristicUUID,
734 BluetoothGattCharacteristic::PROPERTY_READ | 734 BluetoothRemoteGattCharacteristic::PROPERTY_READ |
735 BluetoothGattCharacteristic::PROPERTY_WRITE)); 735 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
736 736
737 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect 737 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect
738 // because this is used in layout tests that may not report a mock expectation 738 // because this is used in layout tests that may not report a mock expectation
739 // error correctly as a layout test failure. 739 // error correctly as a layout test failure.
740 ON_CALL(*blacklist_exclude_reads_characteristic, 740 ON_CALL(*blacklist_exclude_reads_characteristic,
741 ReadRemoteCharacteristic(_, _)) 741 ReadRemoteCharacteristic(_, _))
742 .WillByDefault( 742 .WillByDefault(
743 Invoke([](const BluetoothGattCharacteristic::ValueCallback&, 743 Invoke([](const BluetoothRemoteGattCharacteristic::ValueCallback&,
744 const BluetoothGattCharacteristic::ErrorCallback&) { 744 const BluetoothRemoteGattCharacteristic::ErrorCallback&) {
745 NOTREACHED(); 745 NOTREACHED();
746 })); 746 }));
747 747
748 // Write response. 748 // Write response.
749 ON_CALL(*blacklist_exclude_reads_characteristic, 749 ON_CALL(*blacklist_exclude_reads_characteristic,
750 WriteRemoteCharacteristic(_, _, _)) 750 WriteRemoteCharacteristic(_, _, _))
751 .WillByDefault(RunCallback<1 /* success callback */>()); 751 .WillByDefault(RunCallback<1 /* success callback */>());
752 752
753 blacklist_test_service->AddMockCharacteristic( 753 blacklist_test_service->AddMockCharacteristic(
754 std::move(blacklist_exclude_reads_characteristic)); 754 std::move(blacklist_exclude_reads_characteristic));
755 755
756 return blacklist_test_service; 756 return blacklist_test_service;
757 } 757 }
758 758
759 // static 759 // static
760 std::unique_ptr<NiceMockBluetoothGattService> 760 std::unique_ptr<NiceMockBluetoothGattService>
761 LayoutTestBluetoothAdapterProvider::GetDeviceInformationService( 761 LayoutTestBluetoothAdapterProvider::GetDeviceInformationService(
762 device::MockBluetoothDevice* device) { 762 device::MockBluetoothDevice* device) {
763 std::unique_ptr<NiceMockBluetoothGattService> device_information( 763 std::unique_ptr<NiceMockBluetoothGattService> device_information(
764 GetBaseGATTService(device, kDeviceInformationServiceUUID)); 764 GetBaseGATTService(device, kDeviceInformationServiceUUID));
765 765
766 std::unique_ptr<NiceMockBluetoothGattCharacteristic> serial_number_string( 766 std::unique_ptr<NiceMockBluetoothGattCharacteristic> serial_number_string(
767 GetBaseGATTCharacteristic( 767 GetBaseGATTCharacteristic(
768 "Serial Number String", device_information.get(), 768 "Serial Number String", device_information.get(),
769 kSerialNumberStringUUID, BluetoothGattCharacteristic::PROPERTY_READ)); 769 kSerialNumberStringUUID,
770 BluetoothRemoteGattCharacteristic::PROPERTY_READ));
770 771
771 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect 772 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect
772 // because this is used in layout tests that may not report a mock expectation 773 // because this is used in layout tests that may not report a mock expectation
773 // error correctly as a layout test failure. 774 // error correctly as a layout test failure.
774 ON_CALL(*serial_number_string, ReadRemoteCharacteristic(_, _)) 775 ON_CALL(*serial_number_string, ReadRemoteCharacteristic(_, _))
775 .WillByDefault( 776 .WillByDefault(
776 Invoke([](const BluetoothGattCharacteristic::ValueCallback&, 777 Invoke([](const BluetoothRemoteGattCharacteristic::ValueCallback&,
777 const BluetoothGattCharacteristic::ErrorCallback&) { 778 const BluetoothRemoteGattCharacteristic::ErrorCallback&) {
778 NOTREACHED(); 779 NOTREACHED();
779 })); 780 }));
780 781
781 device_information->AddMockCharacteristic(std::move(serial_number_string)); 782 device_information->AddMockCharacteristic(std::move(serial_number_string));
782 783
783 return device_information; 784 return device_information;
784 } 785 }
785 786
786 // static 787 // static
787 std::unique_ptr<NiceMockBluetoothGattService> 788 std::unique_ptr<NiceMockBluetoothGattService>
788 LayoutTestBluetoothAdapterProvider::GetGenericAccessService( 789 LayoutTestBluetoothAdapterProvider::GetGenericAccessService(
789 device::MockBluetoothDevice* device) { 790 device::MockBluetoothDevice* device) {
790 std::unique_ptr<NiceMockBluetoothGattService> generic_access( 791 std::unique_ptr<NiceMockBluetoothGattService> generic_access(
791 GetBaseGATTService(device, kGenericAccessServiceUUID)); 792 GetBaseGATTService(device, kGenericAccessServiceUUID));
792 793
793 { // Device Name: 794 { // Device Name:
794 std::unique_ptr<NiceMockBluetoothGattCharacteristic> device_name( 795 std::unique_ptr<NiceMockBluetoothGattCharacteristic> device_name(
795 GetBaseGATTCharacteristic( 796 GetBaseGATTCharacteristic(
796 "Device Name", generic_access.get(), kDeviceNameUUID, 797 "Device Name", generic_access.get(), kDeviceNameUUID,
797 BluetoothGattCharacteristic::PROPERTY_READ | 798 BluetoothRemoteGattCharacteristic::PROPERTY_READ |
798 BluetoothGattCharacteristic::PROPERTY_WRITE)); 799 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
799 800
800 // Read response. 801 // Read response.
801 std::string device_name_str = device->GetDeviceName(); 802 std::string device_name_str = device->GetDeviceName();
802 std::vector<uint8_t> device_name_value(device_name_str.begin(), 803 std::vector<uint8_t> device_name_value(device_name_str.begin(),
803 device_name_str.end()); 804 device_name_str.end());
804 805
805 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _)) 806 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _))
806 .WillByDefault(RunCallback<0>(device_name_value)); 807 .WillByDefault(RunCallback<0>(device_name_value));
807 808
808 // Write response. 809 // Write response.
809 ON_CALL(*device_name, WriteRemoteCharacteristic(_, _, _)) 810 ON_CALL(*device_name, WriteRemoteCharacteristic(_, _, _))
810 .WillByDefault(RunCallback<1 /* success callback */>()); 811 .WillByDefault(RunCallback<1 /* success callback */>());
811 812
812 generic_access->AddMockCharacteristic(std::move(device_name)); 813 generic_access->AddMockCharacteristic(std::move(device_name));
813 } 814 }
814 815
815 { // Peripheral Privacy Flag: 816 { // Peripheral Privacy Flag:
816 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 817 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
817 peripheral_privacy_flag(GetBaseGATTCharacteristic( 818 peripheral_privacy_flag(GetBaseGATTCharacteristic(
818 "Peripheral Privacy Flag", generic_access.get(), 819 "Peripheral Privacy Flag", generic_access.get(),
819 kPeripheralPrivacyFlagUUID, 820 kPeripheralPrivacyFlagUUID,
820 BluetoothGattCharacteristic::PROPERTY_READ | 821 BluetoothRemoteGattCharacteristic::PROPERTY_READ |
821 BluetoothGattCharacteristic::PROPERTY_WRITE)); 822 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
822 823
823 // Read response. 824 // Read response.
824 std::vector<uint8_t> value(1); 825 std::vector<uint8_t> value(1);
825 value[0] = false; 826 value[0] = false;
826 827
827 ON_CALL(*peripheral_privacy_flag, ReadRemoteCharacteristic(_, _)) 828 ON_CALL(*peripheral_privacy_flag, ReadRemoteCharacteristic(_, _))
828 .WillByDefault(RunCallback<0>(value)); 829 .WillByDefault(RunCallback<0>(value));
829 830
830 // Crash if WriteRemoteCharacteristic called. Not using GoogleMock's Expect 831 // Crash if WriteRemoteCharacteristic called. Not using GoogleMock's Expect
831 // because this is used in layout tests that may not report a mock 832 // because this is used in layout tests that may not report a mock
832 // expectation error correctly as a layout test failure. 833 // expectation error correctly as a layout test failure.
833 ON_CALL(*peripheral_privacy_flag, WriteRemoteCharacteristic(_, _, _)) 834 ON_CALL(*peripheral_privacy_flag, WriteRemoteCharacteristic(_, _, _))
834 .WillByDefault( 835 .WillByDefault(
835 Invoke([](const std::vector<uint8_t>&, const base::Closure&, 836 Invoke([](const std::vector<uint8_t>&, const base::Closure&,
836 const BluetoothGattCharacteristic::ErrorCallback&) { 837 const BluetoothRemoteGattCharacteristic::ErrorCallback&) {
837 NOTREACHED(); 838 NOTREACHED();
838 })); 839 }));
839 840
840 generic_access->AddMockCharacteristic(std::move(peripheral_privacy_flag)); 841 generic_access->AddMockCharacteristic(std::move(peripheral_privacy_flag));
841 } 842 }
842 843
843 return generic_access; 844 return generic_access;
844 } 845 }
845 846
846 // static 847 // static
847 std::unique_ptr<NiceMockBluetoothGattService> 848 std::unique_ptr<NiceMockBluetoothGattService>
848 LayoutTestBluetoothAdapterProvider::GetHeartRateService( 849 LayoutTestBluetoothAdapterProvider::GetHeartRateService(
849 MockBluetoothAdapter* adapter, 850 MockBluetoothAdapter* adapter,
850 MockBluetoothDevice* device) { 851 MockBluetoothDevice* device) {
851 std::unique_ptr<NiceMockBluetoothGattService> heart_rate( 852 std::unique_ptr<NiceMockBluetoothGattService> heart_rate(
852 GetBaseGATTService(device, kHeartRateServiceUUID)); 853 GetBaseGATTService(device, kHeartRateServiceUUID));
853 854
854 // Heart Rate Measurement 855 // Heart Rate Measurement
855 std::unique_ptr<NiceMockBluetoothGattCharacteristic> heart_rate_measurement( 856 std::unique_ptr<NiceMockBluetoothGattCharacteristic> heart_rate_measurement(
856 GetBaseGATTCharacteristic("Heart Rate Measurement", heart_rate.get(), 857 GetBaseGATTCharacteristic(
857 kHeartRateMeasurementUUID, 858 "Heart Rate Measurement", heart_rate.get(), kHeartRateMeasurementUUID,
858 BluetoothGattCharacteristic::PROPERTY_NOTIFY)); 859 BluetoothRemoteGattCharacteristic::PROPERTY_NOTIFY));
859 NiceMockBluetoothGattCharacteristic* measurement_ptr = 860 NiceMockBluetoothGattCharacteristic* measurement_ptr =
860 heart_rate_measurement.get(); 861 heart_rate_measurement.get();
861 862
862 ON_CALL(*heart_rate_measurement, StartNotifySession(_, _)) 863 ON_CALL(*heart_rate_measurement, StartNotifySession(_, _))
863 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( 864 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
864 [adapter, measurement_ptr]() { 865 [adapter, measurement_ptr]() {
865 std::unique_ptr<NiceMockBluetoothGattNotifySession> notify_session( 866 std::unique_ptr<NiceMockBluetoothGattNotifySession> notify_session(
866 GetBaseGATTNotifySession(measurement_ptr->GetIdentifier())); 867 GetBaseGATTNotifySession(measurement_ptr->GetIdentifier()));
867 868
868 std::vector<uint8_t> rate(1 /* size */); 869 std::vector<uint8_t> rate(1 /* size */);
869 rate[0] = 60; 870 rate[0] = 60;
870 871
871 notify_session->StartTestNotifications(adapter, measurement_ptr, 872 notify_session->StartTestNotifications(adapter, measurement_ptr,
872 rate); 873 rate);
873 874
874 return notify_session; 875 return notify_session;
875 })); 876 }));
876 877
877 // Body Sensor Location Characteristic (Chest) 878 // Body Sensor Location Characteristic (Chest)
878 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 879 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
879 body_sensor_location_chest(GetBaseGATTCharacteristic( 880 body_sensor_location_chest(GetBaseGATTCharacteristic(
880 "Body Sensor Location Chest", heart_rate.get(), kBodySensorLocation, 881 "Body Sensor Location Chest", heart_rate.get(), kBodySensorLocation,
881 BluetoothGattCharacteristic::PROPERTY_READ)); 882 BluetoothRemoteGattCharacteristic::PROPERTY_READ));
882 BluetoothGattCharacteristic* location_chest_ptr = 883 BluetoothRemoteGattCharacteristic* location_chest_ptr =
883 body_sensor_location_chest.get(); 884 body_sensor_location_chest.get();
884 885
885 ON_CALL(*body_sensor_location_chest, ReadRemoteCharacteristic(_, _)) 886 ON_CALL(*body_sensor_location_chest, ReadRemoteCharacteristic(_, _))
886 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( 887 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
887 [adapter, location_chest_ptr]() { 888 [adapter, location_chest_ptr]() {
888 std::vector<uint8_t> location(1 /* size */); 889 std::vector<uint8_t> location(1 /* size */);
889 location[0] = 1; // Chest 890 location[0] = 1; // Chest
890 // Read a characteristic has a side effect of 891 // Read a characteristic has a side effect of
891 // GattCharacteristicValueChanged being called. 892 // GattCharacteristicValueChanged being called.
892 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, 893 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
893 adapter->GetObservers(), 894 adapter->GetObservers(),
894 GattCharacteristicValueChanged( 895 GattCharacteristicValueChanged(
895 adapter, location_chest_ptr, location)); 896 adapter, location_chest_ptr, location));
896 return location; 897 return location;
897 })); 898 }));
898 899
899 // Body Sensor Location Characteristic (Wrist) 900 // Body Sensor Location Characteristic (Wrist)
900 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 901 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
901 body_sensor_location_wrist(GetBaseGATTCharacteristic( 902 body_sensor_location_wrist(GetBaseGATTCharacteristic(
902 "Body Sensor Location Wrist", heart_rate.get(), kBodySensorLocation, 903 "Body Sensor Location Wrist", heart_rate.get(), kBodySensorLocation,
903 BluetoothGattCharacteristic::PROPERTY_READ)); 904 BluetoothRemoteGattCharacteristic::PROPERTY_READ));
904 BluetoothGattCharacteristic* location_wrist_ptr = 905 BluetoothRemoteGattCharacteristic* location_wrist_ptr =
905 body_sensor_location_wrist.get(); 906 body_sensor_location_wrist.get();
906 907
907 ON_CALL(*body_sensor_location_wrist, ReadRemoteCharacteristic(_, _)) 908 ON_CALL(*body_sensor_location_wrist, ReadRemoteCharacteristic(_, _))
908 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( 909 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
909 [adapter, location_wrist_ptr]() { 910 [adapter, location_wrist_ptr]() {
910 std::vector<uint8_t> location(1 /* size */); 911 std::vector<uint8_t> location(1 /* size */);
911 location[0] = 2; // Wrist 912 location[0] = 2; // Wrist
912 // Read a characteristic has a side effect of 913 // Read a characteristic has a side effect of
913 // GattCharacteristicValueChanged being called. 914 // GattCharacteristicValueChanged being called.
914 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, 915 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
(...skipping 11 matching lines...) Expand all
926 } 927 }
927 928
928 // Characteristics 929 // Characteristics
929 930
930 // static 931 // static
931 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 932 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
932 LayoutTestBluetoothAdapterProvider::GetBaseGATTCharacteristic( 933 LayoutTestBluetoothAdapterProvider::GetBaseGATTCharacteristic(
933 const std::string& identifier, 934 const std::string& identifier,
934 MockBluetoothGattService* service, 935 MockBluetoothGattService* service,
935 const std::string& uuid, 936 const std::string& uuid,
936 BluetoothGattCharacteristic::Properties properties) { 937 BluetoothRemoteGattCharacteristic::Properties properties) {
937 return base::WrapUnique(new NiceMockBluetoothGattCharacteristic( 938 return base::WrapUnique(new NiceMockBluetoothGattCharacteristic(
938 service, identifier, BluetoothUUID(uuid), false /* is_local */, 939 service, identifier, BluetoothUUID(uuid), false /* is_local */,
939 properties, NULL /* permissions */)); 940 properties, NULL /* permissions */));
940 } 941 }
941 942
942 // static 943 // static
943 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 944 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
944 LayoutTestBluetoothAdapterProvider::GetErrorCharacteristic( 945 LayoutTestBluetoothAdapterProvider::GetErrorCharacteristic(
945 MockBluetoothGattService* service, 946 MockBluetoothGattService* service,
946 BluetoothGattService::GattErrorCode error_code) { 947 BluetoothRemoteGattService::GattErrorCode error_code) {
947 uint32_t error_alias = error_code + 0xA1; // Error UUIDs start at 0xA1. 948 uint32_t error_alias = error_code + 0xA1; // Error UUIDs start at 0xA1.
948 std::unique_ptr<NiceMockBluetoothGattCharacteristic> characteristic( 949 std::unique_ptr<NiceMockBluetoothGattCharacteristic> characteristic(
949 GetBaseGATTCharacteristic( 950 GetBaseGATTCharacteristic(
950 // Use the UUID to generate unique identifiers. 951 // Use the UUID to generate unique identifiers.
951 "Error Characteristic " + errorUUID(error_alias), service, 952 "Error Characteristic " + errorUUID(error_alias), service,
952 errorUUID(error_alias), 953 errorUUID(error_alias),
953 BluetoothGattCharacteristic::PROPERTY_READ | 954 BluetoothRemoteGattCharacteristic::PROPERTY_READ |
954 BluetoothGattCharacteristic::PROPERTY_WRITE | 955 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE |
955 BluetoothGattCharacteristic::PROPERTY_INDICATE)); 956 BluetoothRemoteGattCharacteristic::PROPERTY_INDICATE));
956 957
957 // Read response. 958 // Read response.
958 ON_CALL(*characteristic, ReadRemoteCharacteristic(_, _)) 959 ON_CALL(*characteristic, ReadRemoteCharacteristic(_, _))
959 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); 960 .WillByDefault(RunCallback<1 /* error_callback */>(error_code));
960 961
961 // Write response. 962 // Write response.
962 ON_CALL(*characteristic, WriteRemoteCharacteristic(_, _, _)) 963 ON_CALL(*characteristic, WriteRemoteCharacteristic(_, _, _))
963 .WillByDefault(RunCallback<2 /* error_callback */>(error_code)); 964 .WillByDefault(RunCallback<2 /* error_callback */>(error_code));
964 965
965 // StartNotifySession response 966 // StartNotifySession response
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 return BluetoothUUID(); 1041 return BluetoothUUID();
1041 } 1042 }
1042 1043
1043 // static 1044 // static
1044 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { 1045 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {
1045 return BluetoothDevice::CanonicalizeAddress( 1046 return BluetoothDevice::CanonicalizeAddress(
1046 base::StringPrintf("%012" PRIx64, addr)); 1047 base::StringPrintf("%012" PRIx64, addr));
1047 } 1048 }
1048 1049
1049 } // namespace content 1050 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698