| OLD | NEW |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 bool result; | 57 bool result; |
| 58 std::string proxy_list; | 58 std::string proxy_list; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 ResolveProxyMsgHelperTest() | 61 ResolveProxyMsgHelperTest() |
| 62 : resolver_(new net::MockAsyncProxyResolver), | 62 : resolver_(new net::MockAsyncProxyResolver), |
| 63 service_( | 63 service_( |
| 64 new net::ProxyService(new MockProxyConfigService, resolver_, NULL)), | 64 new net::ProxyService(new MockProxyConfigService, resolver_, NULL)), |
| 65 helper_(new TestResolveProxyMsgHelper(service_.get(), this)), | 65 helper_(new TestResolveProxyMsgHelper(service_.get(), this)), |
| 66 message_loop_(base::MessageLoop::TYPE_IO), | |
| 67 io_thread_(BrowserThread::IO, &message_loop_) { | 66 io_thread_(BrowserThread::IO, &message_loop_) { |
| 68 test_sink_.AddFilter(this); | 67 test_sink_.AddFilter(this); |
| 69 } | 68 } |
| 70 | 69 |
| 71 protected: | 70 protected: |
| 72 const PendingResult* pending_result() const { return pending_result_.get(); } | 71 const PendingResult* pending_result() const { return pending_result_.get(); } |
| 73 | 72 |
| 74 void clear_pending_result() { | 73 void clear_pending_result() { |
| 75 pending_result_.reset(); | 74 pending_result_.reset(); |
| 76 } | 75 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 90 private: | 89 private: |
| 91 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 90 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { |
| 92 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data; | 91 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data; |
| 93 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); | 92 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); |
| 94 DCHECK(!pending_result_.get()); | 93 DCHECK(!pending_result_.get()); |
| 95 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b)); | 94 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b)); |
| 96 test_sink_.ClearMessages(); | 95 test_sink_.ClearMessages(); |
| 97 return true; | 96 return true; |
| 98 } | 97 } |
| 99 | 98 |
| 100 base::MessageLoop message_loop_; | 99 base::MessageLoopForIO message_loop_; |
| 101 BrowserThreadImpl io_thread_; | 100 BrowserThreadImpl io_thread_; |
| 102 IPC::TestSink test_sink_; | 101 IPC::TestSink test_sink_; |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 // Issue three sequential requests -- each should succeed. | 104 // Issue three sequential requests -- each should succeed. |
| 106 TEST_F(ResolveProxyMsgHelperTest, Sequential) { | 105 TEST_F(ResolveProxyMsgHelperTest, Sequential) { |
| 107 GURL url1("http://www.google1.com/"); | 106 GURL url1("http://www.google1.com/"); |
| 108 GURL url2("http://www.google2.com/"); | 107 GURL url2("http://www.google2.com/"); |
| 109 GURL url3("http://www.google3.com/"); | 108 GURL url3("http://www.google3.com/"); |
| 110 | 109 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 247 |
| 249 EXPECT_EQ(0u, resolver_->pending_requests().size()); | 248 EXPECT_EQ(0u, resolver_->pending_requests().size()); |
| 250 | 249 |
| 251 EXPECT_TRUE(pending_result() == NULL); | 250 EXPECT_TRUE(pending_result() == NULL); |
| 252 | 251 |
| 253 // It should also be the case that msg1, msg2, msg3 were deleted by the | 252 // It should also be the case that msg1, msg2, msg3 were deleted by the |
| 254 // cancellation. (Else will show up as a leak in Valgrind). | 253 // cancellation. (Else will show up as a leak in Valgrind). |
| 255 } | 254 } |
| 256 | 255 |
| 257 } // namespace content | 256 } // namespace content |
| OLD | NEW |