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

Side by Side Diff: components/network_time/network_time_tracker_unittest.cc

Issue 1551433002: Switch to standard integer types in components/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/network_time/network_time_tracker.h" 5 #include "components/network_time/network_time_tracker.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stdint.h>
8 9
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/prefs/testing_pref_service.h" 11 #include "base/prefs/testing_pref_service.h"
11 #include "base/time/tick_clock.h" 12 #include "base/time/tick_clock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace network_time { 15 namespace network_time {
15 16
16 namespace { 17 namespace {
17 18
18 // These are all in milliseconds. 19 // These are all in milliseconds.
19 const int64 kLatency1 = 50; 20 const int64_t kLatency1 = 50;
20 const int64 kLatency2 = 500; 21 const int64_t kLatency2 = 500;
21 22
22 // Can not be smaller than 15, it's the NowFromSystemTime() resolution. 23 // Can not be smaller than 15, it's the NowFromSystemTime() resolution.
23 const int64 kResolution1 = 17; 24 const int64_t kResolution1 = 17;
24 const int64 kResolution2 = 177; 25 const int64_t kResolution2 = 177;
25 26
26 const int64 kPseudoSleepTime1 = 500000001; 27 const int64_t kPseudoSleepTime1 = 500000001;
27 const int64 kPseudoSleepTime2 = 1888; 28 const int64_t kPseudoSleepTime2 = 1888;
28 29
29 // A custom tick clock that will return an arbitrary time. 30 // A custom tick clock that will return an arbitrary time.
30 class TestTickClock : public base::TickClock { 31 class TestTickClock : public base::TickClock {
31 public: 32 public:
32 explicit TestTickClock(base::TimeTicks* ticks_now) : ticks_now_(ticks_now) {} 33 explicit TestTickClock(base::TimeTicks* ticks_now) : ticks_now_(ticks_now) {}
33 ~TestTickClock() override {} 34 ~TestTickClock() override {}
34 35
35 base::TimeTicks NowTicks() override { return *ticks_now_; } 36 base::TimeTicks NowTicks() override { return *ticks_now_; }
36 37
37 private: 38 private:
(...skipping 16 matching lines...) Expand all
54 } 55 }
55 56
56 base::Time Now() const { 57 base::Time Now() const {
57 return now_ + (ticks_now_ - base::TimeTicks()); 58 return now_ + (ticks_now_ - base::TimeTicks());
58 } 59 }
59 60
60 base::TimeTicks TicksNow() const { 61 base::TimeTicks TicksNow() const {
61 return ticks_now_; 62 return ticks_now_;
62 } 63 }
63 64
64 void AddToTicksNow(int64 ms) { 65 void AddToTicksNow(int64_t ms) {
65 ticks_now_ += base::TimeDelta::FromMilliseconds(ms); 66 ticks_now_ += base::TimeDelta::FromMilliseconds(ms);
66 } 67 }
67 68
68 // Updates the notifier's time with the specified parameters. 69 // Updates the notifier's time with the specified parameters.
69 void UpdateNetworkTime(const base::Time& network_time, 70 void UpdateNetworkTime(const base::Time& network_time,
70 const base::TimeDelta& resolution, 71 const base::TimeDelta& resolution,
71 const base::TimeDelta& latency, 72 const base::TimeDelta& latency,
72 const base::TimeTicks& post_time) { 73 const base::TimeTicks& post_time) {
73 network_time_tracker_->UpdateNetworkTime( 74 network_time_tracker_->UpdateNetworkTime(
74 network_time, resolution, latency, post_time); 75 network_time, resolution, latency, post_time);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 AddToTicksNow(kPseudoSleepTime2); 153 AddToTicksNow(kPseudoSleepTime2);
153 UpdateNetworkTime( 154 UpdateNetworkTime(
154 old_now, 155 old_now,
155 base::TimeDelta::FromMilliseconds(kResolution2), 156 base::TimeDelta::FromMilliseconds(kResolution2),
156 base::TimeDelta::FromMilliseconds(kLatency2), 157 base::TimeDelta::FromMilliseconds(kLatency2),
157 old_ticks); 158 old_ticks);
158 EXPECT_TRUE(ValidateExpectedTime()); 159 EXPECT_TRUE(ValidateExpectedTime());
159 } 160 }
160 161
161 } // namespace network_time 162 } // namespace network_time
OLDNEW
« no previous file with comments | « components/network_time/network_time_tracker.cc ('k') | components/ntp_snippets/ntp_snippets_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698