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

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

Issue 8985012: base::Bind: Convert net/proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more include. Created 9 years 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/network_delegate_error_observer.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/bind.h"
8 #include "base/bind_helpers.h"
7 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
8 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
9 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
10 #include "net/base/network_delegate.h" 12 #include "net/base/network_delegate.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::NetworkDelegateErrorObserver);
14
15 namespace net { 15 namespace net {
16 16
17 namespace { 17 namespace {
18 18
19 class TestNetworkDelegate : public net::NetworkDelegate { 19 class TestNetworkDelegate : public net::NetworkDelegate {
20 public: 20 public:
21 TestNetworkDelegate() : got_pac_error_(false) {} 21 TestNetworkDelegate() : got_pac_error_(false) {}
22 virtual ~TestNetworkDelegate() {} 22 virtual ~TestNetworkDelegate() {}
23 23
24 bool got_pac_error() const { return got_pac_error_; } 24 bool got_pac_error() const { return got_pac_error_; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // thread. 73 // thread.
74 TEST(NetworkDelegateErrorObserverTest, CallOnThread) { 74 TEST(NetworkDelegateErrorObserverTest, CallOnThread) {
75 base::Thread thread("test_thread"); 75 base::Thread thread("test_thread");
76 thread.Start(); 76 thread.Start();
77 TestNetworkDelegate network_delegate; 77 TestNetworkDelegate network_delegate;
78 NetworkDelegateErrorObserver 78 NetworkDelegateErrorObserver
79 observer(&network_delegate, 79 observer(&network_delegate,
80 base::MessageLoopProxy::current()); 80 base::MessageLoopProxy::current());
81 thread.message_loop()->PostTask( 81 thread.message_loop()->PostTask(
82 FROM_HERE, 82 FROM_HERE,
83 NewRunnableMethod(&observer, 83 base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
84 &NetworkDelegateErrorObserver::OnPACScriptError, 84 base::Unretained(&observer), 42, string16()));
85 42, string16()));
86 thread.Stop(); 85 thread.Stop();
87 MessageLoop::current()->RunAllPending(); 86 MessageLoop::current()->RunAllPending();
88 ASSERT_TRUE(network_delegate.got_pac_error()); 87 ASSERT_TRUE(network_delegate.got_pac_error());
89 } 88 }
90 89
91 // Check that passing a NULL network delegate works. 90 // Check that passing a NULL network delegate works.
92 TEST(NetworkDelegateErrorObserverTest, NoDelegate) { 91 TEST(NetworkDelegateErrorObserverTest, NoDelegate) {
93 base::Thread thread("test_thread"); 92 base::Thread thread("test_thread");
94 thread.Start(); 93 thread.Start();
95 NetworkDelegateErrorObserver 94 NetworkDelegateErrorObserver
96 observer(NULL, base::MessageLoopProxy::current()); 95 observer(NULL, base::MessageLoopProxy::current());
97 thread.message_loop()->PostTask( 96 thread.message_loop()->PostTask(
98 FROM_HERE, 97 FROM_HERE,
99 NewRunnableMethod(&observer, 98 base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
100 &NetworkDelegateErrorObserver::OnPACScriptError, 99 base::Unretained(&observer), 42, string16()));
101 42, string16()));
102 thread.Stop(); 100 thread.Stop();
103 MessageLoop::current()->RunAllPending(); 101 MessageLoop::current()->RunAllPending();
104 // Shouldn't have crashed until here... 102 // Shouldn't have crashed until here...
105 } 103 }
106 104
107 } // namespace net 105 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/network_delegate_error_observer.cc ('k') | net/proxy/polling_proxy_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698