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"
13 MockBluetoothDevice::MockBluetoothDevice(MockBluetoothAdapter
* adapter
,
14 uint32 bluetooth_class
,
15 const std::string
& name
,
16 const std::string
& address
,
19 : BluetoothDevice(adapter
),
20 bluetooth_class_(bluetooth_class
),
23 ON_CALL(*this, GetBluetoothClass())
24 .WillByDefault(testing::Return(bluetooth_class_
));
25 ON_CALL(*this, GetDeviceName())
26 .WillByDefault(testing::Return(name_
));
27 ON_CALL(*this, GetIdentifier())
28 .WillByDefault(testing::Return(address_
+ "-Identifier"));
29 ON_CALL(*this, GetAddress())
30 .WillByDefault(testing::Return(address_
));
31 ON_CALL(*this, GetDeviceType())
32 .WillByDefault(testing::Return(DEVICE_UNKNOWN
));
33 ON_CALL(*this, GetVendorIDSource())
34 .WillByDefault(testing::Return(VENDOR_ID_UNKNOWN
));
35 ON_CALL(*this, GetVendorID())
36 .WillByDefault(testing::Return(0));
37 ON_CALL(*this, GetProductID())
38 .WillByDefault(testing::Return(0));
39 ON_CALL(*this, GetDeviceID())
40 .WillByDefault(testing::Return(0));
41 ON_CALL(*this, IsPaired())
42 .WillByDefault(testing::Return(paired
));
43 ON_CALL(*this, IsConnected())
44 .WillByDefault(testing::Return(connected
));
45 ON_CALL(*this, IsConnectable())
46 .WillByDefault(testing::Return(false));
47 ON_CALL(*this, IsConnecting())
48 .WillByDefault(testing::Return(false));
49 ON_CALL(*this, GetName())
50 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_
)));
51 ON_CALL(*this, ExpectingPinCode())
52 .WillByDefault(testing::Return(false));
53 ON_CALL(*this, ExpectingPasskey())
54 .WillByDefault(testing::Return(false));
55 ON_CALL(*this, ExpectingConfirmation())
56 .WillByDefault(testing::Return(false));
57 ON_CALL(*this, GetUUIDs())
58 .WillByDefault(testing::Return(uuids_
));
61 MockBluetoothDevice::~MockBluetoothDevice() {}
63 void MockBluetoothDevice::AddMockService(
64 scoped_ptr
<MockBluetoothGattService
> mock_service
) {
65 mock_services_
.push_back(mock_service
.Pass());
68 std::vector
<BluetoothGattService
*> MockBluetoothDevice::GetMockServices()
70 std::vector
<BluetoothGattService
*> services
;
71 for (BluetoothGattService
* service
: mock_services_
) {
72 services
.push_back(service
);
77 BluetoothGattService
* MockBluetoothDevice::GetMockService(
78 const std::string
& identifier
) const {
79 for (BluetoothGattService
* service
: mock_services_
) {
80 if (service
->GetIdentifier() == identifier
)