diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-03 02:25:23 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-03 02:25:23 +0000 |
commit | ce8c2a80fddc4866d88dfba43b8d4c39ba1b0063 (patch) | |
tree | b94dd6b80502cdfa77f39545bfb74f627997f03b /device | |
parent | f1a571eb319c7390f4ab6d2dfdb804fd142236c4 (diff) | |
download | chromium_src-ce8c2a80fddc4866d88dfba43b8d4c39ba1b0063.zip chromium_src-ce8c2a80fddc4866d88dfba43b8d4c39ba1b0063.tar.gz chromium_src-ce8c2a80fddc4866d88dfba43b8d4c39ba1b0063.tar.bz2 |
chrome.bluetoothLowEnergy: Implement getCharacteristics.
This CL implements the getCharacteristics method of the bluetoothLowEnergy API
and adds a mapping for Characteristic instance IDs to
BluetoothLowEnergyEventRouter.
BUG=265663
TEST=browser_tests --gtest_filter=BluetoothLowEnergyApiTest.*
Review URL: https://codereview.chromium.org/255053002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r-- | device/bluetooth/bluetooth.gyp | 2 | ||||
-rw-r--r-- | device/bluetooth/test/mock_bluetooth_gatt_characteristic.cc | 37 | ||||
-rw-r--r-- | device/bluetooth/test/mock_bluetooth_gatt_characteristic.h | 55 |
3 files changed, 94 insertions, 0 deletions
diff --git a/device/bluetooth/bluetooth.gyp b/device/bluetooth/bluetooth.gyp index deb7d26a..ec06dec 100644 --- a/device/bluetooth/bluetooth.gyp +++ b/device/bluetooth/bluetooth.gyp @@ -136,6 +136,8 @@ 'test/mock_bluetooth_device.h', 'test/mock_bluetooth_discovery_session.cc', 'test/mock_bluetooth_discovery_session.h', + 'test/mock_bluetooth_gatt_characteristic.cc', + 'test/mock_bluetooth_gatt_characteristic.h', 'test/mock_bluetooth_gatt_service.cc', 'test/mock_bluetooth_gatt_service.h', 'test/mock_bluetooth_profile.cc', diff --git a/device/bluetooth/test/mock_bluetooth_gatt_characteristic.cc b/device/bluetooth/test/mock_bluetooth_gatt_characteristic.cc new file mode 100644 index 0000000..5cc4da3 --- /dev/null +++ b/device/bluetooth/test/mock_bluetooth_gatt_characteristic.cc @@ -0,0 +1,37 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" + +#include "device/bluetooth/test/mock_bluetooth_gatt_service.h" + +using testing::Return; +using testing::ReturnRefOfCopy; +using testing::_; + +namespace device { + +MockBluetoothGattCharacteristic::MockBluetoothGattCharacteristic( + MockBluetoothGattService* service, + const std::string& identifier, + const BluetoothUUID& uuid, + bool is_local, + Properties properties, + Permissions permissions) { + ON_CALL(*this, GetIdentifier()).WillByDefault(Return(identifier)); + ON_CALL(*this, GetUUID()).WillByDefault(Return(uuid)); + ON_CALL(*this, IsLocal()).WillByDefault(Return(is_local)); + ON_CALL(*this, GetValue()) + .WillByDefault(ReturnRefOfCopy(std::vector<uint8>())); + ON_CALL(*this, GetService()).WillByDefault(Return(service)); + ON_CALL(*this, GetProperties()).WillByDefault(Return(properties)); + ON_CALL(*this, GetPermissions()).WillByDefault(Return(permissions)); + ON_CALL(*this, GetDescriptors()) + .WillByDefault(Return(std::vector<BluetoothGattDescriptor*>())); +} + +MockBluetoothGattCharacteristic::~MockBluetoothGattCharacteristic() { +} + +} // namespace device diff --git a/device/bluetooth/test/mock_bluetooth_gatt_characteristic.h b/device/bluetooth/test/mock_bluetooth_gatt_characteristic.h new file mode 100644 index 0000000..6619543 --- /dev/null +++ b/device/bluetooth/test/mock_bluetooth_gatt_characteristic.h @@ -0,0 +1,55 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_CHARACTERISTIC_H_ +#define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_CHARACTERISTIC_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/callback.h" +#include "device/bluetooth/bluetooth_gatt_characteristic.h" +#include "device/bluetooth/bluetooth_uuid.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace device { + +class BluetoothGattDescriptor; +class BluetoothGattService; +class MockBluetoothGattService; + +class MockBluetoothGattCharacteristic : public BluetoothGattCharacteristic { + public: + MockBluetoothGattCharacteristic(MockBluetoothGattService* service, + const std::string& identifier, + const BluetoothUUID& uuid, + bool is_local, + Properties properties, + Permissions permissions); + virtual ~MockBluetoothGattCharacteristic(); + + MOCK_CONST_METHOD0(GetIdentifier, std::string()); + MOCK_CONST_METHOD0(GetUUID, BluetoothUUID()); + MOCK_CONST_METHOD0(IsLocal, bool()); + MOCK_CONST_METHOD0(GetValue, const std::vector<uint8>&()); + MOCK_CONST_METHOD0(GetService, BluetoothGattService*()); + MOCK_CONST_METHOD0(GetProperties, Properties()); + MOCK_CONST_METHOD0(GetPermissions, Permissions()); + MOCK_CONST_METHOD0(GetDescriptors, std::vector<BluetoothGattDescriptor*>()); + MOCK_METHOD1(AddDescriptor, bool(BluetoothGattDescriptor*)); + MOCK_METHOD1(UpdateValue, bool(const std::vector<uint8>&)); + MOCK_METHOD2(ReadRemoteCharacteristic, + void(const ValueCallback&, const ErrorCallback&)); + MOCK_METHOD3(WriteRemoteCharacteristic, + void(const std::vector<uint8>&, + const base::Closure&, + const ErrorCallback&)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattCharacteristic); +}; + +} // namespace device + +#endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_CHARACTERISTIC_H_ |