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

Side by Side Diff: chrome/browser/net/resolve_proxy_msg_helper_unittest.cc

Issue 1052002: Move over another legacy "LoadLog-style" event generator to routing its messa... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address willchan's comments Created 10 years, 9 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/resolve_proxy_msg_helper.h" 5 #include "chrome/browser/net/resolve_proxy_msg_helper.h"
6 6
7 #include "base/waitable_event.h" 7 #include "base/waitable_event.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/proxy/mock_proxy_resolver.h" 9 #include "net/proxy/mock_proxy_resolver.h"
10 #include "net/proxy/proxy_config_service.h" 10 #include "net/proxy/proxy_config_service.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 private: 50 private:
51 scoped_ptr<PendingResult> pending_result_; 51 scoped_ptr<PendingResult> pending_result_;
52 }; 52 };
53 53
54 // Issue three sequential requests -- each should succeed. 54 // Issue three sequential requests -- each should succeed.
55 TEST(ResolveProxyMsgHelperTest, Sequential) { 55 TEST(ResolveProxyMsgHelperTest, Sequential) {
56 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver; 56 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
57 scoped_refptr<net::ProxyService> service( 57 scoped_refptr<net::ProxyService> service(
58 new net::ProxyService(new MockProxyConfigService, resolver, NULL)); 58 new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
59 59
60 MyDelegate delegate; 60 MyDelegate delegate;
61 ResolveProxyMsgHelper helper(&delegate, service); 61 ResolveProxyMsgHelper helper(&delegate, service);
62 62
63 GURL url1("http://www.google1.com/"); 63 GURL url1("http://www.google1.com/");
64 GURL url2("http://www.google2.com/"); 64 GURL url2("http://www.google2.com/");
65 GURL url3("http://www.google3.com/"); 65 GURL url3("http://www.google3.com/");
66 66
67 scoped_ptr<IPC::Message> msg1(new IPC::Message()); 67 scoped_ptr<IPC::Message> msg1(new IPC::Message());
68 scoped_ptr<IPC::Message> msg2(new IPC::Message()); 68 scoped_ptr<IPC::Message> msg2(new IPC::Message());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 EXPECT_EQ(msg3.get(), delegate.pending_result()->msg); 111 EXPECT_EQ(msg3.get(), delegate.pending_result()->msg);
112 EXPECT_EQ(net::OK, delegate.pending_result()->error_code); 112 EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
113 EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list); 113 EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list);
114 delegate.clear_pending_result(); 114 delegate.clear_pending_result();
115 } 115 }
116 116
117 // Issue a request while one is already in progress -- should be queued. 117 // Issue a request while one is already in progress -- should be queued.
118 TEST(ResolveProxyMsgHelperTest, QueueRequests) { 118 TEST(ResolveProxyMsgHelperTest, QueueRequests) {
119 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver; 119 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
120 scoped_refptr<net::ProxyService> service( 120 scoped_refptr<net::ProxyService> service(
121 new net::ProxyService(new MockProxyConfigService, resolver, NULL)); 121 new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
122 122
123 MyDelegate delegate; 123 MyDelegate delegate;
124 ResolveProxyMsgHelper helper(&delegate, service); 124 ResolveProxyMsgHelper helper(&delegate, service);
125 125
126 GURL url1("http://www.google1.com/"); 126 GURL url1("http://www.google1.com/");
127 GURL url2("http://www.google2.com/"); 127 GURL url2("http://www.google2.com/");
128 GURL url3("http://www.google3.com/"); 128 GURL url3("http://www.google3.com/");
129 129
130 scoped_ptr<IPC::Message> msg1(new IPC::Message()); 130 scoped_ptr<IPC::Message> msg1(new IPC::Message());
131 scoped_ptr<IPC::Message> msg2(new IPC::Message()); 131 scoped_ptr<IPC::Message> msg2(new IPC::Message());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 EXPECT_EQ(msg3.get(), delegate.pending_result()->msg); 178 EXPECT_EQ(msg3.get(), delegate.pending_result()->msg);
179 EXPECT_EQ(net::OK, delegate.pending_result()->error_code); 179 EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
180 EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list); 180 EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list);
181 delegate.clear_pending_result(); 181 delegate.clear_pending_result();
182 } 182 }
183 183
184 // Delete the helper while a request is in progress, and others are pending. 184 // Delete the helper while a request is in progress, and others are pending.
185 TEST(ResolveProxyMsgHelperTest, CancelPendingRequests) { 185 TEST(ResolveProxyMsgHelperTest, CancelPendingRequests) {
186 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver; 186 net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
187 scoped_refptr<net::ProxyService> service( 187 scoped_refptr<net::ProxyService> service(
188 new net::ProxyService(new MockProxyConfigService, resolver, NULL)); 188 new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
189 189
190 MyDelegate delegate; 190 MyDelegate delegate;
191 scoped_ptr<ResolveProxyMsgHelper> helper( 191 scoped_ptr<ResolveProxyMsgHelper> helper(
192 new ResolveProxyMsgHelper(&delegate, service)); 192 new ResolveProxyMsgHelper(&delegate, service));
193 193
194 GURL url1("http://www.google1.com/"); 194 GURL url1("http://www.google1.com/");
195 GURL url2("http://www.google2.com/"); 195 GURL url2("http://www.google2.com/");
196 GURL url3("http://www.google3.com/"); 196 GURL url3("http://www.google3.com/");
197 197
198 // NOTE: these are not scoped ptr, since they will be deleted by the 198 // NOTE: these are not scoped ptr, since they will be deleted by the
(...skipping 24 matching lines...) Expand all
223 223
224 // The pending requests sent to the proxy resolver should have been cancelled. 224 // The pending requests sent to the proxy resolver should have been cancelled.
225 225
226 EXPECT_EQ(0u, resolver->pending_requests().size()); 226 EXPECT_EQ(0u, resolver->pending_requests().size());
227 227
228 EXPECT_TRUE(delegate.pending_result() == NULL); 228 EXPECT_TRUE(delegate.pending_result() == NULL);
229 229
230 // It should also be the case that msg1, msg2, msg3 were deleted by the 230 // It should also be the case that msg1, msg2, msg3 were deleted by the
231 // cancellation. (Else will show up as a leak in Purify/Valgrind). 231 // cancellation. (Else will show up as a leak in Purify/Valgrind).
232 } 232 }
OLDNEW
« no previous file with comments | « chrome/browser/net/passive_log_collector.cc ('k') | chrome/browser/net/view_net_internals_job_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698