QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / device / bluetooth / test / mock_bluetooth_device.cc
blob19b67a31416dd78bbba630f91f08d3a2550d90d8
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
3 // found in the LICENSE file.
5 #include "device/bluetooth/test/mock_bluetooth_device.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "device/bluetooth/bluetooth_gatt_service.h"
9 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
11 namespace device {
13 MockBluetoothDevice::MockBluetoothDevice(MockBluetoothAdapter* adapter,
14 uint32 bluetooth_class,
15 const std::string& name,
16 const std::string& address,
17 bool paired,
18 bool connected)
19 : bluetooth_class_(bluetooth_class),
20 name_(name),
21 address_(address) {
22 ON_CALL(*this, GetBluetoothClass())
23 .WillByDefault(testing::Return(bluetooth_class_));
24 ON_CALL(*this, GetDeviceName())
25 .WillByDefault(testing::Return(name_));
26 ON_CALL(*this, GetAddress())
27 .WillByDefault(testing::Return(address_));
28 ON_CALL(*this, GetDeviceType())
29 .WillByDefault(testing::Return(DEVICE_UNKNOWN));
30 ON_CALL(*this, GetVendorIDSource())
31 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN));
32 ON_CALL(*this, GetVendorID())
33 .WillByDefault(testing::Return(0));
34 ON_CALL(*this, GetProductID())
35 .WillByDefault(testing::Return(0));
36 ON_CALL(*this, GetDeviceID())
37 .WillByDefault(testing::Return(0));
38 ON_CALL(*this, IsPaired())
39 .WillByDefault(testing::Return(paired));
40 ON_CALL(*this, IsConnected())
41 .WillByDefault(testing::Return(connected));
42 ON_CALL(*this, IsConnectable())
43 .WillByDefault(testing::Return(false));
44 ON_CALL(*this, IsConnecting())
45 .WillByDefault(testing::Return(false));
46 ON_CALL(*this, GetName())
47 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_)));
48 ON_CALL(*this, ExpectingPinCode())
49 .WillByDefault(testing::Return(false));
50 ON_CALL(*this, ExpectingPasskey())
51 .WillByDefault(testing::Return(false));
52 ON_CALL(*this, ExpectingConfirmation())
53 .WillByDefault(testing::Return(false));
54 ON_CALL(*this, GetUUIDs())
55 .WillByDefault(testing::Return(uuids_));
58 MockBluetoothDevice::~MockBluetoothDevice() {}
60 void MockBluetoothDevice::AddMockService(
61 scoped_ptr<MockBluetoothGattService> mock_service) {
62 mock_services_.push_back(mock_service.Pass());
65 std::vector<BluetoothGattService*> MockBluetoothDevice::GetMockServices()
66 const {
67 std::vector<BluetoothGattService*> services;
68 for (BluetoothGattService* service : mock_services_) {
69 services.push_back(service);
71 return services;
74 BluetoothGattService* MockBluetoothDevice::GetMockService(
75 const std::string& identifier) const {
76 for (BluetoothGattService* service : mock_services_) {
77 if (service->GetIdentifier() == identifier)
78 return service;
80 return nullptr;
83 } // namespace device