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

Side by Side Diff: device/bluetooth/bluetooth_low_energy_win_fake.h

Issue 1690133002: Implement BluetoothRemoteGattServiceWin and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 10 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 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_
7 7
8 #include "device/bluetooth/bluetooth_low_energy_win.h" 8 #include "device/bluetooth/bluetooth_low_energy_win.h"
9 9
10 #include <set> 10 #include <set>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info; 61 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info;
62 scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value; 62 scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value;
63 }; 63 };
64 64
65 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin. 65 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin.
66 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper { 66 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
67 public: 67 public:
68 BluetoothLowEnergyWrapperFake(); 68 BluetoothLowEnergyWrapperFake();
69 ~BluetoothLowEnergyWrapperFake() override; 69 ~BluetoothLowEnergyWrapperFake() override;
70 70
71 bool IsBluetoothLowEnergySupported() override;
71 bool EnumerateKnownBluetoothLowEnergyDevices( 72 bool EnumerateKnownBluetoothLowEnergyDevices(
72 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 73 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
73 std::string* error) override; 74 std::string* error) override;
74 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( 75 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
75 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 76 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
76 std::string* error) override; 77 std::string* error) override;
77 bool EnumerateKnownBluetoothLowEnergyServices( 78 bool EnumerateKnownBluetoothLowEnergyServices(
78 const base::FilePath& device_path, 79 const base::FilePath& device_path,
79 ScopedVector<BluetoothLowEnergyServiceInfo>* services, 80 ScopedVector<BluetoothLowEnergyServiceInfo>* services,
80 std::string* error) override; 81 std::string* error) override;
82 HRESULT ReadIncludedServicesOfAService(
83 base::FilePath& service_path,
84 const PBTH_LE_GATT_SERVICE service,
85 scoped_ptr<BTH_LE_GATT_SERVICE>* out_included_services,
86 USHORT* out_counts) override;
87 HRESULT ReadCharacteristicsOfAService(
88 base::FilePath& service_path,
89 const PBTH_LE_GATT_SERVICE service,
90 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>* out_included_characteristics,
91 USHORT* out_counts) override;
81 92
82 BLEDevice* SimulateBLEDevice(std::string device_name, 93 BLEDevice* SimulateBLEDevice(std::string device_name,
83 BLUETOOTH_ADDRESS device_address); 94 BLUETOOTH_ADDRESS device_address);
84 BLEDevice* GetSimulatedBLEDevice(std::string device_address); 95 BLEDevice* GetSimulatedBLEDevice(std::string device_address);
85 BLEGattService* SimulateBLEGattService(BLEDevice* device, std::string uuid); 96
97 // Note: |parent_service| == nullptr if simulated service is a primary
scheib 2016/02/24 01:39:10 |parent_service| may be nullptr to indicate a prim
gogerald1 2016/02/24 16:09:06 Done.
98 // service.
99 BLEGattService* SimulateBLEGattService(BLEDevice* device,
100 BLEGattService* parent_service,
101 const BTH_LE_UUID& uuid);
102
103 // Note: |parent_service| == nullptr if removed service is a primary
scheib 2016/02/24 01:39:10 ditto
gogerald1 2016/02/24 16:09:06 Done.
104 // service.
105 void SimulateBLEGattServiceRemove(BLEDevice* device,
scheib 2016/02/24 01:39:10 SimulateBLEGattServiceRemoved
gogerald1 2016/02/24 16:09:06 Done.
106 BLEGattService* parent_service,
107 std::string attribute_handle);
108
109 // Note: |chain_of_att_handle| contains the attribute handles of the services
110 // in order from primary service to target service. The last item in
111 // |chain_of_att_handle| is the target service's attribute handle.
112 BLEGattService* GetSimulatedGattService(
113 BLEDevice* device,
114 const std::vector<std::string>& chain_of_att_handle);
115 BLEGattCharacteristic* SimulateCharacterisc(
scheib 2016/02/24 01:39:10 SimulateCharacteristic. Note this doesn't follow t
gogerald1 2016/02/24 16:09:06 Follow above names "BLEGatt" for now since all the
116 std::string device_address,
117 BLEGattService* parent_service,
118 const BTH_LE_GATT_CHARACTERISTIC& characteristic);
119 void SimulateCharacteriscRemove(BLEGattService* parent_service,
120 std::string attribute_handle);
86 121
87 private: 122 private:
88 // Generate an unique attribute handle on |device_address|. 123 // Generate an unique attribute handle on |device_address|.
89 USHORT GenerateAUniqueAttributeHandle(std::string device_address); 124 USHORT GenerateAUniqueAttributeHandle(std::string device_address);
90 125
91 // Generate device path for the BLE device with |device_address|. 126 // Generate device path for the BLE device with |device_address|.
92 base::string16 GenerateBLEDevicePath(std::string device_address); 127 base::string16 GenerateBLEDevicePath(std::string device_address);
93 128
94 // Generate GATT service device path of the service with 129 // Generate GATT service device path of the service with
95 // |service_attribute_handle|. |resident_device_path| is the BLE device this 130 // |service_attribute_handle|. |resident_device_path| is the BLE device this
96 // GATT service belongs to. 131 // GATT service belongs to.
97 base::string16 GenerateBLEGattServiceDevicePath( 132 base::string16 GenerateBLEGattServiceDevicePath(
98 base::string16 resident_device_path, 133 base::string16 resident_device_path,
99 USHORT service_attribute_handle); 134 USHORT service_attribute_handle);
100 135
101 // Extract device address from the device |path| generated by 136 // Extract device address from the device |path| generated by
102 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath. 137 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath.
103 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path); 138 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path);
104 139
105 // Extract service attribute handle from the |path| generated by 140 // Extract service attribute handles from the |path| generated by
106 // GenerateBLEGattServiceDevicePath. 141 // GenerateBLEGattServiceDevicePath.
107 base::string16 ExtractServiceAttributeHandleFromDevicePath( 142 std::vector<std::string> ExtractServiceAttributeHandlesFromDevicePath(
108 base::string16 path); 143 base::string16 path);
109 144
110 // The canonical BLE device address string format is the 145 // The canonical BLE device address string format is the
111 // BluetoothDevice::CanonicalizeAddress. 146 // BluetoothDevice::CanonicalizeAddress.
112 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha); 147 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha);
113 148
114 // The canonical UUID string format is device::BluetoothUUID.value().
115 BTH_LE_UUID CanonicalStringToBTH_LE_UUID(std::string uuid);
116
117 // Table to store allocated attribute handle for a device. 149 // Table to store allocated attribute handle for a device.
118 BLEAttributeHandleTable attribute_handle_table_; 150 BLEAttributeHandleTable attribute_handle_table_;
119 BLEDevicesMap simulated_devices_; 151 BLEDevicesMap simulated_devices_;
120 }; 152 };
121 153
122 } // namespace win 154 } // namespace win
123 } // namespace device 155 } // namespace device
124 156
125 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ 157 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698