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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/cryptauth/remote_device.h" | 17 #include "components/cryptauth/remote_device.h" |
| 18 #include "components/cryptauth/wire_message.h" |
18 #include "components/proximity_auth/proximity_auth_test_util.h" | 19 #include "components/proximity_auth/proximity_auth_test_util.h" |
19 #include "components/proximity_auth/wire_message.h" | |
20 #include "device/bluetooth/bluetooth_adapter_factory.h" | 20 #include "device/bluetooth/bluetooth_adapter_factory.h" |
21 #include "device/bluetooth/bluetooth_uuid.h" | 21 #include "device/bluetooth/bluetooth_uuid.h" |
22 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 22 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
23 #include "device/bluetooth/test/mock_bluetooth_device.h" | 23 #include "device/bluetooth/test/mock_bluetooth_device.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 using testing::_; | 27 using testing::_; |
28 using testing::NiceMock; | 28 using testing::NiceMock; |
29 using testing::Return; | 29 using testing::Return; |
(...skipping 16 matching lines...) Expand all Loading... |
46 void SetStatus(Connection::Status status) { | 46 void SetStatus(Connection::Status status) { |
47 // This object should not be destroyed after setting the status and calling | 47 // This object should not be destroyed after setting the status and calling |
48 // observers. | 48 // observers. |
49 do_not_destroy_ = true; | 49 do_not_destroy_ = true; |
50 Connection::SetStatus(status); | 50 Connection::SetStatus(status); |
51 do_not_destroy_ = false; | 51 do_not_destroy_ = false; |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 void Disconnect() override {} | 55 void Disconnect() override {} |
56 void SendMessageImpl(std::unique_ptr<WireMessage> message) override {} | 56 void SendMessageImpl( |
| 57 std::unique_ptr<cryptauth::WireMessage> message) override {} |
57 | 58 |
58 // If true, we do not expect |this| object to be destroyed until this value is | 59 // If true, we do not expect |this| object to be destroyed until this value is |
59 // toggled back to false. | 60 // toggled back to false. |
60 bool do_not_destroy_; | 61 bool do_not_destroy_; |
61 | 62 |
62 DISALLOW_COPY_AND_ASSIGN(MockConnection); | 63 DISALLOW_COPY_AND_ASSIGN(MockConnection); |
63 }; | 64 }; |
64 | 65 |
65 class MockBluetoothConnectionFinder : public BluetoothConnectionFinder { | 66 class MockBluetoothConnectionFinder : public BluetoothConnectionFinder { |
66 public: | 67 public: |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 // Successfully connect to the Bluetooth device. | 360 // Successfully connect to the Bluetooth device. |
360 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) | 361 ON_CALL(*adapter_, GetDevice(kTestRemoteDeviceBluetoothAddress)) |
361 .WillByDefault(Return(bluetooth_device_.get())); | 362 .WillByDefault(Return(bluetooth_device_.get())); |
362 MockConnection* connection = connection_finder_.ExpectCreateConnection(); | 363 MockConnection* connection = connection_finder_.ExpectCreateConnection(); |
363 connection_finder_.seek_callback().Run(); | 364 connection_finder_.seek_callback().Run(); |
364 SimulateDeviceConnection(connection); | 365 SimulateDeviceConnection(connection); |
365 } | 366 } |
366 | 367 |
367 } // namespace proximity_auth | 368 } // namespace proximity_auth |
OLD | NEW |