Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: components/proximity_auth/bluetooth_throttler_impl_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 16 matching lines...) Expand all
27 27
28 private: 28 private:
29 DISALLOW_COPY_AND_ASSIGN(TestBluetoothThrottler); 29 DISALLOW_COPY_AND_ASSIGN(TestBluetoothThrottler);
30 }; 30 };
31 31
32 } // namespace 32 } // namespace
33 33
34 class ProximityAuthBluetoothThrottlerImplTest : public testing::Test { 34 class ProximityAuthBluetoothThrottlerImplTest : public testing::Test {
35 public: 35 public:
36 ProximityAuthBluetoothThrottlerImplTest() 36 ProximityAuthBluetoothThrottlerImplTest()
37 : clock_(new base::SimpleTestTickClock), 37 // The throttler treats null times as special, so start with a non-null
38 throttler_(make_scoped_ptr(clock_)) { 38 // time.
39 // The throttler treats null times as special, so start with a non-null 39 : clock_(new base::SimpleTestTickClock(base::TimeTicks() +
40 // time. 40 base::TimeDelta::FromSeconds(1))),
41 clock_->Advance(base::TimeDelta::FromSeconds(1)); 41 throttler_(make_scoped_ptr(clock_)) {}
42 }
43 42
44 void PerformConnectionStateTransition(Connection::Status old_status, 43 void PerformConnectionStateTransition(Connection::Status old_status,
45 Connection::Status new_status) { 44 Connection::Status new_status) {
46 FakeConnection connection((RemoteDevice())); 45 FakeConnection connection((RemoteDevice()));
47 throttler_.OnConnection(&connection); 46 throttler_.OnConnection(&connection);
48 static_cast<ConnectionObserver*>(&throttler_) 47 static_cast<ConnectionObserver*>(&throttler_)
49 ->OnConnectionStatusChanged(&connection, old_status, new_status); 48 ->OnConnectionStatusChanged(&connection, old_status, new_status);
50 } 49 }
51 50
52 protected: 51 protected:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) { 90 GetDelay_DelayedConnectionAfterInProgressDisconnectIsNotThrottled) {
92 // Simulate an attempt to connect (in progress connection) followed by a 91 // Simulate an attempt to connect (in progress connection) followed by a
93 // disconnection, then allow the cooldown period to elapse. 92 // disconnection, then allow the cooldown period to elapse.
94 PerformConnectionStateTransition(Connection::IN_PROGRESS, 93 PerformConnectionStateTransition(Connection::IN_PROGRESS,
95 Connection::DISCONNECTED); 94 Connection::DISCONNECTED);
96 clock_->Advance(throttler_.GetCooldownTimeDelta()); 95 clock_->Advance(throttler_.GetCooldownTimeDelta());
97 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay()); 96 EXPECT_EQ(base::TimeDelta(), throttler_.GetDelay());
98 } 97 }
99 98
100 } // namespace proximity_auth 99 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698