OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/throttled_bluetooth_connection_finder.h" | 5 #include "components/proximity_auth/throttled_bluetooth_connection_finder.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 class FakeBluetoothConnectionFinder : public BluetoothConnectionFinder { | 51 class FakeBluetoothConnectionFinder : public BluetoothConnectionFinder { |
52 public: | 52 public: |
53 FakeBluetoothConnectionFinder() | 53 FakeBluetoothConnectionFinder() |
54 : BluetoothConnectionFinder( | 54 : BluetoothConnectionFinder( |
55 RemoteDevice(), | 55 RemoteDevice(), |
56 device::BluetoothUUID(kUuid), | 56 device::BluetoothUUID(kUuid), |
57 base::TimeDelta::FromSeconds(kPollingIntervalSeconds)) {} | 57 base::TimeDelta::FromSeconds(kPollingIntervalSeconds)) {} |
58 ~FakeBluetoothConnectionFinder() override {} | 58 ~FakeBluetoothConnectionFinder() override {} |
59 | 59 |
60 void Find(const ConnectionCallback& connection_callback) override { | 60 void Find(const ConnectionCallback& connection_callback) override { |
61 connection_callback.Run( | 61 connection_callback.Run(base::MakeUnique<FakeConnection>(RemoteDevice())); |
62 base::WrapUnique(new FakeConnection(RemoteDevice()))); | |
63 } | 62 } |
64 | 63 |
65 private: | 64 private: |
66 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothConnectionFinder); | 65 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothConnectionFinder); |
67 }; | 66 }; |
68 | 67 |
69 } // namespace | 68 } // namespace |
70 | 69 |
71 class ProximityAuthThrottledBluetoothConnectionFinderTest | 70 class ProximityAuthThrottledBluetoothConnectionFinderTest |
72 : public testing::Test { | 71 : public testing::Test { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ThrottledBluetoothConnectionFinder connection_finder( | 115 ThrottledBluetoothConnectionFinder connection_finder( |
117 base::WrapUnique(new FakeBluetoothConnectionFinder), task_runner_, | 116 base::WrapUnique(new FakeBluetoothConnectionFinder), task_runner_, |
118 &throttler_); | 117 &throttler_); |
119 std::unique_ptr<Connection> connection; | 118 std::unique_ptr<Connection> connection; |
120 EXPECT_CALL(throttler_, OnConnection(_)); | 119 EXPECT_CALL(throttler_, OnConnection(_)); |
121 connection_finder.Find(base::Bind(&SaveConnection, &connection)); | 120 connection_finder.Find(base::Bind(&SaveConnection, &connection)); |
122 EXPECT_TRUE(connection); | 121 EXPECT_TRUE(connection); |
123 } | 122 } |
124 | 123 |
125 } // namespace proximity_auth | 124 } // namespace proximity_auth |
OLD | NEW |