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

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver_unittest.cc

Issue 2053133002: Remove MessageLoop::current()->RunUntilIdle() in net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 (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 "net/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // interesting case to test. 495 // interesting case to test.
496 factory().resolvers()[0]->SetResolveLatency( 496 factory().resolvers()[0]->SetResolveLatency(
497 base::TimeDelta::FromMilliseconds(100)); 497 base::TimeDelta::FromMilliseconds(100));
498 498
499 // Unblock the worker thread and delete the underlying 499 // Unblock the worker thread and delete the underlying
500 // MultiThreadedProxyResolver immediately. 500 // MultiThreadedProxyResolver immediately.
501 factory().resolvers()[0]->Unblock(); 501 factory().resolvers()[0]->Unblock();
502 ClearResolver(); 502 ClearResolver();
503 503
504 // Give any posted tasks a chance to run (in case there is badness). 504 // Give any posted tasks a chance to run (in case there is badness).
505 base::MessageLoop::current()->RunUntilIdle(); 505 base::RunLoop().RunUntilIdle();
506 506
507 // Check that none of the outstanding requests were completed. 507 // Check that none of the outstanding requests were completed.
508 EXPECT_FALSE(callback0.have_result()); 508 EXPECT_FALSE(callback0.have_result());
509 EXPECT_FALSE(callback1.have_result()); 509 EXPECT_FALSE(callback1.have_result());
510 EXPECT_FALSE(callback2.have_result()); 510 EXPECT_FALSE(callback2.have_result());
511 } 511 }
512 512
513 // Tests setting the PAC script once, lazily creating new threads, and 513 // Tests setting the PAC script once, lazily creating new threads, and
514 // cancelling requests. 514 // cancelling requests.
515 TEST_F(MultiThreadedProxyResolverTest, ThreeThreads_Basic) { 515 TEST_F(MultiThreadedProxyResolverTest, ThreeThreads_Basic) {
(...skipping 17 matching lines...) Expand all
533 BoundNetLog()); 533 BoundNetLog());
534 EXPECT_EQ(ERR_IO_PENDING, rv); 534 EXPECT_EQ(ERR_IO_PENDING, rv);
535 535
536 // Wait for request 0 to finish. 536 // Wait for request 0 to finish.
537 rv = callback[0].WaitForResult(); 537 rv = callback[0].WaitForResult();
538 EXPECT_EQ(0, rv); 538 EXPECT_EQ(0, rv);
539 EXPECT_EQ("PROXY request0:80", results[0].ToPacString()); 539 EXPECT_EQ("PROXY request0:80", results[0].ToPacString());
540 ASSERT_EQ(1u, factory().resolvers().size()); 540 ASSERT_EQ(1u, factory().resolvers().size());
541 EXPECT_EQ(1, factory().resolvers()[0]->request_count()); 541 EXPECT_EQ(1, factory().resolvers()[0]->request_count());
542 542
543 base::MessageLoop::current()->RunUntilIdle(); 543 base::RunLoop().RunUntilIdle();
544 544
545 // We now block the first resolver to ensure a request is sent to the second 545 // We now block the first resolver to ensure a request is sent to the second
546 // thread. 546 // thread.
547 factory().resolvers()[0]->Block(); 547 factory().resolvers()[0]->Block();
548 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1], 548 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1],
549 callback[1].callback(), &request[1], 549 callback[1].callback(), &request[1],
550 BoundNetLog()); 550 BoundNetLog());
551 EXPECT_EQ(ERR_IO_PENDING, rv); 551 EXPECT_EQ(ERR_IO_PENDING, rv);
552 factory().resolvers()[0]->WaitUntilBlocked(); 552 factory().resolvers()[0]->WaitUntilBlocked();
553 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2], 553 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2],
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 774 }
775 // The factory destructor will block until the worker thread stops, but it may 775 // The factory destructor will block until the worker thread stops, but it may
776 // post tasks to the origin message loop which are still pending. Run them 776 // post tasks to the origin message loop which are still pending. Run them
777 // now to ensure it works as expected. 777 // now to ensure it works as expected.
778 base::RunLoop().RunUntilIdle(); 778 base::RunLoop().RunUntilIdle();
779 } 779 }
780 780
781 } // namespace 781 } // namespace
782 782
783 } // namespace net 783 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc ('k') | net/proxy/network_delegate_error_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698