Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 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_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | 9 #include <vector> |
| 12 | 10 |
| 13 #include "base/callback.h" | |
| 14 #include "base/macros.h" | 11 #include "base/macros.h" |
| 15 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 12 #include "device/bluetooth/bluetooth_export.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 13 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 14 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h" | |
| 17 #include "device/bluetooth/bluetooth_uuid.h" | 15 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | |
| 19 | 16 |
| 20 namespace device { | 17 namespace device { |
| 21 | 18 |
| 22 class MockBluetoothGattCharacteristic; | 19 // BluetoothLocalGattDescriptor represents a local or remote GATT characteristic |
|
scheib
2016/04/20 01:23:30
local only.
rkc
2016/04/20 16:31:53
Done.
| |
| 20 // descriptor. A GATT characteristic descriptor provides further information | |
| 21 // about a characteristic's value. They can be used to describe the | |
| 22 // characteristic's features or to control certain behaviors. | |
| 23 // | |
| 24 // Note: We use virtual inheritance on the GATT descriptor since it will be | |
| 25 // inherited by platform specific versions of the GATT descriptor classes also. | |
| 26 // The platform specific remote GATT descriptor classes will inherit both this | |
| 27 // class and their GATT descriptor class, hence causing an inheritance diamond. | |
| 28 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattDescriptor | |
| 29 : public virtual BluetoothGattDescriptor { | |
| 30 public: | |
| 31 // Constructs a BluetoothLocalGattDescriptor that can be associated with a | |
| 32 // local | |
|
scheib
2016/04/20 01:23:30
wrapping
rkc
2016/04/20 16:31:53
Done.
| |
| 33 // GATT characteristic when the adapter is in the peripheral role. To | |
| 34 // associate the returned descriptor with a characteristic, provide an pointer | |
|
scheib
2016/04/20 01:23:30
a pointer
^
rkc
2016/04/20 16:31:53
Done.
| |
| 35 // to that characteristic instance to the create function. | |
| 36 // | |
| 37 // This method constructs a characteristic descriptor with UUID |uuid| and the | |
| 38 // initial cached value |value|. |value| will be cached and returned for read | |
| 39 // requests and automatically modified for write requests by default, unless | |
| 40 // an instance of BluetoothRemoteGattService::Delegate has been provided to | |
| 41 // the | |
| 42 // associated BluetoothRemoteGattService instance, in which case the delegate | |
| 43 // will | |
| 44 // handle the read and write requests. | |
| 45 // | |
| 46 // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and | |
| 47 // |kCharacteristicPresentationFormat| are supported for locally hosted | |
| 48 // descriptors. This method will return NULL if |uuid| is any one of the | |
| 49 // unsupported predefined descriptor UUIDs. | |
| 50 static BluetoothLocalGattDescriptor* Create( | |
| 51 const BluetoothUUID& uuid, | |
| 52 const std::vector<uint8_t>& value, | |
|
scheib
2016/04/20 01:23:30
Because value can be empty on reads it is valid to
rkc
2016/04/20 16:31:54
Agreed. This parameter is gone in a later patch.
| |
| 53 BluetoothGattCharacteristic::Permissions permissions, | |
| 54 BluetoothLocalGattCharacteristic* characteristic); | |
| 23 | 55 |
| 24 class MockBluetoothGattDescriptor : public BluetoothGattDescriptor { | 56 protected: |
| 25 public: | 57 BluetoothLocalGattDescriptor(); |
| 26 MockBluetoothGattDescriptor( | 58 ~BluetoothLocalGattDescriptor() override; |
| 27 MockBluetoothGattCharacteristic* characteristic, | |
| 28 const std::string& identifier, | |
| 29 const BluetoothUUID& uuid, | |
| 30 bool is_local, | |
| 31 BluetoothGattCharacteristic::Permissions permissions); | |
| 32 virtual ~MockBluetoothGattDescriptor(); | |
| 33 | |
| 34 MOCK_CONST_METHOD0(GetIdentifier, std::string()); | |
| 35 MOCK_CONST_METHOD0(GetUUID, BluetoothUUID()); | |
| 36 MOCK_CONST_METHOD0(IsLocal, bool()); | |
| 37 MOCK_CONST_METHOD0(GetValue, const std::vector<uint8_t>&()); | |
| 38 MOCK_CONST_METHOD0(GetCharacteristic, BluetoothGattCharacteristic*()); | |
| 39 MOCK_CONST_METHOD0(GetPermissions, | |
| 40 BluetoothGattCharacteristic::Permissions()); | |
| 41 MOCK_METHOD2(ReadRemoteDescriptor, | |
| 42 void(const ValueCallback&, const ErrorCallback&)); | |
| 43 MOCK_METHOD3(WriteRemoteDescriptor, | |
| 44 void(const std::vector<uint8_t>&, | |
| 45 const base::Closure&, | |
| 46 const ErrorCallback&)); | |
| 47 | 59 |
| 48 private: | 60 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattDescriptor); | 61 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattDescriptor); |
| 50 }; | 62 }; |
| 51 | 63 |
| 52 } // namespace device | 64 } // namespace device |
| 53 | 65 |
| 54 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_DESCRIPTOR_H_ | 66 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_ |
| OLD | NEW |