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

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

Issue 1991063002: Implement the gattserverdisconnected event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename-web-bluetooth-device
Patch Set: Created 4 years, 7 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 ON_CALL(*this, GetBluetoothClass()) 27 ON_CALL(*this, GetBluetoothClass())
27 .WillByDefault(testing::Return(bluetooth_class_)); 28 .WillByDefault(testing::Return(bluetooth_class_));
28 ON_CALL(*this, GetDeviceName()) 29 ON_CALL(*this, GetDeviceName())
29 .WillByDefault(testing::Return(name_)); 30 .WillByDefault(testing::Return(name_));
30 ON_CALL(*this, GetIdentifier()) 31 ON_CALL(*this, GetIdentifier())
31 .WillByDefault(testing::Return(address_ + "-Identifier")); 32 .WillByDefault(testing::Return(address_ + "-Identifier"));
32 ON_CALL(*this, GetAddress()) 33 ON_CALL(*this, GetAddress())
33 .WillByDefault(testing::Return(address_)); 34 .WillByDefault(testing::Return(address_));
34 ON_CALL(*this, GetDeviceType()) 35 ON_CALL(*this, GetDeviceType())
35 .WillByDefault(testing::Return(DEVICE_UNKNOWN)); 36 .WillByDefault(testing::Return(DEVICE_UNKNOWN));
36 ON_CALL(*this, GetVendorIDSource()) 37 ON_CALL(*this, GetVendorIDSource())
37 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN)); 38 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN));
38 ON_CALL(*this, GetVendorID()) 39 ON_CALL(*this, GetVendorID())
39 .WillByDefault(testing::Return(0)); 40 .WillByDefault(testing::Return(0));
40 ON_CALL(*this, GetProductID()) 41 ON_CALL(*this, GetProductID())
41 .WillByDefault(testing::Return(0)); 42 .WillByDefault(testing::Return(0));
42 ON_CALL(*this, GetDeviceID()) 43 ON_CALL(*this, GetDeviceID())
43 .WillByDefault(testing::Return(0)); 44 .WillByDefault(testing::Return(0));
44 ON_CALL(*this, IsPaired()) 45 ON_CALL(*this, IsPaired())
45 .WillByDefault(testing::Return(paired)); 46 .WillByDefault(testing::Return(paired));
46 ON_CALL(*this, IsConnected()) 47 ON_CALL(*this, IsConnected())
47 .WillByDefault(testing::Return(connected)); 48 .WillByDefault(testing::ReturnPointee(&connected_));
48 ON_CALL(*this, IsConnectable()) 49 ON_CALL(*this, IsConnectable())
49 .WillByDefault(testing::Return(false)); 50 .WillByDefault(testing::Return(false));
50 ON_CALL(*this, IsConnecting()) 51 ON_CALL(*this, IsConnecting())
51 .WillByDefault(testing::Return(false)); 52 .WillByDefault(testing::Return(false));
52 ON_CALL(*this, GetName()) 53 ON_CALL(*this, GetName())
53 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_))); 54 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_)));
54 ON_CALL(*this, ExpectingPinCode()) 55 ON_CALL(*this, ExpectingPinCode())
55 .WillByDefault(testing::Return(false)); 56 .WillByDefault(testing::Return(false));
56 ON_CALL(*this, ExpectingPasskey()) 57 ON_CALL(*this, ExpectingPasskey())
57 .WillByDefault(testing::Return(false)); 58 .WillByDefault(testing::Return(false));
(...skipping 22 matching lines...) Expand all
80 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( 81 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService(
81 const std::string& identifier) const { 82 const std::string& identifier) const {
82 for (BluetoothRemoteGattService* service : mock_services_) { 83 for (BluetoothRemoteGattService* service : mock_services_) {
83 if (service->GetIdentifier() == identifier) 84 if (service->GetIdentifier() == identifier)
84 return service; 85 return service;
85 } 86 }
86 return nullptr; 87 return nullptr;
87 } 88 }
88 89
89 } // namespace device 90 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698