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

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

Issue 2487073005: Remove direct usage of BrowserThreadImpl in tests (Closed)
Patch Set: The RDHImpl is actually not even necessary in ResourceSchedulerTest, removed. Created 4 years, 1 month 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
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 <tuple> 7 #include <tuple>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/browser_thread_impl.h"
11 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
11 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "ipc/ipc_test_sink.h" 12 #include "ipc/ipc_test_sink.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/proxy/mock_proxy_resolver.h" 14 #include "net/proxy/mock_proxy_resolver.h"
15 #include "net/proxy/proxy_config_service.h" 15 #include "net/proxy/proxy_config_service.h"
16 #include "net/proxy/proxy_service.h" 16 #include "net/proxy/proxy_service.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 // This ProxyConfigService always returns "http://pac" as the PAC url to use. 21 // This ProxyConfigService always returns "http://pac" as the PAC url to use.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 bool result; 59 bool result;
60 std::string proxy_list; 60 std::string proxy_list;
61 }; 61 };
62 62
63 ResolveProxyMsgHelperTest() 63 ResolveProxyMsgHelperTest()
64 : resolver_factory_(new net::MockAsyncProxyResolverFactory(false)), 64 : resolver_factory_(new net::MockAsyncProxyResolverFactory(false)),
65 service_( 65 service_(
66 new net::ProxyService(base::WrapUnique(new MockProxyConfigService), 66 new net::ProxyService(base::WrapUnique(new MockProxyConfigService),
67 base::WrapUnique(resolver_factory_), 67 base::WrapUnique(resolver_factory_),
68 NULL)), 68 NULL)),
69 helper_(new TestResolveProxyMsgHelper(service_.get(), this)), 69 helper_(new TestResolveProxyMsgHelper(service_.get(), this)) {
70 io_thread_(BrowserThread::IO, &message_loop_) {
71 test_sink_.AddFilter(this); 70 test_sink_.AddFilter(this);
72 } 71 }
73 72
74 protected: 73 protected:
75 const PendingResult* pending_result() const { return pending_result_.get(); } 74 const PendingResult* pending_result() const { return pending_result_.get(); }
76 75
77 void clear_pending_result() { 76 void clear_pending_result() {
78 pending_result_.reset(); 77 pending_result_.reset();
79 } 78 }
80 79
(...skipping 14 matching lines...) Expand all
95 bool OnMessageReceived(const IPC::Message& msg) override { 94 bool OnMessageReceived(const IPC::Message& msg) override {
96 ViewHostMsg_ResolveProxy::ReplyParam reply_data; 95 ViewHostMsg_ResolveProxy::ReplyParam reply_data;
97 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); 96 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data));
98 DCHECK(!pending_result_.get()); 97 DCHECK(!pending_result_.get());
99 pending_result_.reset( 98 pending_result_.reset(
100 new PendingResult(std::get<0>(reply_data), std::get<1>(reply_data))); 99 new PendingResult(std::get<0>(reply_data), std::get<1>(reply_data)));
101 test_sink_.ClearMessages(); 100 test_sink_.ClearMessages();
102 return true; 101 return true;
103 } 102 }
104 103
105 base::MessageLoopForIO message_loop_; 104 TestBrowserThreadBundle thread_bundle_;
106 BrowserThreadImpl io_thread_;
107 IPC::TestSink test_sink_; 105 IPC::TestSink test_sink_;
108 }; 106 };
109 107
110 // Issue three sequential requests -- each should succeed. 108 // Issue three sequential requests -- each should succeed.
111 TEST_F(ResolveProxyMsgHelperTest, Sequential) { 109 TEST_F(ResolveProxyMsgHelperTest, Sequential) {
112 GURL url1("http://www.google1.com/"); 110 GURL url1("http://www.google1.com/");
113 GURL url2("http://www.google2.com/"); 111 GURL url2("http://www.google2.com/");
114 GURL url3("http://www.google3.com/"); 112 GURL url3("http://www.google3.com/");
115 113
116 // Messages are deleted by the sink. 114 // Messages are deleted by the sink.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 257
260 EXPECT_EQ(0u, resolver_.pending_jobs().size()); 258 EXPECT_EQ(0u, resolver_.pending_jobs().size());
261 259
262 EXPECT_TRUE(pending_result() == NULL); 260 EXPECT_TRUE(pending_result() == NULL);
263 261
264 // It should also be the case that msg1, msg2, msg3 were deleted by the 262 // It should also be the case that msg1, msg2, msg3 were deleted by the
265 // cancellation. (Else will show up as a leak in Valgrind). 263 // cancellation. (Else will show up as a leak in Valgrind).
266 } 264 }
267 265
268 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | net/url_request/test_url_fetcher_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698