| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/proximity_auth/bluetooth_connection_finder.h" | 5 #include "components/proximity_auth/bluetooth_connection_finder.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 14 #include "components/proximity_auth/proximity_auth_test_util.h" | 16 #include "components/proximity_auth/proximity_auth_test_util.h" |
| 15 #include "components/proximity_auth/remote_device.h" | 17 #include "components/proximity_auth/remote_device.h" |
| 16 #include "components/proximity_auth/wire_message.h" | 18 #include "components/proximity_auth/wire_message.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 144 |
| 143 // By default, the remote device is known to |adapter_| so | 145 // By default, the remote device is known to |adapter_| so |
| 144 // |SeekDeviceByAddress()| will not be called. | 146 // |SeekDeviceByAddress()| will not be called. |
| 145 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) | 147 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) |
| 146 .WillByDefault(Return(bluetooth_device_.get())); | 148 .WillByDefault(Return(bluetooth_device_.get())); |
| 147 } | 149 } |
| 148 | 150 |
| 149 MOCK_METHOD1(OnConnectionFoundProxy, void(Connection* connection)); | 151 MOCK_METHOD1(OnConnectionFoundProxy, void(Connection* connection)); |
| 150 void OnConnectionFound(scoped_ptr<Connection> connection) { | 152 void OnConnectionFound(scoped_ptr<Connection> connection) { |
| 151 OnConnectionFoundProxy(connection.get()); | 153 OnConnectionFoundProxy(connection.get()); |
| 152 last_found_connection_ = connection.Pass(); | 154 last_found_connection_ = std::move(connection); |
| 153 } | 155 } |
| 154 | 156 |
| 155 // Starts |connection_finder_|. If |expect_connection| is true, then we set an | 157 // Starts |connection_finder_|. If |expect_connection| is true, then we set an |
| 156 // expectation that an in-progress connection will be created and returned. | 158 // expectation that an in-progress connection will be created and returned. |
| 157 MockConnection* StartConnectionFinder(bool expect_connection) { | 159 MockConnection* StartConnectionFinder(bool expect_connection) { |
| 158 MockConnection* connection = nullptr; | 160 MockConnection* connection = nullptr; |
| 159 if (expect_connection) | 161 if (expect_connection) |
| 160 connection = connection_finder_.ExpectCreateConnection(); | 162 connection = connection_finder_.ExpectCreateConnection(); |
| 161 connection_finder_.Find(connection_callback_); | 163 connection_finder_.Find(connection_callback_); |
| 162 return connection; | 164 return connection; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 357 |
| 356 // Successfully connect to the Bluetooth device. | 358 // Successfully connect to the Bluetooth device. |
| 357 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) | 359 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) |
| 358 .WillByDefault(Return(bluetooth_device_.get())); | 360 .WillByDefault(Return(bluetooth_device_.get())); |
| 359 MockConnection* connection = connection_finder_.ExpectCreateConnection(); | 361 MockConnection* connection = connection_finder_.ExpectCreateConnection(); |
| 360 connection_finder_.seek_callback().Run(); | 362 connection_finder_.seek_callback().Run(); |
| 361 SimulateDeviceConnection(connection); | 363 SimulateDeviceConnection(connection); |
| 362 } | 364 } |
| 363 | 365 |
| 364 } // namespace proximity_auth | 366 } // namespace proximity_auth |
| OLD | NEW |