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

Side by Side Diff: content/browser/resolve_proxy_msg_helper_unittest.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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) 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 "content/browser/resolve_proxy_msg_helper.h" 5 #include "content/browser/resolve_proxy_msg_helper.h"
6 6
7 #include "content/browser/browser_thread_impl.h" 7 #include "content/browser/browser_thread_impl.h"
8 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
9 #include "ipc/ipc_test_sink.h" 9 #include "ipc/ipc_test_sink.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 23 matching lines...) Expand all
34 const std::string& proxy_list) 34 const std::string& proxy_list)
35 : result(result), proxy_list(proxy_list) { 35 : result(result), proxy_list(proxy_list) {
36 } 36 }
37 37
38 bool result; 38 bool result;
39 std::string proxy_list; 39 std::string proxy_list;
40 }; 40 };
41 41
42 ResolveProxyMsgHelperTest() 42 ResolveProxyMsgHelperTest()
43 : resolver_(new net::MockAsyncProxyResolver), 43 : resolver_(new net::MockAsyncProxyResolver),
44 service_(new net::ProxyService( 44 service_(
45 new MockProxyConfigService, resolver_, NULL)), 45 new net::ProxyService(new MockProxyConfigService, resolver_, NULL)),
46 helper_(new ResolveProxyMsgHelper(service_.get())), 46 helper_(new ResolveProxyMsgHelper(service_.get())),
47 message_loop_(MessageLoop::TYPE_IO), 47 message_loop_(base::MessageLoop::TYPE_IO),
48 io_thread_(BrowserThread::IO, &message_loop_) { 48 io_thread_(BrowserThread::IO, &message_loop_) {
49 test_sink_.AddFilter(this); 49 test_sink_.AddFilter(this);
50 helper_->OnFilterAdded(&test_sink_); 50 helper_->OnFilterAdded(&test_sink_);
51 } 51 }
52 52
53 protected: 53 protected:
54 const PendingResult* pending_result() const { return pending_result_.get(); } 54 const PendingResult* pending_result() const { return pending_result_.get(); }
55 55
56 void clear_pending_result() { 56 void clear_pending_result() {
57 pending_result_.reset(); 57 pending_result_.reset();
(...skipping 14 matching lines...) Expand all
72 private: 72 private:
73 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { 73 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE {
74 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data; 74 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data;
75 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); 75 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data));
76 DCHECK(!pending_result_.get()); 76 DCHECK(!pending_result_.get());
77 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b)); 77 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b));
78 test_sink_.ClearMessages(); 78 test_sink_.ClearMessages();
79 return true; 79 return true;
80 } 80 }
81 81
82 MessageLoop message_loop_; 82 base::MessageLoop message_loop_;
83 BrowserThreadImpl io_thread_; 83 BrowserThreadImpl io_thread_;
84 IPC::TestSink test_sink_; 84 IPC::TestSink test_sink_;
85 }; 85 };
86 86
87 // Issue three sequential requests -- each should succeed. 87 // Issue three sequential requests -- each should succeed.
88 TEST_F(ResolveProxyMsgHelperTest, Sequential) { 88 TEST_F(ResolveProxyMsgHelperTest, Sequential) {
89 GURL url1("http://www.google1.com/"); 89 GURL url1("http://www.google1.com/");
90 GURL url2("http://www.google2.com/"); 90 GURL url2("http://www.google2.com/");
91 GURL url3("http://www.google3.com/"); 91 GURL url3("http://www.google3.com/");
92 92
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 EXPECT_EQ(0u, resolver_->pending_requests().size()); 231 EXPECT_EQ(0u, resolver_->pending_requests().size());
232 232
233 EXPECT_TRUE(pending_result() == NULL); 233 EXPECT_TRUE(pending_result() == NULL);
234 234
235 // It should also be the case that msg1, msg2, msg3 were deleted by the 235 // It should also be the case that msg1, msg2, msg3 were deleted by the
236 // cancellation. (Else will show up as a leak in Valgrind). 236 // cancellation. (Else will show up as a leak in Valgrind).
237 } 237 }
238 238
239 } // namespace content 239 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/text_input_client_mac_unittest.mm ('k') | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698