| 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> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 10 #include "components/proximity_auth/fake_connection.h" | 12 #include "components/proximity_auth/fake_connection.h" |
| 11 #include "components/proximity_auth/wire_message.h" | 13 #include "components/proximity_auth/wire_message.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 namespace proximity_auth { | 16 namespace proximity_auth { |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 class TestBluetoothThrottler : public BluetoothThrottlerImpl { | 19 class TestBluetoothThrottler : public BluetoothThrottlerImpl { |
| 18 public: | 20 public: |
| 19 explicit TestBluetoothThrottler(scoped_ptr<base::TickClock> clock) | 21 explicit TestBluetoothThrottler(scoped_ptr<base::TickClock> clock) |
| 20 : BluetoothThrottlerImpl(clock.Pass()) {} | 22 : BluetoothThrottlerImpl(std::move(clock)) {} |
| 21 ~TestBluetoothThrottler() override {} | 23 ~TestBluetoothThrottler() override {} |
| 22 | 24 |
| 23 // Increase visibility for testing. | 25 // Increase visibility for testing. |
| 24 using BluetoothThrottlerImpl::GetCooldownTimeDelta; | 26 using BluetoothThrottlerImpl::GetCooldownTimeDelta; |
| 25 | 27 |
| 26 private: | 28 private: |
| 27 DISALLOW_COPY_AND_ASSIGN(TestBluetoothThrottler); | 29 DISALLOW_COPY_AND_ASSIGN(TestBluetoothThrottler); |
| 28 }; | 30 }; |
| 29 | 31 |
| 30 } // namespace | 32 } // namespace |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) { | 91 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) { |
| 90 // Simulate an attempt to connect (in progress connection) followed by a | 92 // Simulate an attempt to connect (in progress connection) followed by a |
| 91 // disconnection, then allow the cooldown period to elapse. | 93 // disconnection, then allow the cooldown period to elapse. |
| 92 PerformConnectionStateTransition(Connection::IN_PROGRESS, | 94 PerformConnectionStateTransition(Connection::IN_PROGRESS, |
| 93 Connection::DISCONNECTED); | 95 Connection::DISCONNECTED); |
| 94 clock_->Advance(throttler_.GetCooldownTimeDelta()); | 96 clock_->Advance(throttler_.GetCooldownTimeDelta()); |
| 95 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay()); | 97 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 } // namespace proximity_auth | 100 } // namespace proximity_auth |
| OLD | NEW |