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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 MockBluetoothDevice::~MockBluetoothDevice() {} | 66 MockBluetoothDevice::~MockBluetoothDevice() {} |
67 | 67 |
68 void MockBluetoothDevice::AddMockService( | 68 void MockBluetoothDevice::AddMockService( |
69 std::unique_ptr<MockBluetoothGattService> mock_service) { | 69 std::unique_ptr<MockBluetoothGattService> mock_service) { |
70 mock_services_.push_back(std::move(mock_service)); | 70 mock_services_.push_back(std::move(mock_service)); |
71 } | 71 } |
72 | 72 |
73 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() | 73 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() |
74 const { | 74 const { |
75 std::vector<BluetoothRemoteGattService*> services; | 75 std::vector<BluetoothRemoteGattService*> services; |
76 for (BluetoothRemoteGattService* service : mock_services_) { | 76 for (const auto& service : mock_services_) { |
77 services.push_back(service); | 77 services.push_back(service.get()); |
78 } | 78 } |
79 return services; | 79 return services; |
80 } | 80 } |
81 | 81 |
82 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( | 82 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( |
83 const std::string& identifier) const { | 83 const std::string& identifier) const { |
84 for (BluetoothRemoteGattService* service : mock_services_) { | 84 for (const auto& service : mock_services_) { |
85 if (service->GetIdentifier() == identifier) | 85 if (service->GetIdentifier() == identifier) |
86 return service; | 86 return service.get(); |
87 } | 87 } |
88 return nullptr; | 88 return nullptr; |
89 } | 89 } |
90 | 90 |
91 void MockBluetoothDevice::PushPendingCallback(const base::Closure& callback) { | 91 void MockBluetoothDevice::PushPendingCallback(const base::Closure& callback) { |
92 pending_callbacks_.push(callback); | 92 pending_callbacks_.push(callback); |
93 } | 93 } |
94 | 94 |
95 void MockBluetoothDevice::RunPendingCallbacks() { | 95 void MockBluetoothDevice::RunPendingCallbacks() { |
96 while (!pending_callbacks_.empty()) { | 96 while (!pending_callbacks_.empty()) { |
97 pending_callbacks_.front().Run(); | 97 pending_callbacks_.front().Run(); |
98 pending_callbacks_.pop(); | 98 pending_callbacks_.pop(); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 } // namespace device | 102 } // namespace device |
OLD | NEW |