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

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

Issue 1676073002: Implement BluetoothLowEnergyWrapperFake for Bluetooth test fixture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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>
11
12 #include "base/containers/scoped_ptr_hash_map.h"
13
10 namespace device { 14 namespace device {
11 namespace win { 15 namespace win {
12 16
17 struct BLEDevice;
18 struct BLEGattService;
19 struct BLEGattCharacteristic;
20 struct BLEGattDescriptor;
21
22 // The key of BLEDevicesMap is the string of BLE device address.
scheib 2016/02/07 02:24:08 "of the BLE" ^^^^
gogerald1 2016/02/08 19:23:51 Done.
23 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BLEDevice>>
24 BLEDevicesMap;
25 // The key of BLEGattServicesMap, BLEGattCharacteristicsMap and
26 // BLEGattDescriptorsMap is the string of attribute handle.
scheib 2016/02/07 02:24:08 "string of the attribute" ^^^^
gogerald1 2016/02/08 19:23:51 Done.
27 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BLEGattService>>
28 BLEGattServicesMap;
29 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BLEGattCharacteristic>>
30 BLEGattCharacteristicsMap;
31 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BLEGattDescriptor>>
32 BLEGattDescriptorsMap;
33 // The key of BLEAttributeHandleTable is the string of BLE device address.
scheib 2016/02/07 02:24:08 "of the BLE" ^^^^
gogerald1 2016/02/08 19:23:51 Done.
34 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<std::set<USHORT>>>
35 BLEAttributeHandleTable;
36
37 struct BLEDevice {
38 scoped_ptr<BluetoothLowEnergyDeviceInfo> device_info;
39 BLEGattServicesMap primary_services;
40 };
41
42 struct BLEGattService {
43 scoped_ptr<BTH_LE_GATT_SERVICE> service_info;
44 BLEGattServicesMap included_services;
45 BLEGattCharacteristicsMap included_characteristics;
46 };
47
48 struct BLEGattCharacteristic {
49 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info;
50 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value;
51 BLEGattDescriptorsMap included_descriptors;
52 };
53
54 struct BLEGattDescriptor {
55 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info;
56 scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value;
57 };
58
13 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin. 59 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin.
14 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper { 60 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
15 public: 61 public:
16 BluetoothLowEnergyWrapperFake(); 62 BluetoothLowEnergyWrapperFake();
17 ~BluetoothLowEnergyWrapperFake() override; 63 ~BluetoothLowEnergyWrapperFake() override;
18 64
19 bool EnumerateKnownBluetoothLowEnergyDevices( 65 bool EnumerateKnownBluetoothLowEnergyDevices(
20 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 66 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
21 std::string* error) override; 67 std::string* error) override;
22 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( 68 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
23 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 69 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
24 std::string* error) override; 70 std::string* error) override;
25 bool EnumerateKnownBluetoothLowEnergyServices( 71 bool EnumerateKnownBluetoothLowEnergyServices(
26 const base::FilePath& device_path, 72 const base::FilePath& device_path,
27 ScopedVector<BluetoothLowEnergyServiceInfo>* services, 73 ScopedVector<BluetoothLowEnergyServiceInfo>* services,
28 std::string* error) override; 74 std::string* error) override;
75
76 BLEDevice* SimulateBLEDevice(std::string device_name,
77 BLUETOOTH_ADDRESS device_address);
78 BLEGattService* SimulateBLEGattService(BLEDevice* device, std::string uuid);
79
80 private:
81 // Generate an unique attribute handle on |device_address|.
82 USHORT GenerateAnUniqueAttributeHandle(std::string device_address);
scheib 2016/02/07 02:24:08 GenerateAUniqueAttributeHandle or GenerateUniqueA
gogerald1 2016/02/08 19:23:51 Done.
83
84 // The canonical BLE device address string format is the
85 // BluetoothDevice::CanonicalizeAddress.
86 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha);
87
88 // The canonical uuid string format is device::BluetoothUUID.value().
scheib 2016/02/07 02:24:08 Capital UUID.
gogerald1 2016/02/08 19:23:51 Done.
89 BTH_LE_UUID CanonicalStringToBTH_LE_UUID(std::string uuid);
90
91 // Table to store allocated attribute handle for a device.
92 BLEAttributeHandleTable attribute_handle_table_;
93 BLEDevicesMap simulated_devices_;
29 }; 94 };
30 95
31 } // namespace win 96 } // namespace win
32 } // namespace device 97 } // namespace device
33 98
34 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ 99 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698