| OLD | NEW |
| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 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()) |
| 42 .WillByDefault(testing::Return(base::make_optional(name_))); |
| 41 ON_CALL(*this, GetNameForDisplay()) | 43 ON_CALL(*this, GetNameForDisplay()) |
| 42 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_))); | 44 .WillByDefault(testing::Return(base::UTF8ToUTF16(name_))); |
| 43 ON_CALL(*this, GetDeviceType()) | 45 ON_CALL(*this, GetDeviceType()) |
| 44 .WillByDefault(testing::Return(DEVICE_UNKNOWN)); | 46 .WillByDefault(testing::Return(DEVICE_UNKNOWN)); |
| 45 ON_CALL(*this, IsPaired()) | 47 ON_CALL(*this, IsPaired()) |
| 46 .WillByDefault(testing::Return(paired)); | 48 .WillByDefault(testing::Return(paired)); |
| 47 ON_CALL(*this, IsConnected()) | 49 ON_CALL(*this, IsConnected()) |
| 48 .WillByDefault(testing::ReturnPointee(&connected_)); | 50 .WillByDefault(testing::ReturnPointee(&connected_)); |
| 49 ON_CALL(*this, IsConnectable()) | 51 ON_CALL(*this, IsConnectable()) |
| 50 .WillByDefault(testing::Return(false)); | 52 .WillByDefault(testing::Return(false)); |
| 51 ON_CALL(*this, IsConnecting()) | 53 ON_CALL(*this, IsConnecting()) |
| 52 .WillByDefault(testing::Return(false)); | 54 .WillByDefault(testing::Return(false)); |
| 53 ON_CALL(*this, GetUUIDs()).WillByDefault(testing::Return(uuids_)); | 55 ON_CALL(*this, GetUUIDs()).WillByDefault(testing::Return(uuids_)); |
| 54 ON_CALL(*this, ExpectingPinCode()) | 56 ON_CALL(*this, ExpectingPinCode()) |
| 55 .WillByDefault(testing::Return(false)); | 57 .WillByDefault(testing::Return(false)); |
| 56 ON_CALL(*this, ExpectingPasskey()) | 58 ON_CALL(*this, ExpectingPasskey()) |
| 57 .WillByDefault(testing::Return(false)); | 59 .WillByDefault(testing::Return(false)); |
| 58 ON_CALL(*this, ExpectingConfirmation()) | 60 ON_CALL(*this, ExpectingConfirmation()) |
| 59 .WillByDefault(testing::Return(false)); | 61 .WillByDefault(testing::Return(false)); |
| 60 ON_CALL(*this, GetDeviceName()).WillByDefault(testing::Return(name_)); | |
| 61 } | 62 } |
| 62 | 63 |
| 63 MockBluetoothDevice::~MockBluetoothDevice() {} | 64 MockBluetoothDevice::~MockBluetoothDevice() {} |
| 64 | 65 |
| 65 void MockBluetoothDevice::AddMockService( | 66 void MockBluetoothDevice::AddMockService( |
| 66 std::unique_ptr<MockBluetoothGattService> mock_service) { | 67 std::unique_ptr<MockBluetoothGattService> mock_service) { |
| 67 mock_services_.push_back(std::move(mock_service)); | 68 mock_services_.push_back(std::move(mock_service)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() | 71 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() |
| 71 const { | 72 const { |
| 72 std::vector<BluetoothRemoteGattService*> services; | 73 std::vector<BluetoothRemoteGattService*> services; |
| 73 for (BluetoothRemoteGattService* service : mock_services_) { | 74 for (BluetoothRemoteGattService* service : mock_services_) { |
| 74 services.push_back(service); | 75 services.push_back(service); |
| 75 } | 76 } |
| 76 return services; | 77 return services; |
| 77 } | 78 } |
| 78 | 79 |
| 79 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( | 80 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( |
| 80 const std::string& identifier) const { | 81 const std::string& identifier) const { |
| 81 for (BluetoothRemoteGattService* service : mock_services_) { | 82 for (BluetoothRemoteGattService* service : mock_services_) { |
| 82 if (service->GetIdentifier() == identifier) | 83 if (service->GetIdentifier() == identifier) |
| 83 return service; | 84 return service; |
| 84 } | 85 } |
| 85 return nullptr; | 86 return nullptr; |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace device | 89 } // namespace device |
| OLD | NEW |