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

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

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "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"
11 #include "net/proxy/mock_proxy_resolver.h" 11 #include "net/proxy/mock_proxy_resolver.h"
12 #include "net/proxy/proxy_config_service.h" 12 #include "net/proxy/proxy_config_service.h"
13 #include "net/proxy/proxy_service.h" 13 #include "net/proxy/proxy_service.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // This ProxyConfigService always returns "http://pac" as the PAC url to use. 18 // This ProxyConfigService always returns "http://pac" as the PAC url to use.
19 class MockProxyConfigService : public net::ProxyConfigService { 19 class MockProxyConfigService : public net::ProxyConfigService {
20 public: 20 public:
21 virtual void AddObserver(Observer* observer) override {} 21 void AddObserver(Observer* observer) override {}
22 virtual void RemoveObserver(Observer* observer) override {} 22 void RemoveObserver(Observer* observer) override {}
23 virtual ConfigAvailability GetLatestProxyConfig( 23 ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* results) override {
24 net::ProxyConfig* results) override {
25 *results = net::ProxyConfig::CreateFromCustomPacURL(GURL("http://pac")); 24 *results = net::ProxyConfig::CreateFromCustomPacURL(GURL("http://pac"));
26 return CONFIG_VALID; 25 return CONFIG_VALID;
27 } 26 }
28 }; 27 };
29 28
30 class TestResolveProxyMsgHelper : public ResolveProxyMsgHelper { 29 class TestResolveProxyMsgHelper : public ResolveProxyMsgHelper {
31 public: 30 public:
32 TestResolveProxyMsgHelper( 31 TestResolveProxyMsgHelper(
33 net::ProxyService* proxy_service, 32 net::ProxyService* proxy_service,
34 IPC::Listener* listener) 33 IPC::Listener* listener)
35 : ResolveProxyMsgHelper(proxy_service), 34 : ResolveProxyMsgHelper(proxy_service),
36 listener_(listener) {} 35 listener_(listener) {}
37 virtual bool Send(IPC::Message* message) override { 36 bool Send(IPC::Message* message) override {
38 listener_->OnMessageReceived(*message); 37 listener_->OnMessageReceived(*message);
39 delete message; 38 delete message;
40 return true; 39 return true;
41 } 40 }
42 41
43 protected: 42 protected:
44 virtual ~TestResolveProxyMsgHelper() {} 43 ~TestResolveProxyMsgHelper() override {}
45 44
46 IPC::Listener* listener_; 45 IPC::Listener* listener_;
47 }; 46 };
48 47
49 class ResolveProxyMsgHelperTest : public testing::Test, public IPC::Listener { 48 class ResolveProxyMsgHelperTest : public testing::Test, public IPC::Listener {
50 public: 49 public:
51 struct PendingResult { 50 struct PendingResult {
52 PendingResult(bool result, 51 PendingResult(bool result,
53 const std::string& proxy_list) 52 const std::string& proxy_list)
54 : result(result), proxy_list(proxy_list) { 53 : result(result), proxy_list(proxy_list) {
(...skipping 25 matching lines...) Expand all
80 ViewHostMsg_ResolveProxy message(GURL(), &temp_bool, &temp_string); 79 ViewHostMsg_ResolveProxy message(GURL(), &temp_bool, &temp_string);
81 return IPC::SyncMessage::GenerateReply(&message); 80 return IPC::SyncMessage::GenerateReply(&message);
82 } 81 }
83 82
84 net::MockAsyncProxyResolver* resolver_; 83 net::MockAsyncProxyResolver* resolver_;
85 scoped_ptr<net::ProxyService> service_; 84 scoped_ptr<net::ProxyService> service_;
86 scoped_refptr<ResolveProxyMsgHelper> helper_; 85 scoped_refptr<ResolveProxyMsgHelper> helper_;
87 scoped_ptr<PendingResult> pending_result_; 86 scoped_ptr<PendingResult> pending_result_;
88 87
89 private: 88 private:
90 virtual bool OnMessageReceived(const IPC::Message& msg) override { 89 bool OnMessageReceived(const IPC::Message& msg) override {
91 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data; 90 TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data;
92 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); 91 EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data));
93 DCHECK(!pending_result_.get()); 92 DCHECK(!pending_result_.get());
94 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b)); 93 pending_result_.reset(new PendingResult(reply_data.a, reply_data.b));
95 test_sink_.ClearMessages(); 94 test_sink_.ClearMessages();
96 return true; 95 return true;
97 } 96 }
98 97
99 base::MessageLoopForIO message_loop_; 98 base::MessageLoopForIO message_loop_;
100 BrowserThreadImpl io_thread_; 99 BrowserThreadImpl io_thread_;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 246
248 EXPECT_EQ(0u, resolver_->pending_requests().size()); 247 EXPECT_EQ(0u, resolver_->pending_requests().size());
249 248
250 EXPECT_TRUE(pending_result() == NULL); 249 EXPECT_TRUE(pending_result() == NULL);
251 250
252 // It should also be the case that msg1, msg2, msg3 were deleted by the 251 // It should also be the case that msg1, msg2, msg3 were deleted by the
253 // cancellation. (Else will show up as a leak in Valgrind). 252 // cancellation. (Else will show up as a leak in Valgrind).
254 } 253 }
255 254
256 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/resolve_proxy_msg_helper.h ('k') | content/browser/screen_orientation/screen_orientation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698