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/bluetooth_throttler_impl.h" | 5 #include "components/proximity_auth/bluetooth_throttler_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 ProximityAuthBluetoothThrottlerImplTest() | 37 ProximityAuthBluetoothThrottlerImplTest() |
38 : clock_(new base::SimpleTestTickClock), | 38 : clock_(new base::SimpleTestTickClock), |
39 throttler_(base::WrapUnique(clock_)) { | 39 throttler_(base::WrapUnique(clock_)) { |
40 // The throttler treats null times as special, so start with a non-null | 40 // The throttler treats null times as special, so start with a non-null |
41 // time. | 41 // time. |
42 clock_->Advance(base::TimeDelta::FromSeconds(1)); | 42 clock_->Advance(base::TimeDelta::FromSeconds(1)); |
43 } | 43 } |
44 | 44 |
45 void PerformConnectionStateTransition(Connection::Status old_status, | 45 void PerformConnectionStateTransition(Connection::Status old_status, |
46 Connection::Status new_status) { | 46 Connection::Status new_status) { |
47 FakeConnection connection((RemoteDevice())); | 47 FakeConnection connection((cryptauth::RemoteDevice())); |
48 throttler_.OnConnection(&connection); | 48 throttler_.OnConnection(&connection); |
49 static_cast<ConnectionObserver*>(&throttler_) | 49 static_cast<ConnectionObserver*>(&throttler_) |
50 ->OnConnectionStatusChanged(&connection, old_status, new_status); | 50 ->OnConnectionStatusChanged(&connection, old_status, new_status); |
51 } | 51 } |
52 | 52 |
53 protected: | 53 protected: |
54 // The clock is owned by the |throttler_|. | 54 // The clock is owned by the |throttler_|. |
55 base::SimpleTestTickClock* clock_; | 55 base::SimpleTestTickClock* clock_; |
56 TestBluetoothThrottler throttler_; | 56 TestBluetoothThrottler throttler_; |
57 }; | 57 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) { | 92 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) { |
93 // Simulate an attempt to connect (in progress connection) followed by a | 93 // Simulate an attempt to connect (in progress connection) followed by a |
94 // disconnection, then allow the cooldown period to elapse. | 94 // disconnection, then allow the cooldown period to elapse. |
95 PerformConnectionStateTransition(Connection::IN_PROGRESS, | 95 PerformConnectionStateTransition(Connection::IN_PROGRESS, |
96 Connection::DISCONNECTED); | 96 Connection::DISCONNECTED); |
97 clock_->Advance(throttler_.GetCooldownTimeDelta()); | 97 clock_->Advance(throttler_.GetCooldownTimeDelta()); |
98 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay()); | 98 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay()); |
99 } | 99 } |
100 | 100 |
101 } // namespace proximity_auth | 101 } // namespace proximity_auth |
OLD | NEW |