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

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

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/polling_proxy_config_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/network_delegate.h" 10 #include "net/base/network_delegate.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } // namespace 58 } // namespace
59 59
60 // Check that the OnPACScriptError method can be called from an arbitrary 60 // Check that the OnPACScriptError method can be called from an arbitrary
61 // thread. 61 // thread.
62 TEST(NetworkDelegateErrorObserverTest, CallOnThread) { 62 TEST(NetworkDelegateErrorObserverTest, CallOnThread) {
63 base::Thread thread("test_thread"); 63 base::Thread thread("test_thread");
64 thread.Start(); 64 thread.Start();
65 TestNetworkDelegate network_delegate; 65 TestNetworkDelegate network_delegate;
66 NetworkDelegateErrorObserver 66 NetworkDelegateErrorObserver
67 observer(&network_delegate, 67 observer(&network_delegate,
68 base::MessageLoopProxy::CreateForCurrentThread()); 68 base::MessageLoopProxy::current());
69 thread.message_loop()->PostTask( 69 thread.message_loop()->PostTask(
70 FROM_HERE, 70 FROM_HERE,
71 NewRunnableMethod(&observer, 71 NewRunnableMethod(&observer,
72 &NetworkDelegateErrorObserver::OnPACScriptError, 72 &NetworkDelegateErrorObserver::OnPACScriptError,
73 42, string16())); 73 42, string16()));
74 thread.Stop(); 74 thread.Stop();
75 MessageLoop::current()->RunAllPending(); 75 MessageLoop::current()->RunAllPending();
76 ASSERT_TRUE(network_delegate.got_pac_error()); 76 ASSERT_TRUE(network_delegate.got_pac_error());
77 } 77 }
78 78
79 // Check that passing a NULL network delegate works. 79 // Check that passing a NULL network delegate works.
80 TEST(NetworkDelegateErrorObserverTest, NoDelegate) { 80 TEST(NetworkDelegateErrorObserverTest, NoDelegate) {
81 base::Thread thread("test_thread"); 81 base::Thread thread("test_thread");
82 thread.Start(); 82 thread.Start();
83 NetworkDelegateErrorObserver 83 NetworkDelegateErrorObserver
84 observer(NULL, base::MessageLoopProxy::CreateForCurrentThread()); 84 observer(NULL, base::MessageLoopProxy::current());
85 thread.message_loop()->PostTask( 85 thread.message_loop()->PostTask(
86 FROM_HERE, 86 FROM_HERE,
87 NewRunnableMethod(&observer, 87 NewRunnableMethod(&observer,
88 &NetworkDelegateErrorObserver::OnPACScriptError, 88 &NetworkDelegateErrorObserver::OnPACScriptError,
89 42, string16())); 89 42, string16()));
90 thread.Stop(); 90 thread.Stop();
91 MessageLoop::current()->RunAllPending(); 91 MessageLoop::current()->RunAllPending();
92 // Shouldn't have crashed until here... 92 // Shouldn't have crashed until here...
93 } 93 }
94 94
95 } // namespace net 95 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/polling_proxy_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698