OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/net/http_server_properties_manager.h" | 5 #include "chrome/browser/net/http_server_properties_manager.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 HttpServerPropertiesManagerTest() | 81 HttpServerPropertiesManagerTest() |
82 : ui_thread_(BrowserThread::UI, &loop_), | 82 : ui_thread_(BrowserThread::UI, &loop_), |
83 io_thread_(BrowserThread::IO, &loop_) { | 83 io_thread_(BrowserThread::IO, &loop_) { |
84 } | 84 } |
85 | 85 |
86 virtual void SetUp() OVERRIDE { | 86 virtual void SetUp() OVERRIDE { |
87 pref_service_.RegisterDictionaryPref(prefs::kHttpServerProperties); | 87 pref_service_.RegisterDictionaryPref(prefs::kHttpServerProperties); |
88 http_server_props_manager_.reset( | 88 http_server_props_manager_.reset( |
89 new StrictMock<TestingHttpServerPropertiesManager>(&pref_service_)); | 89 new StrictMock<TestingHttpServerPropertiesManager>(&pref_service_)); |
90 ExpectCacheUpdate(); | 90 ExpectCacheUpdate(); |
91 loop_.RunAllPending(); | 91 loop_.RunUntilIdle(); |
92 } | 92 } |
93 | 93 |
94 virtual void TearDown() OVERRIDE { | 94 virtual void TearDown() OVERRIDE { |
95 if (http_server_props_manager_.get()) | 95 if (http_server_props_manager_.get()) |
96 http_server_props_manager_->ShutdownOnUIThread(); | 96 http_server_props_manager_->ShutdownOnUIThread(); |
97 loop_.RunAllPending(); | 97 loop_.RunUntilIdle(); |
98 // Delete |http_server_props_manager_| while |io_thread_| is mapping IO to | 98 // Delete |http_server_props_manager_| while |io_thread_| is mapping IO to |
99 // |loop_|. | 99 // |loop_|. |
100 http_server_props_manager_.reset(); | 100 http_server_props_manager_.reset(); |
101 } | 101 } |
102 | 102 |
103 void ExpectCacheUpdate() { | 103 void ExpectCacheUpdate() { |
104 EXPECT_CALL(*http_server_props_manager_, UpdateCacheFromPrefsOnUI()) | 104 EXPECT_CALL(*http_server_props_manager_, UpdateCacheFromPrefsOnUI()) |
105 .WillOnce( | 105 .WillOnce( |
106 Invoke(http_server_props_manager_.get(), | 106 Invoke(http_server_props_manager_.get(), |
107 &TestingHttpServerPropertiesManager:: | 107 &TestingHttpServerPropertiesManager:: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 "mail.google.com:80", server_pref_dict1); | 177 "mail.google.com:80", server_pref_dict1); |
178 | 178 |
179 // Set the same value for kHttpServerProperties multiple times. | 179 // Set the same value for kHttpServerProperties multiple times. |
180 pref_service_.SetManagedPref(prefs::kHttpServerProperties, | 180 pref_service_.SetManagedPref(prefs::kHttpServerProperties, |
181 http_server_properties_dict); | 181 http_server_properties_dict); |
182 base::DictionaryValue* http_server_properties_dict2 = | 182 base::DictionaryValue* http_server_properties_dict2 = |
183 http_server_properties_dict->DeepCopy(); | 183 http_server_properties_dict->DeepCopy(); |
184 pref_service_.SetManagedPref(prefs::kHttpServerProperties, | 184 pref_service_.SetManagedPref(prefs::kHttpServerProperties, |
185 http_server_properties_dict2); | 185 http_server_properties_dict2); |
186 | 186 |
187 loop_.RunAllPending(); | 187 loop_.RunUntilIdle(); |
188 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 188 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
189 | 189 |
190 // Verify SupportsSpdy. | 190 // Verify SupportsSpdy. |
191 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 191 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
192 net::HostPortPair::FromString("www.google.com:80"))); | 192 net::HostPortPair::FromString("www.google.com:80"))); |
193 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 193 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
194 net::HostPortPair::FromString("mail.google.com:80"))); | 194 net::HostPortPair::FromString("mail.google.com:80"))); |
195 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( | 195 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( |
196 net::HostPortPair::FromString("foo.google.com:1337"))); | 196 net::HostPortPair::FromString("foo.google.com:1337"))); |
197 | 197 |
(...skipping 27 matching lines...) Expand all Loading... |
225 | 225 |
226 // Post an update task to the IO thread. SetSupportsSpdy calls | 226 // Post an update task to the IO thread. SetSupportsSpdy calls |
227 // ScheduleUpdatePrefsOnIO. | 227 // ScheduleUpdatePrefsOnIO. |
228 | 228 |
229 // Add mail.google.com:443 as a supporting spdy server. | 229 // Add mail.google.com:443 as a supporting spdy server. |
230 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 230 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
231 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 231 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
232 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 232 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
233 | 233 |
234 // Run the task. | 234 // Run the task. |
235 loop_.RunAllPending(); | 235 loop_.RunUntilIdle(); |
236 | 236 |
237 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 237 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
238 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 238 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
239 } | 239 } |
240 | 240 |
241 TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) { | 241 TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) { |
242 ExpectPrefsUpdate(); | 242 ExpectPrefsUpdate(); |
243 | 243 |
244 // Add SpdySetting for mail.google.com:443. | 244 // Add SpdySetting for mail.google.com:443. |
245 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 245 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
246 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 246 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
247 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 247 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
248 const uint32 value1 = 31337; | 248 const uint32 value1 = 31337; |
249 http_server_props_manager_->SetSpdySetting( | 249 http_server_props_manager_->SetSpdySetting( |
250 spdy_server_mail, id1, flags1, value1); | 250 spdy_server_mail, id1, flags1, value1); |
251 | 251 |
252 // Run the task. | 252 // Run the task. |
253 loop_.RunAllPending(); | 253 loop_.RunUntilIdle(); |
254 | 254 |
255 const net::SettingsMap& settings_map1_ret = | 255 const net::SettingsMap& settings_map1_ret = |
256 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 256 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
257 ASSERT_EQ(1U, settings_map1_ret.size()); | 257 ASSERT_EQ(1U, settings_map1_ret.size()); |
258 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 258 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
259 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); | 259 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); |
260 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; | 260 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; |
261 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 261 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
262 EXPECT_EQ(value1, flags_and_value1_ret.second); | 262 EXPECT_EQ(value1, flags_and_value1_ret.second); |
263 | 263 |
264 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 264 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
265 } | 265 } |
266 | 266 |
267 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { | 267 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { |
268 ExpectPrefsUpdate(); | 268 ExpectPrefsUpdate(); |
269 | 269 |
270 net::HostPortPair spdy_server_mail("mail.google.com", 80); | 270 net::HostPortPair spdy_server_mail("mail.google.com", 80); |
271 EXPECT_FALSE( | 271 EXPECT_FALSE( |
272 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 272 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
273 http_server_props_manager_->SetAlternateProtocol( | 273 http_server_props_manager_->SetAlternateProtocol( |
274 spdy_server_mail, 443, net::NPN_SPDY_2); | 274 spdy_server_mail, 443, net::NPN_SPDY_2); |
275 | 275 |
276 // Run the task. | 276 // Run the task. |
277 loop_.RunAllPending(); | 277 loop_.RunUntilIdle(); |
278 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 278 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
279 | 279 |
280 ASSERT_TRUE( | 280 ASSERT_TRUE( |
281 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 281 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
282 net::PortAlternateProtocolPair port_alternate_protocol = | 282 net::PortAlternateProtocolPair port_alternate_protocol = |
283 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); | 283 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); |
284 EXPECT_EQ(443, port_alternate_protocol.port); | 284 EXPECT_EQ(443, port_alternate_protocol.port); |
285 EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol); | 285 EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol); |
286 } | 286 } |
287 | 287 |
288 TEST_F(HttpServerPropertiesManagerTest, PipelineCapability) { | 288 TEST_F(HttpServerPropertiesManagerTest, PipelineCapability) { |
289 ExpectPrefsUpdate(); | 289 ExpectPrefsUpdate(); |
290 | 290 |
291 net::HostPortPair known_pipeliner("pipeline.com", 8080); | 291 net::HostPortPair known_pipeliner("pipeline.com", 8080); |
292 net::HostPortPair bad_pipeliner("wordpress.com", 80); | 292 net::HostPortPair bad_pipeliner("wordpress.com", 80); |
293 EXPECT_EQ(net::PIPELINE_UNKNOWN, | 293 EXPECT_EQ(net::PIPELINE_UNKNOWN, |
294 http_server_props_manager_->GetPipelineCapability(known_pipeliner)); | 294 http_server_props_manager_->GetPipelineCapability(known_pipeliner)); |
295 EXPECT_EQ(net::PIPELINE_UNKNOWN, | 295 EXPECT_EQ(net::PIPELINE_UNKNOWN, |
296 http_server_props_manager_->GetPipelineCapability(bad_pipeliner)); | 296 http_server_props_manager_->GetPipelineCapability(bad_pipeliner)); |
297 | 297 |
298 // Post an update task to the IO thread. SetPipelineCapability calls | 298 // Post an update task to the IO thread. SetPipelineCapability calls |
299 // ScheduleUpdatePrefsOnIO. | 299 // ScheduleUpdatePrefsOnIO. |
300 http_server_props_manager_->SetPipelineCapability(known_pipeliner, | 300 http_server_props_manager_->SetPipelineCapability(known_pipeliner, |
301 net::PIPELINE_CAPABLE); | 301 net::PIPELINE_CAPABLE); |
302 http_server_props_manager_->SetPipelineCapability(bad_pipeliner, | 302 http_server_props_manager_->SetPipelineCapability(bad_pipeliner, |
303 net::PIPELINE_INCAPABLE); | 303 net::PIPELINE_INCAPABLE); |
304 | 304 |
305 // Run the task. | 305 // Run the task. |
306 loop_.RunAllPending(); | 306 loop_.RunUntilIdle(); |
307 | 307 |
308 EXPECT_EQ(net::PIPELINE_CAPABLE, | 308 EXPECT_EQ(net::PIPELINE_CAPABLE, |
309 http_server_props_manager_->GetPipelineCapability(known_pipeliner)); | 309 http_server_props_manager_->GetPipelineCapability(known_pipeliner)); |
310 EXPECT_EQ(net::PIPELINE_INCAPABLE, | 310 EXPECT_EQ(net::PIPELINE_INCAPABLE, |
311 http_server_props_manager_->GetPipelineCapability(bad_pipeliner)); | 311 http_server_props_manager_->GetPipelineCapability(bad_pipeliner)); |
312 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 312 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
313 } | 313 } |
314 | 314 |
315 TEST_F(HttpServerPropertiesManagerTest, Clear) { | 315 TEST_F(HttpServerPropertiesManagerTest, Clear) { |
316 ExpectPrefsUpdate(); | 316 ExpectPrefsUpdate(); |
317 | 317 |
318 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 318 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
319 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 319 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
320 http_server_props_manager_->SetAlternateProtocol( | 320 http_server_props_manager_->SetAlternateProtocol( |
321 spdy_server_mail, 443, net::NPN_SPDY_2); | 321 spdy_server_mail, 443, net::NPN_SPDY_2); |
322 | 322 |
323 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 323 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
324 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 324 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
325 const uint32 value1 = 31337; | 325 const uint32 value1 = 31337; |
326 http_server_props_manager_->SetSpdySetting( | 326 http_server_props_manager_->SetSpdySetting( |
327 spdy_server_mail, id1, flags1, value1); | 327 spdy_server_mail, id1, flags1, value1); |
328 | 328 |
329 net::HostPortPair known_pipeliner("pipeline.com", 8080); | 329 net::HostPortPair known_pipeliner("pipeline.com", 8080); |
330 http_server_props_manager_->SetPipelineCapability(known_pipeliner, | 330 http_server_props_manager_->SetPipelineCapability(known_pipeliner, |
331 net::PIPELINE_CAPABLE); | 331 net::PIPELINE_CAPABLE); |
332 | 332 |
333 // Run the task. | 333 // Run the task. |
334 loop_.RunAllPending(); | 334 loop_.RunUntilIdle(); |
335 | 335 |
336 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 336 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
337 EXPECT_TRUE( | 337 EXPECT_TRUE( |
338 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 338 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
339 | 339 |
340 // Check SPDY settings values. | 340 // Check SPDY settings values. |
341 const net::SettingsMap& settings_map1_ret = | 341 const net::SettingsMap& settings_map1_ret = |
342 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 342 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
343 ASSERT_EQ(1U, settings_map1_ret.size()); | 343 ASSERT_EQ(1U, settings_map1_ret.size()); |
344 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 344 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
(...skipping 27 matching lines...) Expand all Loading... |
372 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 372 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
373 } | 373 } |
374 | 374 |
375 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) { | 375 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) { |
376 // Post an update task to the UI thread. | 376 // Post an update task to the UI thread. |
377 http_server_props_manager_->ScheduleUpdateCacheOnUI(); | 377 http_server_props_manager_->ScheduleUpdateCacheOnUI(); |
378 // Shutdown comes before the task is executed. | 378 // Shutdown comes before the task is executed. |
379 http_server_props_manager_->ShutdownOnUIThread(); | 379 http_server_props_manager_->ShutdownOnUIThread(); |
380 http_server_props_manager_.reset(); | 380 http_server_props_manager_.reset(); |
381 // Run the task after shutdown and deletion. | 381 // Run the task after shutdown and deletion. |
382 loop_.RunAllPending(); | 382 loop_.RunUntilIdle(); |
383 } | 383 } |
384 | 384 |
385 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) { | 385 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) { |
386 // Post an update task. | 386 // Post an update task. |
387 http_server_props_manager_->ScheduleUpdateCacheOnUI(); | 387 http_server_props_manager_->ScheduleUpdateCacheOnUI(); |
388 // Shutdown comes before the task is executed. | 388 // Shutdown comes before the task is executed. |
389 http_server_props_manager_->ShutdownOnUIThread(); | 389 http_server_props_manager_->ShutdownOnUIThread(); |
390 // Run the task after shutdown, but before deletion. | 390 // Run the task after shutdown, but before deletion. |
391 loop_.RunAllPending(); | 391 loop_.RunUntilIdle(); |
392 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 392 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
393 http_server_props_manager_.reset(); | 393 http_server_props_manager_.reset(); |
394 loop_.RunAllPending(); | 394 loop_.RunUntilIdle(); |
395 } | 395 } |
396 | 396 |
397 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) { | 397 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) { |
398 http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete(); | 398 http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete(); |
399 // Shutdown comes before the task is executed. | 399 // Shutdown comes before the task is executed. |
400 http_server_props_manager_->ShutdownOnUIThread(); | 400 http_server_props_manager_->ShutdownOnUIThread(); |
401 // Run the task after shutdown, but before deletion. | 401 // Run the task after shutdown, but before deletion. |
402 loop_.RunAllPending(); | 402 loop_.RunUntilIdle(); |
403 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 403 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
404 http_server_props_manager_.reset(); | 404 http_server_props_manager_.reset(); |
405 loop_.RunAllPending(); | 405 loop_.RunUntilIdle(); |
406 } | 406 } |
407 | 407 |
408 // | 408 // |
409 // Tests for shutdown when updating prefs. | 409 // Tests for shutdown when updating prefs. |
410 // | 410 // |
411 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { | 411 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { |
412 // Post an update task to the IO thread. | 412 // Post an update task to the IO thread. |
413 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); | 413 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); |
414 // Shutdown comes before the task is executed. | 414 // Shutdown comes before the task is executed. |
415 http_server_props_manager_->ShutdownOnUIThread(); | 415 http_server_props_manager_->ShutdownOnUIThread(); |
416 http_server_props_manager_.reset(); | 416 http_server_props_manager_.reset(); |
417 // Run the task after shutdown and deletion. | 417 // Run the task after shutdown and deletion. |
418 loop_.RunAllPending(); | 418 loop_.RunUntilIdle(); |
419 } | 419 } |
420 | 420 |
421 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { | 421 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { |
422 ExpectPrefsUpdate(); | 422 ExpectPrefsUpdate(); |
423 // Post an update task. | 423 // Post an update task. |
424 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); | 424 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); |
425 // Shutdown comes before the task is executed. | 425 // Shutdown comes before the task is executed. |
426 http_server_props_manager_->ShutdownOnUIThread(); | 426 http_server_props_manager_->ShutdownOnUIThread(); |
427 // Run the task after shutdown, but before deletion. | 427 // Run the task after shutdown, but before deletion. |
428 loop_.RunAllPending(); | 428 loop_.RunUntilIdle(); |
429 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 429 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
430 http_server_props_manager_.reset(); | 430 http_server_props_manager_.reset(); |
431 loop_.RunAllPending(); | 431 loop_.RunUntilIdle(); |
432 } | 432 } |
433 | 433 |
434 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { | 434 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { |
435 // This posts a task to the UI thread. | 435 // This posts a task to the UI thread. |
436 http_server_props_manager_->UpdatePrefsFromCacheOnIOConcrete(base::Closure()); | 436 http_server_props_manager_->UpdatePrefsFromCacheOnIOConcrete(base::Closure()); |
437 // Shutdown comes before the task is executed. | 437 // Shutdown comes before the task is executed. |
438 http_server_props_manager_->ShutdownOnUIThread(); | 438 http_server_props_manager_->ShutdownOnUIThread(); |
439 // Run the task after shutdown, but before deletion. | 439 // Run the task after shutdown, but before deletion. |
440 loop_.RunAllPending(); | 440 loop_.RunUntilIdle(); |
441 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 441 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
442 http_server_props_manager_.reset(); | 442 http_server_props_manager_.reset(); |
443 loop_.RunAllPending(); | 443 loop_.RunUntilIdle(); |
444 } | 444 } |
445 | 445 |
446 } // namespace | 446 } // namespace |
447 | 447 |
448 } // namespace chrome_browser_net | 448 } // namespace chrome_browser_net |
OLD | NEW |