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

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

Issue 2196883002: bluetooth: Add optional 'name' support to MockBluetoothDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_device.h" 5 #include "device/bluetooth/test/mock_bluetooth_device.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 11 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
12 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 12 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
13 13
14 namespace device { 14 namespace device {
15 15
16 MockBluetoothDevice::MockBluetoothDevice(MockBluetoothAdapter* adapter, 16 MockBluetoothDevice::MockBluetoothDevice(MockBluetoothAdapter* adapter,
17 uint32_t bluetooth_class, 17 uint32_t bluetooth_class,
18 const std::string& name, 18 const char* name,
19 const std::string& address, 19 const std::string& address,
20 bool paired, 20 bool paired,
21 bool connected) 21 bool connected)
22 : BluetoothDevice(adapter), 22 : BluetoothDevice(adapter),
23 bluetooth_class_(bluetooth_class), 23 bluetooth_class_(bluetooth_class),
24 name_(name), 24 name_(name ? base::Optional<std::string>(name) : base::nullopt),
25 address_(address), 25 address_(address),
26 connected_(connected) { 26 connected_(connected) {
27 ON_CALL(*this, GetBluetoothClass()) 27 ON_CALL(*this, GetBluetoothClass())
28 .WillByDefault(testing::Return(bluetooth_class_)); 28 .WillByDefault(testing::Return(bluetooth_class_));
29 ON_CALL(*this, GetIdentifier()) 29 ON_CALL(*this, GetIdentifier())
30 .WillByDefault(testing::Return(address_ + "-Identifier")); 30 .WillByDefault(testing::Return(address_ + "-Identifier"));
31 ON_CALL(*this, GetAddress()) 31 ON_CALL(*this, GetAddress())
32 .WillByDefault(testing::Return(address_)); 32 .WillByDefault(testing::Return(address_));
33 ON_CALL(*this, GetVendorIDSource()) 33 ON_CALL(*this, GetVendorIDSource())
34 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN)); 34 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN));
35 ON_CALL(*this, GetVendorID()) 35 ON_CALL(*this, GetVendorID())
36 .WillByDefault(testing::Return(0)); 36 .WillByDefault(testing::Return(0));
37 ON_CALL(*this, GetProductID()) 37 ON_CALL(*this, GetProductID())
38 .WillByDefault(testing::Return(0)); 38 .WillByDefault(testing::Return(0));
39 ON_CALL(*this, GetDeviceID()) 39 ON_CALL(*this, GetDeviceID())
40 .WillByDefault(testing::Return(0)); 40 .WillByDefault(testing::Return(0));
41 ON_CALL(*this, GetName()) 41 ON_CALL(*this, GetName()).WillByDefault(testing::Return(name_));
42 .WillByDefault(testing::Return(base::make_optional(name_)));
43 ON_CALL(*this, GetNameForDisplay()) 42 ON_CALL(*this, GetNameForDisplay())
44 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_))); 43 .WillByDefault(testing::Return(
44 base::UTF8ToUTF16(name_ ? name_.value() : "Unnamed Device")));
45 ON_CALL(*this, GetDeviceType()) 45 ON_CALL(*this, GetDeviceType())
46 .WillByDefault(testing::Return(DEVICE_UNKNOWN)); 46 .WillByDefault(testing::Return(DEVICE_UNKNOWN));
47 ON_CALL(*this, IsPaired()) 47 ON_CALL(*this, IsPaired())
48 .WillByDefault(testing::Return(paired)); 48 .WillByDefault(testing::Return(paired));
49 ON_CALL(*this, IsConnected()) 49 ON_CALL(*this, IsConnected())
50 .WillByDefault(testing::ReturnPointee(&connected_)); 50 .WillByDefault(testing::ReturnPointee(&connected_));
51 ON_CALL(*this, IsConnectable()) 51 ON_CALL(*this, IsConnectable())
52 .WillByDefault(testing::Return(false)); 52 .WillByDefault(testing::Return(false));
53 ON_CALL(*this, IsConnecting()) 53 ON_CALL(*this, IsConnecting())
54 .WillByDefault(testing::Return(false)); 54 .WillByDefault(testing::Return(false));
(...skipping 25 matching lines...) Expand all
80 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( 80 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService(
81 const std::string& identifier) const { 81 const std::string& identifier) const {
82 for (BluetoothRemoteGattService* service : mock_services_) { 82 for (BluetoothRemoteGattService* service : mock_services_) {
83 if (service->GetIdentifier() == identifier) 83 if (service->GetIdentifier() == identifier)
84 return service; 84 return service;
85 } 85 }
86 return nullptr; 86 return nullptr;
87 } 87 }
88 88
89 } // namespace device 89 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698