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

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

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 "base/memory/ptr_util.h"
7 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
8 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
9 #include "ipc/ipc_test_sink.h" 10 #include "ipc/ipc_test_sink.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 #include "net/proxy/mock_proxy_resolver.h" 12 #include "net/proxy/mock_proxy_resolver.h"
12 #include "net/proxy/proxy_config_service.h" 13 #include "net/proxy/proxy_config_service.h"
13 #include "net/proxy/proxy_service.h" 14 #include "net/proxy/proxy_service.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace content { 17 namespace content {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 : result(result), proxy_list(proxy_list) { 54 : result(result), proxy_list(proxy_list) {
54 } 55 }
55 56
56 bool result; 57 bool result;
57 std::string proxy_list; 58 std::string proxy_list;
58 }; 59 };
59 60
60 ResolveProxyMsgHelperTest() 61 ResolveProxyMsgHelperTest()
61 : resolver_factory_(new net::MockAsyncProxyResolverFactory(false)), 62 : resolver_factory_(new net::MockAsyncProxyResolverFactory(false)),
62 service_( 63 service_(
63 new net::ProxyService(make_scoped_ptr(new MockProxyConfigService), 64 new net::ProxyService(base::WrapUnique(new MockProxyConfigService),
64 make_scoped_ptr(resolver_factory_), 65 base::WrapUnique(resolver_factory_),
65 NULL)), 66 NULL)),
66 helper_(new TestResolveProxyMsgHelper(service_.get(), this)), 67 helper_(new TestResolveProxyMsgHelper(service_.get(), this)),
67 io_thread_(BrowserThread::IO, &message_loop_) { 68 io_thread_(BrowserThread::IO, &message_loop_) {
68 test_sink_.AddFilter(this); 69 test_sink_.AddFilter(this);
69 } 70 }
70 71
71 protected: 72 protected:
72 const PendingResult* pending_result() const { return pending_result_.get(); } 73 const PendingResult* pending_result() const { return pending_result_.get(); }
73 74
74 void clear_pending_result() { 75 void clear_pending_result() {
75 pending_result_.reset(); 76 pending_result_.reset();
76 } 77 }
77 78
78 IPC::Message* GenerateReply() { 79 IPC::Message* GenerateReply() {
79 bool temp_bool; 80 bool temp_bool;
80 std::string temp_string; 81 std::string temp_string;
81 ViewHostMsg_ResolveProxy message(GURL(), &temp_bool, &temp_string); 82 ViewHostMsg_ResolveProxy message(GURL(), &temp_bool, &temp_string);
82 return IPC::SyncMessage::GenerateReply(&message); 83 return IPC::SyncMessage::GenerateReply(&message);
83 } 84 }
84 85
85 net::MockAsyncProxyResolverFactory* resolver_factory_; 86 net::MockAsyncProxyResolverFactory* resolver_factory_;
86 net::MockAsyncProxyResolver resolver_; 87 net::MockAsyncProxyResolver resolver_;
87 scoped_ptr<net::ProxyService> service_; 88 std::unique_ptr<net::ProxyService> service_;
88 scoped_refptr<ResolveProxyMsgHelper> helper_; 89 scoped_refptr<ResolveProxyMsgHelper> helper_;
89 scoped_ptr<PendingResult> pending_result_; 90 std::unique_ptr<PendingResult> pending_result_;
90 91
91 private: 92 private:
92 bool OnMessageReceived(const IPC::Message& msg) override { 93 bool OnMessageReceived(const IPC::Message& msg) override {
93 ViewHostMsg_ResolveProxy::ReplyParam reply_data; 94 ViewHostMsg_ResolveProxy::ReplyParam reply_data;
94 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); 95 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data));
95 DCHECK(!pending_result_.get()); 96 DCHECK(!pending_result_.get());
96 pending_result_.reset( 97 pending_result_.reset(
97 new PendingResult(base::get<0>(reply_data), base::get<1>(reply_data))); 98 new PendingResult(base::get<0>(reply_data), base::get<1>(reply_data)));
98 test_sink_.ClearMessages(); 99 test_sink_.ClearMessages();
99 return true; 100 return true;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 EXPECT_EQ(0u, resolver_.pending_requests().size()); 258 EXPECT_EQ(0u, resolver_.pending_requests().size());
258 259
259 EXPECT_TRUE(pending_result() == NULL); 260 EXPECT_TRUE(pending_result() == NULL);
260 261
261 // 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
262 // cancellation. (Else will show up as a leak in Valgrind). 263 // cancellation. (Else will show up as a leak in Valgrind).
263 } 264 }
264 265
265 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/quota_temporary_storage_evictor_unittest.cc ('k') | content/browser/resource_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698