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

Side by Side Diff: net/proxy/network_delegate_error_observer_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/network_delegate_error_observer.h" 5 #include "net/proxy/network_delegate_error_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
14 #include "net/base/network_delegate_impl.h" 15 #include "net/base/network_delegate_impl.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 namespace { 20 namespace {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 TEST(NetworkDelegateErrorObserverTest, CallOnThread) { 85 TEST(NetworkDelegateErrorObserverTest, CallOnThread) {
85 base::Thread thread("test_thread"); 86 base::Thread thread("test_thread");
86 thread.Start(); 87 thread.Start();
87 TestNetworkDelegate network_delegate; 88 TestNetworkDelegate network_delegate;
88 NetworkDelegateErrorObserver observer( 89 NetworkDelegateErrorObserver observer(
89 &network_delegate, base::ThreadTaskRunnerHandle::Get().get()); 90 &network_delegate, base::ThreadTaskRunnerHandle::Get().get());
90 thread.task_runner()->PostTask( 91 thread.task_runner()->PostTask(
91 FROM_HERE, base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, 92 FROM_HERE, base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
92 base::Unretained(&observer), 42, base::string16())); 93 base::Unretained(&observer), 42, base::string16()));
93 thread.Stop(); 94 thread.Stop();
94 base::MessageLoop::current()->RunUntilIdle(); 95 base::RunLoop().RunUntilIdle();
95 ASSERT_TRUE(network_delegate.got_pac_error()); 96 ASSERT_TRUE(network_delegate.got_pac_error());
96 } 97 }
97 98
98 // Check that passing a NULL network delegate works. 99 // Check that passing a NULL network delegate works.
99 TEST(NetworkDelegateErrorObserverTest, NoDelegate) { 100 TEST(NetworkDelegateErrorObserverTest, NoDelegate) {
100 base::Thread thread("test_thread"); 101 base::Thread thread("test_thread");
101 thread.Start(); 102 thread.Start();
102 NetworkDelegateErrorObserver observer( 103 NetworkDelegateErrorObserver observer(
103 NULL, base::ThreadTaskRunnerHandle::Get().get()); 104 NULL, base::ThreadTaskRunnerHandle::Get().get());
104 thread.task_runner()->PostTask( 105 thread.task_runner()->PostTask(
105 FROM_HERE, base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, 106 FROM_HERE, base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
106 base::Unretained(&observer), 42, base::string16())); 107 base::Unretained(&observer), 42, base::string16()));
107 thread.Stop(); 108 thread.Stop();
108 base::MessageLoop::current()->RunUntilIdle(); 109 base::RunLoop().RunUntilIdle();
109 // Shouldn't have crashed until here... 110 // Shouldn't have crashed until here...
110 } 111 }
111 112
112 } // namespace 113 } // namespace
113 114
114 } // namespace net 115 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver_unittest.cc ('k') | net/proxy/proxy_config_service_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698