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

Side by Side Diff: remoting/host/backoff_timer_unittest.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
« no previous file with comments | « remoting/host/backoff_timer.cc ('k') | remoting/host/basic_desktop_environment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "remoting/host/backoff_timer.h" 5 #include "remoting/host/backoff_timer.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/timer/mock_timer.h" 8 #include "base/timer/mock_timer.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace remoting { 11 namespace remoting {
11 12
12 namespace { 13 namespace {
13 14
14 void IncrementCounter(int* counter) { 15 void IncrementCounter(int* counter) {
15 ++(*counter); 16 ++(*counter);
16 } 17 }
17 18
18 } // namespace 19 } // namespace
19 20
20 TEST(BackoffTimer, Basic) { 21 TEST(BackoffTimer, Basic) {
21 base::MockTimer* mock_timer = new base::MockTimer(false, false); 22 base::MockTimer* mock_timer = new base::MockTimer(false, false);
22 BackoffTimer backoff_timer; 23 BackoffTimer backoff_timer;
23 backoff_timer.SetTimerForTest(make_scoped_ptr(mock_timer)); 24 backoff_timer.SetTimerForTest(base::WrapUnique(mock_timer));
24 ASSERT_FALSE(backoff_timer.IsRunning()); 25 ASSERT_FALSE(backoff_timer.IsRunning());
25 26
26 int counter = 0; 27 int counter = 0;
27 backoff_timer.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(10), 28 backoff_timer.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(10),
28 base::TimeDelta::FromMilliseconds(50), 29 base::TimeDelta::FromMilliseconds(50),
29 base::Bind(&IncrementCounter, &counter)); 30 base::Bind(&IncrementCounter, &counter));
30 ASSERT_TRUE(backoff_timer.IsRunning()); 31 ASSERT_TRUE(backoff_timer.IsRunning());
31 ASSERT_EQ(0, counter); 32 ASSERT_EQ(0, counter);
32 ASSERT_NEAR(0, mock_timer->GetCurrentDelay().InMillisecondsF(), 1); 33 ASSERT_NEAR(0, mock_timer->GetCurrentDelay().InMillisecondsF(), 1);
33 34
(...skipping 20 matching lines...) Expand all
54 mock_timer->Fire(); 55 mock_timer->Fire();
55 ASSERT_TRUE(backoff_timer.IsRunning()); 56 ASSERT_TRUE(backoff_timer.IsRunning());
56 ASSERT_EQ(5, counter); 57 ASSERT_EQ(5, counter);
57 EXPECT_NEAR(50, mock_timer->GetCurrentDelay().InMillisecondsF(), 1); 58 EXPECT_NEAR(50, mock_timer->GetCurrentDelay().InMillisecondsF(), 1);
58 59
59 backoff_timer.Stop(); 60 backoff_timer.Stop();
60 ASSERT_FALSE(backoff_timer.IsRunning()); 61 ASSERT_FALSE(backoff_timer.IsRunning());
61 } 62 }
62 63
63 } // namespace remoting 64 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/backoff_timer.cc ('k') | remoting/host/basic_desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698