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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_gatt_service.cc

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/bluetooth/test/mock_bluetooth_gatt_service.h" 5 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "device/bluetooth/test/mock_bluetooth_device.h" 10 #include "device/bluetooth/test/mock_bluetooth_device.h"
11 11
12 using testing::Return; 12 using testing::Return;
13 using testing::_; 13 using testing::_;
14 14
15 namespace device { 15 namespace device {
16 16
17 MockBluetoothGattService::MockBluetoothGattService( 17 MockBluetoothGattService::MockBluetoothGattService(
18 MockBluetoothDevice* device, 18 MockBluetoothDevice* device,
19 const std::string& identifier, 19 const std::string& identifier,
20 const BluetoothUUID& uuid, 20 const BluetoothUUID& uuid,
21 bool is_primary, 21 bool is_primary,
22 bool is_local) { 22 bool is_local) {
23 ON_CALL(*this, GetIdentifier()).WillByDefault(Return(identifier)); 23 ON_CALL(*this, GetIdentifier()).WillByDefault(Return(identifier));
24 ON_CALL(*this, GetUUID()).WillByDefault(Return(uuid)); 24 ON_CALL(*this, GetUUID()).WillByDefault(Return(uuid));
25 ON_CALL(*this, IsLocal()).WillByDefault(Return(is_local)); 25 ON_CALL(*this, IsLocal()).WillByDefault(Return(is_local));
26 ON_CALL(*this, IsPrimary()).WillByDefault(Return(is_primary)); 26 ON_CALL(*this, IsPrimary()).WillByDefault(Return(is_primary));
27 ON_CALL(*this, GetDevice()).WillByDefault(Return(device)); 27 ON_CALL(*this, GetDevice()).WillByDefault(Return(device));
28 ON_CALL(*this, GetCharacteristics()) 28 ON_CALL(*this, GetCharacteristics())
29 .WillByDefault(Return(std::vector<BluetoothGattCharacteristic*>())); 29 .WillByDefault(Return(std::vector<BluetoothRemoteGattCharacteristic*>()));
30 ON_CALL(*this, GetIncludedServices()) 30 ON_CALL(*this, GetIncludedServices())
31 .WillByDefault(Return(std::vector<BluetoothGattService*>())); 31 .WillByDefault(Return(std::vector<BluetoothRemoteGattService*>()));
32 ON_CALL(*this, GetCharacteristic(_)) 32 ON_CALL(*this, GetCharacteristic(_))
33 .WillByDefault(Return(static_cast<BluetoothGattCharacteristic*>(NULL))); 33 .WillByDefault(
34 Return(static_cast<BluetoothRemoteGattCharacteristic*>(NULL)));
34 } 35 }
35 36
36 MockBluetoothGattService::~MockBluetoothGattService() { 37 MockBluetoothGattService::~MockBluetoothGattService() {
37 } 38 }
38 39
39 void MockBluetoothGattService::AddMockCharacteristic( 40 void MockBluetoothGattService::AddMockCharacteristic(
40 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic) { 41 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic) {
41 mock_characteristics_.push_back(std::move(mock_characteristic)); 42 mock_characteristics_.push_back(std::move(mock_characteristic));
42 } 43 }
43 44
44 std::vector<BluetoothGattCharacteristic*> 45 std::vector<BluetoothRemoteGattCharacteristic*>
45 MockBluetoothGattService::GetMockCharacteristics() const { 46 MockBluetoothGattService::GetMockCharacteristics() const {
46 std::vector<BluetoothGattCharacteristic*> characteristics; 47 std::vector<BluetoothRemoteGattCharacteristic*> characteristics;
47 for (BluetoothGattCharacteristic* characteristic : mock_characteristics_) { 48 for (BluetoothRemoteGattCharacteristic* characteristic :
49 mock_characteristics_) {
48 characteristics.push_back(characteristic); 50 characteristics.push_back(characteristic);
49 } 51 }
50 return characteristics; 52 return characteristics;
51 } 53 }
52 54
53 BluetoothGattCharacteristic* MockBluetoothGattService::GetMockCharacteristic( 55 BluetoothRemoteGattCharacteristic*
56 MockBluetoothGattService::GetMockCharacteristic(
54 const std::string& identifier) const { 57 const std::string& identifier) const {
55 for (BluetoothGattCharacteristic* characteristic : mock_characteristics_) { 58 for (BluetoothRemoteGattCharacteristic* characteristic :
59 mock_characteristics_) {
56 if (characteristic->GetIdentifier() == identifier) { 60 if (characteristic->GetIdentifier() == identifier) {
57 return characteristic; 61 return characteristic;
58 } 62 }
59 } 63 }
60 return nullptr; 64 return nullptr;
61 } 65 }
62 66
63 } // namespace device 67 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_gatt_service.h ('k') | device/bluetooth/test/test_bluetooth_adapter_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698