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

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

Issue 1835823002: network_time_tracker: add temporary time protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: estark review 1 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
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 "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop/message_loop.h"
8 #include "base/test/simple_test_clock.h" 9 #include "base/test/simple_test_clock.h"
9 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
10 #include "components/network_time/network_time_pref_names.h" 11 #include "components/network_time/network_time_pref_names.h"
11 #include "components/prefs/testing_pref_service.h" 12 #include "components/prefs/testing_pref_service.h"
13 #include "net/http/http_response_headers.h"
14 #include "net/url_request/test_url_fetcher_factory.h"
15 #include "net/url_request/url_request_test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
13 17
14 namespace network_time { 18 namespace network_time {
15 19
16 class NetworkTimeTrackerTest : public testing::Test { 20 class NetworkTimeTrackerTest : public testing::Test {
17 public: 21 public:
18 ~NetworkTimeTrackerTest() override {} 22 ~NetworkTimeTrackerTest() override {}
19 23
20 void SetUp() override { 24 void SetUp() override {
25 url_fetcher_factory_.reset(new net::TestURLFetcherFactory());
21 NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); 26 NetworkTimeTracker::RegisterPrefs(pref_service_.registry());
22 27
23 clock_ = new base::SimpleTestClock(); 28 clock_ = new base::SimpleTestClock();
24 tick_clock_ = new base::SimpleTestTickClock(); 29 tick_clock_ = new base::SimpleTestTickClock();
25 // Do this to be sure that |is_null| returns false. 30 // Do this to be sure that |is_null| returns false.
26 clock_->Advance(base::TimeDelta::FromDays(111)); 31 clock_->Advance(base::TimeDelta::FromDays(111));
27 tick_clock_->Advance(base::TimeDelta::FromDays(222)); 32 tick_clock_->Advance(base::TimeDelta::FromDays(222));
28 33
29 tracker_.reset(new NetworkTimeTracker( 34 tracker_.reset(new NetworkTimeTracker(
30 scoped_ptr<base::Clock>(clock_), 35 scoped_ptr<base::Clock>(clock_),
31 scoped_ptr<base::TickClock>(tick_clock_), 36 scoped_ptr<base::TickClock>(tick_clock_), &pref_service_,
32 &pref_service_)); 37 new net::TestURLRequestContextGetter(message_loop_.task_runner())));
33 38
34 // Can not be smaller than 15, it's the NowFromSystemTime() resolution. 39 // Can not be smaller than 15, it's the NowFromSystemTime() resolution.
35 resolution_ = base::TimeDelta::FromMilliseconds(17); 40 resolution_ = base::TimeDelta::FromMilliseconds(17);
36 latency_ = base::TimeDelta::FromMilliseconds(50); 41 latency_ = base::TimeDelta::FromMilliseconds(50);
37 adjustment_ = 7 * base::TimeDelta::FromMilliseconds(kTicksResolutionMs); 42 adjustment_ = 7 * base::TimeDelta::FromMilliseconds(kTicksResolutionMs);
38 } 43 }
39 44
40 // Replaces |tracker_| with a new object, while preserving the 45 // Replaces |tracker_| with a new object, while preserving the
41 // testing clocks. 46 // testing clocks.
42 void Reset() { 47 void Reset() {
43 base::SimpleTestClock* new_clock = new base::SimpleTestClock(); 48 base::SimpleTestClock* new_clock = new base::SimpleTestClock();
44 new_clock->SetNow(clock_->Now()); 49 new_clock->SetNow(clock_->Now());
45 base::SimpleTestTickClock* new_tick_clock = new base::SimpleTestTickClock(); 50 base::SimpleTestTickClock* new_tick_clock = new base::SimpleTestTickClock();
46 new_tick_clock->SetNowTicks(tick_clock_->NowTicks()); 51 new_tick_clock->SetNowTicks(tick_clock_->NowTicks());
47 clock_ = new_clock; 52 clock_ = new_clock;
48 tick_clock_= new_tick_clock; 53 tick_clock_= new_tick_clock;
49 tracker_.reset(new NetworkTimeTracker( 54 tracker_.reset(new NetworkTimeTracker(
50 scoped_ptr<base::Clock>(clock_), 55 scoped_ptr<base::Clock>(clock_),
51 scoped_ptr<base::TickClock>(tick_clock_), 56 scoped_ptr<base::TickClock>(tick_clock_), &pref_service_,
52 &pref_service_)); 57 new net::TestURLRequestContextGetter(message_loop_.task_runner())));
53 } 58 }
54 59
55 // Updates the notifier's time with the specified parameters. 60 // Updates the notifier's time with the specified parameters.
56 void UpdateNetworkTime(const base::Time& network_time, 61 void UpdateNetworkTime(const base::Time& network_time,
57 const base::TimeDelta& resolution, 62 const base::TimeDelta& resolution,
58 const base::TimeDelta& latency, 63 const base::TimeDelta& latency,
59 const base::TimeTicks& post_time) { 64 const base::TimeTicks& post_time) {
60 tracker_->UpdateNetworkTime( 65 tracker_->UpdateNetworkTime(
61 network_time, resolution, latency, post_time); 66 network_time, resolution, latency, post_time);
62 } 67 }
63 68
64 // Advances both the system clock and the tick clock. This should be used for 69 // Advances both the system clock and the tick clock. This should be used for
65 // the normal passage of time, i.e. when neither clock is doing anything odd. 70 // the normal passage of time, i.e. when neither clock is doing anything odd.
66 void AdvanceBoth(const base::TimeDelta& delta) { 71 void AdvanceBoth(const base::TimeDelta& delta) {
67 tick_clock_->Advance(delta); 72 tick_clock_->Advance(delta);
68 clock_->Advance(delta); 73 clock_->Advance(delta);
69 } 74 }
70 75
71 protected: 76 protected:
77 base::MessageLoop message_loop_;
72 base::TimeDelta resolution_; 78 base::TimeDelta resolution_;
73 base::TimeDelta latency_; 79 base::TimeDelta latency_;
74 base::TimeDelta adjustment_; 80 base::TimeDelta adjustment_;
75 base::SimpleTestClock* clock_; 81 base::SimpleTestClock* clock_;
76 base::SimpleTestTickClock* tick_clock_; 82 base::SimpleTestTickClock* tick_clock_;
77 TestingPrefServiceSimple pref_service_; 83 TestingPrefServiceSimple pref_service_;
78 scoped_ptr<NetworkTimeTracker> tracker_; 84 scoped_ptr<NetworkTimeTracker> tracker_;
85 scoped_ptr<net::TestURLFetcherFactory> url_fetcher_factory_;
79 }; 86 };
80 87
81 TEST_F(NetworkTimeTrackerTest, Uninitialized) { 88 TEST_F(NetworkTimeTrackerTest, Uninitialized) {
82 base::Time network_time; 89 base::Time network_time;
83 base::TimeDelta uncertainty; 90 base::TimeDelta uncertainty;
84 EXPECT_FALSE(tracker_->GetNetworkTime(&network_time, &uncertainty)); 91 EXPECT_FALSE(tracker_->GetNetworkTime(&network_time, &uncertainty));
85 } 92 }
86 93
87 TEST_F(NetworkTimeTrackerTest, LongPostingDelay) { 94 TEST_F(NetworkTimeTrackerTest, LongPostingDelay) {
88 // The request arrives at the server, which records the time. Advance the 95 // The request arrives at the server, which records the time. Advance the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 EXPECT_GT(out_network_time + uncertainty / 2, clock_->Now()); 131 EXPECT_GT(out_network_time + uncertainty / 2, clock_->Now());
125 } 132 }
126 133
127 TEST_F(NetworkTimeTrackerTest, ClockIsWack) { 134 TEST_F(NetworkTimeTrackerTest, ClockIsWack) {
128 // Now let's assume the system clock is completely wrong. 135 // Now let's assume the system clock is completely wrong.
129 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 136 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
130 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 137 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
131 tick_clock_->NowTicks()); 138 tick_clock_->NowTicks());
132 139
133 base::Time out_network_time; 140 base::Time out_network_time;
134 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, NULL)); 141 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
135 EXPECT_EQ(in_network_time, out_network_time); 142 EXPECT_EQ(in_network_time, out_network_time);
136 } 143 }
137 144
138 TEST_F(NetworkTimeTrackerTest, ClocksDivergeSlightly) { 145 TEST_F(NetworkTimeTrackerTest, ClocksDivergeSlightly) {
139 // The two clocks are allowed to diverge a little bit. 146 // The two clocks are allowed to diverge a little bit.
140 base::Time in_network_time = clock_->Now(); 147 base::Time in_network_time = clock_->Now();
141 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 148 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
142 tick_clock_->NowTicks()); 149 tick_clock_->NowTicks());
143 150
144 base::TimeDelta small = base::TimeDelta::FromSeconds(30); 151 base::TimeDelta small = base::TimeDelta::FromSeconds(30);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 EXPECT_EQ(resolution_ + latency_ + adjustment_, uncertainty); 185 EXPECT_EQ(resolution_ + latency_ + adjustment_, uncertainty);
179 } 186 }
180 187
181 TEST_F(NetworkTimeTrackerTest, SpringForward) { 188 TEST_F(NetworkTimeTrackerTest, SpringForward) {
182 // Simulate the wall clock advancing faster than the tick clock. 189 // Simulate the wall clock advancing faster than the tick clock.
183 UpdateNetworkTime(clock_->Now(), resolution_, latency_, 190 UpdateNetworkTime(clock_->Now(), resolution_, latency_,
184 tick_clock_->NowTicks()); 191 tick_clock_->NowTicks());
185 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); 192 tick_clock_->Advance(base::TimeDelta::FromSeconds(1));
186 clock_->Advance(base::TimeDelta::FromDays(1)); 193 clock_->Advance(base::TimeDelta::FromDays(1));
187 base::Time out_network_time; 194 base::Time out_network_time;
188 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 195 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
189 } 196 }
190 197
191 TEST_F(NetworkTimeTrackerTest, FallBack) { 198 TEST_F(NetworkTimeTrackerTest, FallBack) {
192 // Simulate the wall clock running backward. 199 // Simulate the wall clock running backward.
193 UpdateNetworkTime(clock_->Now(), resolution_, latency_, 200 UpdateNetworkTime(clock_->Now(), resolution_, latency_,
194 tick_clock_->NowTicks()); 201 tick_clock_->NowTicks());
195 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); 202 tick_clock_->Advance(base::TimeDelta::FromSeconds(1));
196 clock_->Advance(base::TimeDelta::FromDays(-1)); 203 clock_->Advance(base::TimeDelta::FromDays(-1));
197 base::Time out_network_time; 204 base::Time out_network_time;
198 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 205 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
199 } 206 }
200 207
201 TEST_F(NetworkTimeTrackerTest, SuspendAndResume) { 208 TEST_F(NetworkTimeTrackerTest, SuspendAndResume) {
202 // Simulate the wall clock advancing while the tick clock stands still, as 209 // Simulate the wall clock advancing while the tick clock stands still, as
203 // would happen in a suspend+resume cycle. 210 // would happen in a suspend+resume cycle.
204 UpdateNetworkTime(clock_->Now(), resolution_, latency_, 211 UpdateNetworkTime(clock_->Now(), resolution_, latency_,
205 tick_clock_->NowTicks()); 212 tick_clock_->NowTicks());
206 clock_->Advance(base::TimeDelta::FromHours(1)); 213 clock_->Advance(base::TimeDelta::FromHours(1));
207 base::Time out_network_time; 214 base::Time out_network_time;
208 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 215 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
209 } 216 }
210 217
211 TEST_F(NetworkTimeTrackerTest, Serialize) { 218 TEST_F(NetworkTimeTrackerTest, Serialize) {
212 // Test that we can serialize and deserialize state and get consistent 219 // Test that we can serialize and deserialize state and get consistent
213 // results. 220 // results.
214 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 221 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
215 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 222 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
216 tick_clock_->NowTicks()); 223 tick_clock_->NowTicks());
217 base::Time out_network_time; 224 base::Time out_network_time;
218 base::TimeDelta out_uncertainty; 225 base::TimeDelta out_uncertainty;
(...skipping 11 matching lines...) Expand all
230 } 237 }
231 238
232 TEST_F(NetworkTimeTrackerTest, DeserializeOldFormat) { 239 TEST_F(NetworkTimeTrackerTest, DeserializeOldFormat) {
233 // Test that deserializing old data (which do not record the uncertainty and 240 // Test that deserializing old data (which do not record the uncertainty and
234 // tick clock) causes the serialized data to be ignored. 241 // tick clock) causes the serialized data to be ignored.
235 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 242 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
236 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 243 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
237 tick_clock_->NowTicks()); 244 tick_clock_->NowTicks());
238 245
239 base::Time out_network_time; 246 base::Time out_network_time;
240 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, NULL)); 247 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
241 double local, network; 248 double local, network;
242 const base::DictionaryValue* saved_prefs = 249 const base::DictionaryValue* saved_prefs =
243 pref_service_.GetDictionary(prefs::kNetworkTimeMapping); 250 pref_service_.GetDictionary(prefs::kNetworkTimeMapping);
244 saved_prefs->GetDouble("local", &local); 251 saved_prefs->GetDouble("local", &local);
245 saved_prefs->GetDouble("network", &network); 252 saved_prefs->GetDouble("network", &network);
246 base::DictionaryValue prefs; 253 base::DictionaryValue prefs;
247 prefs.SetDouble("local", local); 254 prefs.SetDouble("local", local);
248 prefs.SetDouble("network", network); 255 prefs.SetDouble("network", network);
249 pref_service_.Set(prefs::kNetworkTimeMapping, prefs); 256 pref_service_.Set(prefs::kNetworkTimeMapping, prefs);
250 Reset(); 257 Reset();
251 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 258 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
252 } 259 }
253 260
254 TEST_F(NetworkTimeTrackerTest, SerializeWithLongDelay) { 261 TEST_F(NetworkTimeTrackerTest, SerializeWithLongDelay) {
255 // Test that if the serialized data are more than a week old, they are 262 // Test that if the serialized data are more than a week old, they are
256 // discarded. 263 // discarded.
257 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 264 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
258 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 265 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
259 tick_clock_->NowTicks()); 266 tick_clock_->NowTicks());
260 base::Time out_network_time; 267 base::Time out_network_time;
261 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, NULL)); 268 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
262 AdvanceBoth(base::TimeDelta::FromDays(8)); 269 AdvanceBoth(base::TimeDelta::FromDays(8));
263 Reset(); 270 Reset();
264 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 271 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
265 } 272 }
266 273
267 TEST_F(NetworkTimeTrackerTest, SerializeWithTickClockAdvance) { 274 TEST_F(NetworkTimeTrackerTest, SerializeWithTickClockAdvance) {
268 // Test that serialized data are discarded if the wall clock and tick clock 275 // Test that serialized data are discarded if the wall clock and tick clock
269 // have not advanced consistently since data were serialized. 276 // have not advanced consistently since data were serialized.
270 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 277 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
271 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 278 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
272 tick_clock_->NowTicks()); 279 tick_clock_->NowTicks());
273 base::Time out_network_time; 280 base::Time out_network_time;
274 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, NULL)); 281 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
275 tick_clock_->Advance(base::TimeDelta::FromDays(1)); 282 tick_clock_->Advance(base::TimeDelta::FromDays(1));
276 Reset(); 283 Reset();
277 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 284 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
278 } 285 }
279 286
280 TEST_F(NetworkTimeTrackerTest, SerializeWithWallClockAdvance) { 287 TEST_F(NetworkTimeTrackerTest, SerializeWithWallClockAdvance) {
281 // Test that serialized data are discarded if the wall clock and tick clock 288 // Test that serialized data are discarded if the wall clock and tick clock
282 // have not advanced consistently since data were serialized. 289 // have not advanced consistently since data were serialized.
283 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90); 290 base::Time in_network_time = clock_->Now() - base::TimeDelta::FromDays(90);
284 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_, 291 UpdateNetworkTime(in_network_time - latency_ / 2, resolution_, latency_,
285 tick_clock_->NowTicks()); 292 tick_clock_->NowTicks());
286 293
287 base::Time out_network_time; 294 base::Time out_network_time;
288 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, NULL)); 295 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
289 clock_->Advance(base::TimeDelta::FromDays(1)); 296 clock_->Advance(base::TimeDelta::FromDays(1));
290 Reset(); 297 Reset();
291 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, NULL)); 298 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
299 }
300
301 TEST_F(NetworkTimeTrackerTest, UpdateFromNetwork) {
302 base::Time out_network_time;
303 EXPECT_EQ(nullptr, url_fetcher_factory_->GetFetcherByID(0));
304 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
305
306 tracker_->QueryTimeService();
307 net::TestURLFetcher* fetcher = url_fetcher_factory_->GetFetcherByID(0);
308 ASSERT_NE(nullptr, fetcher);
309 EXPECT_EQ("", fetcher->upload_data());
310
311 fetcher->set_response_code(200);
312 fetcher->SetResponseString(
313 "{\"current_time_millis\":1458939575214,\"server_nonce\":8."
314 "18927404567873E115}");
315 fetcher->set_response_headers(new net::HttpResponseHeaders(
316 "x-cup-server-proof: "
317 "304402206f29b656ee23aafc7b6df4cfaa3bf711018cca2cbdbcb366932ae4433286f1f6"
318 "022061ddbd4a6ea0d5d36b9f3a6c2a37b5ba4b5f42065f93cda5ed5e5fb60419bb81:"
319 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n"
320 "ETag: "
321 "W/"
322 "\"304402206f29b656ee23aafc7b6df4cfaa3bf711018cca2cbdbcb366932ae4433286f1"
323 "f6022061ddbd4a6ea0d5d36b9f3a6c2a37b5ba4b5f42065f93cda5ed5e5fb60419bb81:"
324 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"\n"));
325 fetcher->delegate()->OnURLFetchComplete(fetcher);
326
327 EXPECT_TRUE(tracker_->GetNetworkTime(&out_network_time, nullptr));
328 EXPECT_EQ(base::Time::UnixEpoch() +
329 base::TimeDelta::FromMilliseconds(1458939575214),
330 out_network_time);
331 EXPECT_TRUE(tracker_->query_timer_.IsRunning());
332 }
333
334 TEST_F(NetworkTimeTrackerTest, NoNetworkQueryWhileSynced) {
335 base::Time in_network_time = clock_->Now();
336 UpdateNetworkTime(in_network_time, resolution_, latency_,
337 tick_clock_->NowTicks());
338
339 tracker_->QueryTimeService();
340 net::TestURLFetcher* fetcher = url_fetcher_factory_->GetFetcherByID(0);
341 EXPECT_EQ(nullptr, fetcher); // No query should be started.
342 }
343
344 TEST_F(NetworkTimeTrackerTest, UpdateFromNetworkBadSignature) {
345 base::Time out_network_time;
346 EXPECT_EQ(nullptr, url_fetcher_factory_->GetFetcherByID(0));
347 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
348
349 tracker_->QueryTimeService();
350 net::TestURLFetcher* fetcher = url_fetcher_factory_->GetFetcherByID(0);
351 ASSERT_NE(nullptr, fetcher);
352 EXPECT_EQ("", fetcher->upload_data());
353
354 fetcher->set_response_code(200);
355 fetcher->SetResponseString(
356 "{\"current_time_millis\":1458939575214,\"server_nonce\":8."
357 "18927404567873E115}");
358 fetcher->set_response_headers(new net::HttpResponseHeaders(
359 "x-cup-server-proof: "
360 "304402206f29b656ee23aafc7b6df4cfaa3bf711018cca2cbdbcb366932ae4433286f1f6"
361 "022061ddbd4a6ea0d5d36b9f3a6c2a37b5ba4b5f42065f93cda5ed5e5fb60419bb81:"
362 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n"
363 "ETag: "
364 "W/"
365 "\"304402206f29b656ee23aafc7b6df4cfaa3bf711018cca2cbdbcb366932ae4433286f1"
366 "f6022061ddbd4a6ea0d5d36b9f3a6c2a37b5ba4b5f42065f93cda5ed5e5fb60419bb81:"
367 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"\n"));
368 fetcher->delegate()->OnURLFetchComplete(fetcher);
369
370 EXPECT_FALSE(tracker_->GetNetworkTime(&out_network_time, nullptr));
371 EXPECT_TRUE(tracker_->query_timer_.IsRunning());
292 } 372 }
293 373
294 } // namespace network_time 374 } // namespace network_time
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698