| 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/cryptauth/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" |
| 11 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "components/proximity_auth/fake_connection.h" | 13 #include "components/cryptauth/fake_connection.h" |
| 14 #include "components/proximity_auth/wire_message.h" | 14 #include "components/cryptauth/wire_message.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace proximity_auth { | 17 namespace cryptauth { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class TestBluetoothThrottler : public BluetoothThrottlerImpl { | 20 class TestBluetoothThrottler : public BluetoothThrottlerImpl { |
| 21 public: | 21 public: |
| 22 explicit TestBluetoothThrottler(std::unique_ptr<base::TickClock> clock) | 22 explicit TestBluetoothThrottler(std::unique_ptr<base::TickClock> clock) |
| 23 : BluetoothThrottlerImpl(std::move(clock)) {} | 23 : BluetoothThrottlerImpl(std::move(clock)) {} |
| 24 ~TestBluetoothThrottler() override {} | 24 ~TestBluetoothThrottler() override {} |
| 25 | 25 |
| 26 // Increase visibility for testing. | 26 // Increase visibility for testing. |
| 27 using BluetoothThrottlerImpl::GetCooldownTimeDelta; | 27 using BluetoothThrottlerImpl::GetCooldownTimeDelta; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 TEST_F(ProximityAuthBluetoothThrottlerImplTest, | 91 TEST_F(ProximityAuthBluetoothThrottlerImplTest, |
| 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 cryptauth |
| OLD | NEW |