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

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

Issue 2017393002: bluetooth: Rename device's GetName to GetNameForDisplay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 (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 std::string& 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),
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, GetDeviceName())
30 .WillByDefault(testing::Return(name_));
31 ON_CALL(*this, GetIdentifier()) 29 ON_CALL(*this, GetIdentifier())
32 .WillByDefault(testing::Return(address_ + "-Identifier")); 30 .WillByDefault(testing::Return(address_ + "-Identifier"));
33 ON_CALL(*this, GetAddress()) 31 ON_CALL(*this, GetAddress())
34 .WillByDefault(testing::Return(address_)); 32 .WillByDefault(testing::Return(address_));
35 ON_CALL(*this, GetDeviceType())
36 .WillByDefault(testing::Return(DEVICE_UNKNOWN));
37 ON_CALL(*this, GetVendorIDSource()) 33 ON_CALL(*this, GetVendorIDSource())
38 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN)); 34 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN));
39 ON_CALL(*this, GetVendorID()) 35 ON_CALL(*this, GetVendorID())
40 .WillByDefault(testing::Return(0)); 36 .WillByDefault(testing::Return(0));
41 ON_CALL(*this, GetProductID()) 37 ON_CALL(*this, GetProductID())
42 .WillByDefault(testing::Return(0)); 38 .WillByDefault(testing::Return(0));
43 ON_CALL(*this, GetDeviceID()) 39 ON_CALL(*this, GetDeviceID())
44 .WillByDefault(testing::Return(0)); 40 .WillByDefault(testing::Return(0));
41 ON_CALL(*this, GetNameForDisplay())
42 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_)));
43 ON_CALL(*this, GetDeviceType())
44 .WillByDefault(testing::Return(DEVICE_UNKNOWN));
45 ON_CALL(*this, IsPaired()) 45 ON_CALL(*this, IsPaired())
46 .WillByDefault(testing::Return(paired)); 46 .WillByDefault(testing::Return(paired));
47 ON_CALL(*this, IsConnected()) 47 ON_CALL(*this, IsConnected())
48 .WillByDefault(testing::ReturnPointee(&connected_)); 48 .WillByDefault(testing::ReturnPointee(&connected_));
49 ON_CALL(*this, IsConnectable()) 49 ON_CALL(*this, IsConnectable())
50 .WillByDefault(testing::Return(false)); 50 .WillByDefault(testing::Return(false));
51 ON_CALL(*this, IsConnecting()) 51 ON_CALL(*this, IsConnecting())
52 .WillByDefault(testing::Return(false)); 52 .WillByDefault(testing::Return(false));
53 ON_CALL(*this, GetName()) 53 ON_CALL(*this, GetUUIDs()).WillByDefault(testing::Return(uuids_));
54 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_)));
55 ON_CALL(*this, ExpectingPinCode()) 54 ON_CALL(*this, ExpectingPinCode())
56 .WillByDefault(testing::Return(false)); 55 .WillByDefault(testing::Return(false));
57 ON_CALL(*this, ExpectingPasskey()) 56 ON_CALL(*this, ExpectingPasskey())
58 .WillByDefault(testing::Return(false)); 57 .WillByDefault(testing::Return(false));
59 ON_CALL(*this, ExpectingConfirmation()) 58 ON_CALL(*this, ExpectingConfirmation())
60 .WillByDefault(testing::Return(false)); 59 .WillByDefault(testing::Return(false));
61 ON_CALL(*this, GetUUIDs()) 60 ON_CALL(*this, GetDeviceName()).WillByDefault(testing::Return(name_));
62 .WillByDefault(testing::Return(uuids_));
63 } 61 }
64 62
65 MockBluetoothDevice::~MockBluetoothDevice() {} 63 MockBluetoothDevice::~MockBluetoothDevice() {}
66 64
67 void MockBluetoothDevice::AddMockService( 65 void MockBluetoothDevice::AddMockService(
68 std::unique_ptr<MockBluetoothGattService> mock_service) { 66 std::unique_ptr<MockBluetoothGattService> mock_service) {
69 mock_services_.push_back(std::move(mock_service)); 67 mock_services_.push_back(std::move(mock_service));
70 } 68 }
71 69
72 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() 70 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices()
73 const { 71 const {
74 std::vector<BluetoothRemoteGattService*> services; 72 std::vector<BluetoothRemoteGattService*> services;
75 for (BluetoothRemoteGattService* service : mock_services_) { 73 for (BluetoothRemoteGattService* service : mock_services_) {
76 services.push_back(service); 74 services.push_back(service);
77 } 75 }
78 return services; 76 return services;
79 } 77 }
80 78
81 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( 79 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService(
82 const std::string& identifier) const { 80 const std::string& identifier) const {
83 for (BluetoothRemoteGattService* service : mock_services_) { 81 for (BluetoothRemoteGattService* service : mock_services_) {
84 if (service->GetIdentifier() == identifier) 82 if (service->GetIdentifier() == identifier)
85 return service; 83 return service;
86 } 84 }
87 return nullptr; 85 return nullptr;
88 } 86 }
89 87
90 } // namespace device 88 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.h ('k') | extensions/browser/api/bluetooth/bluetooth_api_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698