OLD | NEW |
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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 701 |
702 return discovery_session; | 702 return discovery_session; |
703 } | 703 } |
704 | 704 |
705 // Devices | 705 // Devices |
706 | 706 |
707 // static | 707 // static |
708 std::unique_ptr<NiceMockBluetoothDevice> | 708 std::unique_ptr<NiceMockBluetoothDevice> |
709 LayoutTestBluetoothAdapterProvider::GetBaseDevice( | 709 LayoutTestBluetoothAdapterProvider::GetBaseDevice( |
710 MockBluetoothAdapter* adapter, | 710 MockBluetoothAdapter* adapter, |
711 const std::string& device_name, | 711 const char* device_name, |
712 device::BluetoothDevice::UUIDList uuids, | 712 device::BluetoothDevice::UUIDList uuids, |
713 const std::string& address) { | 713 const std::string& address) { |
714 std::unique_ptr<NiceMockBluetoothDevice> device(new NiceMockBluetoothDevice( | 714 std::unique_ptr<NiceMockBluetoothDevice> device(new NiceMockBluetoothDevice( |
715 adapter, 0x1F00 /* Bluetooth class */, device_name, address, | 715 adapter, 0x1F00 /* Bluetooth class */, device_name, address, |
716 true /* paired */, true /* connected */)); | 716 true /* paired */, true /* connected */)); |
717 | 717 |
718 ON_CALL(*device, GetUUIDs()).WillByDefault(Return(uuids)); | 718 ON_CALL(*device, GetUUIDs()).WillByDefault(Return(uuids)); |
719 | 719 |
720 // Using Invoke allows the device returned from this method to be futher | 720 // Using Invoke allows the device returned from this method to be futher |
721 // modified and have more services added to it. The call to ::GetGattServices | 721 // modified and have more services added to it. The call to ::GetGattServices |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 uuids.push_back(BluetoothUUID(kGlucoseServiceUUID)); | 757 uuids.push_back(BluetoothUUID(kGlucoseServiceUUID)); |
758 uuids.push_back(BluetoothUUID(kTxPowerServiceUUID)); | 758 uuids.push_back(BluetoothUUID(kTxPowerServiceUUID)); |
759 | 759 |
760 return GetBaseDevice(adapter, "Glucose Device", uuids, makeMACAddress(0x2)); | 760 return GetBaseDevice(adapter, "Glucose Device", uuids, makeMACAddress(0x2)); |
761 } | 761 } |
762 | 762 |
763 // static | 763 // static |
764 std::unique_ptr<NiceMockBluetoothDevice> | 764 std::unique_ptr<NiceMockBluetoothDevice> |
765 LayoutTestBluetoothAdapterProvider::GetConnectableDevice( | 765 LayoutTestBluetoothAdapterProvider::GetConnectableDevice( |
766 device::MockBluetoothAdapter* adapter, | 766 device::MockBluetoothAdapter* adapter, |
767 const std::string& device_name, | 767 const char* device_name, |
768 BluetoothDevice::UUIDList uuids, | 768 BluetoothDevice::UUIDList uuids, |
769 const std::string& address) { | 769 const std::string& address) { |
770 std::unique_ptr<NiceMockBluetoothDevice> device( | 770 std::unique_ptr<NiceMockBluetoothDevice> device( |
771 GetBaseDevice(adapter, device_name, uuids, address)); | 771 GetBaseDevice(adapter, device_name, uuids, address)); |
772 | 772 |
773 MockBluetoothDevice* device_ptr = device.get(); | 773 MockBluetoothDevice* device_ptr = device.get(); |
774 | 774 |
775 ON_CALL(*device, CreateGattConnection(_, _)) | 775 ON_CALL(*device, CreateGattConnection(_, _)) |
776 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( | 776 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( |
777 [adapter, device_ptr]() { | 777 [adapter, device_ptr]() { |
778 return base::WrapUnique(new NiceMockBluetoothGattConnection( | 778 return base::WrapUnique(new NiceMockBluetoothGattConnection( |
779 adapter, device_ptr->GetAddress())); | 779 adapter, device_ptr->GetAddress())); |
780 })); | 780 })); |
781 | 781 |
782 ON_CALL(*device, IsGattServicesDiscoveryComplete()) | 782 ON_CALL(*device, IsGattServicesDiscoveryComplete()) |
783 .WillByDefault(Return(true)); | 783 .WillByDefault(Return(true)); |
784 | 784 |
785 return device; | 785 return device; |
786 } | 786 } |
787 | 787 |
788 // static | 788 // static |
789 std::unique_ptr<NiceMockBluetoothDevice> | 789 std::unique_ptr<NiceMockBluetoothDevice> |
790 LayoutTestBluetoothAdapterProvider::GetUnconnectableDevice( | 790 LayoutTestBluetoothAdapterProvider::GetUnconnectableDevice( |
791 MockBluetoothAdapter* adapter, | 791 MockBluetoothAdapter* adapter, |
792 BluetoothDevice::ConnectErrorCode error_code, | 792 BluetoothDevice::ConnectErrorCode error_code, |
793 const std::string& device_name) { | 793 const char* device_name) { |
794 BluetoothDevice::UUIDList uuids; | 794 BluetoothDevice::UUIDList uuids; |
795 uuids.push_back(BluetoothUUID(errorUUID(error_code))); | 795 uuids.push_back(BluetoothUUID(errorUUID(error_code))); |
796 | 796 |
797 std::unique_ptr<NiceMockBluetoothDevice> device( | 797 std::unique_ptr<NiceMockBluetoothDevice> device( |
798 GetBaseDevice(adapter, device_name, uuids, makeMACAddress(error_code))); | 798 GetBaseDevice(adapter, device_name, uuids, makeMACAddress(error_code))); |
799 | 799 |
800 ON_CALL(*device, CreateGattConnection(_, _)) | 800 ON_CALL(*device, CreateGattConnection(_, _)) |
801 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); | 801 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); |
802 | 802 |
803 return device; | 803 return device; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 return BluetoothUUID(); | 1159 return BluetoothUUID(); |
1160 } | 1160 } |
1161 | 1161 |
1162 // static | 1162 // static |
1163 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { | 1163 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { |
1164 return BluetoothDevice::CanonicalizeAddress( | 1164 return BluetoothDevice::CanonicalizeAddress( |
1165 base::StringPrintf("%012" PRIx64, addr)); | 1165 base::StringPrintf("%012" PRIx64, addr)); |
1166 } | 1166 } |
1167 | 1167 |
1168 } // namespace content | 1168 } // namespace content |
OLD | NEW |