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

Side by Side Diff: net/dns/dns_transaction_unittest.cc

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo unwanted change in comment 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
« no previous file with comments | « net/dns/dns_transaction.cc ('k') | net/dns/host_resolver_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/dns/dns_transaction.h" 5 #include "net/dns/dns_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 class TestSocketFactory; 146 class TestSocketFactory;
147 147
148 // A variant of MockUDPClientSocket which always fails to Connect. 148 // A variant of MockUDPClientSocket which always fails to Connect.
149 class FailingUDPClientSocket : public MockUDPClientSocket { 149 class FailingUDPClientSocket : public MockUDPClientSocket {
150 public: 150 public:
151 FailingUDPClientSocket(SocketDataProvider* data, 151 FailingUDPClientSocket(SocketDataProvider* data,
152 net::NetLog* net_log) 152 net::NetLog* net_log)
153 : MockUDPClientSocket(data, net_log) { 153 : MockUDPClientSocket(data, net_log) {
154 } 154 }
155 virtual ~FailingUDPClientSocket() {} 155 virtual ~FailingUDPClientSocket() {}
156 virtual int Connect(const IPEndPoint& endpoint) OVERRIDE { 156 virtual int Connect(const IPEndPoint& endpoint) override {
157 return ERR_CONNECTION_REFUSED; 157 return ERR_CONNECTION_REFUSED;
158 } 158 }
159 159
160 private: 160 private:
161 DISALLOW_COPY_AND_ASSIGN(FailingUDPClientSocket); 161 DISALLOW_COPY_AND_ASSIGN(FailingUDPClientSocket);
162 }; 162 };
163 163
164 // A variant of MockUDPClientSocket which notifies the factory OnConnect. 164 // A variant of MockUDPClientSocket which notifies the factory OnConnect.
165 class TestUDPClientSocket : public MockUDPClientSocket { 165 class TestUDPClientSocket : public MockUDPClientSocket {
166 public: 166 public:
167 TestUDPClientSocket(TestSocketFactory* factory, 167 TestUDPClientSocket(TestSocketFactory* factory,
168 SocketDataProvider* data, 168 SocketDataProvider* data,
169 net::NetLog* net_log) 169 net::NetLog* net_log)
170 : MockUDPClientSocket(data, net_log), factory_(factory) { 170 : MockUDPClientSocket(data, net_log), factory_(factory) {
171 } 171 }
172 virtual ~TestUDPClientSocket() {} 172 virtual ~TestUDPClientSocket() {}
173 virtual int Connect(const IPEndPoint& endpoint) OVERRIDE; 173 virtual int Connect(const IPEndPoint& endpoint) override;
174 174
175 private: 175 private:
176 TestSocketFactory* factory_; 176 TestSocketFactory* factory_;
177 177
178 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket); 178 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket);
179 }; 179 };
180 180
181 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect. 181 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect.
182 class TestSocketFactory : public MockClientSocketFactory { 182 class TestSocketFactory : public MockClientSocketFactory {
183 public: 183 public:
184 TestSocketFactory() : fail_next_socket_(false) {} 184 TestSocketFactory() : fail_next_socket_(false) {}
185 virtual ~TestSocketFactory() {} 185 virtual ~TestSocketFactory() {}
186 186
187 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( 187 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket(
188 DatagramSocket::BindType bind_type, 188 DatagramSocket::BindType bind_type,
189 const RandIntCallback& rand_int_cb, 189 const RandIntCallback& rand_int_cb,
190 net::NetLog* net_log, 190 net::NetLog* net_log,
191 const net::NetLog::Source& source) OVERRIDE { 191 const net::NetLog::Source& source) override {
192 if (fail_next_socket_) { 192 if (fail_next_socket_) {
193 fail_next_socket_ = false; 193 fail_next_socket_ = false;
194 return scoped_ptr<DatagramClientSocket>( 194 return scoped_ptr<DatagramClientSocket>(
195 new FailingUDPClientSocket(&empty_data_, net_log)); 195 new FailingUDPClientSocket(&empty_data_, net_log));
196 } 196 }
197 SocketDataProvider* data_provider = mock_data().GetNext(); 197 SocketDataProvider* data_provider = mock_data().GetNext();
198 scoped_ptr<TestUDPClientSocket> socket( 198 scoped_ptr<TestUDPClientSocket> socket(
199 new TestUDPClientSocket(this, data_provider, net_log)); 199 new TestUDPClientSocket(this, data_provider, net_log));
200 data_provider->set_socket(socket.get()); 200 data_provider->set_socket(socket.get());
201 return socket.PassAs<DatagramClientSocket>(); 201 return socket.PassAs<DatagramClientSocket>();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Checks if the sockets were connected in the order matching the indices in 434 // Checks if the sockets were connected in the order matching the indices in
435 // |servers|. 435 // |servers|.
436 void CheckServerOrder(const unsigned* servers, size_t num_attempts) { 436 void CheckServerOrder(const unsigned* servers, size_t num_attempts) {
437 ASSERT_EQ(num_attempts, socket_factory_->remote_endpoints_.size()); 437 ASSERT_EQ(num_attempts, socket_factory_->remote_endpoints_.size());
438 for (size_t i = 0; i < num_attempts; ++i) { 438 for (size_t i = 0; i < num_attempts; ++i) {
439 EXPECT_EQ(socket_factory_->remote_endpoints_[i], 439 EXPECT_EQ(socket_factory_->remote_endpoints_[i],
440 session_->config().nameservers[servers[i]]); 440 session_->config().nameservers[servers[i]]);
441 } 441 }
442 } 442 }
443 443
444 virtual void SetUp() OVERRIDE { 444 virtual void SetUp() override {
445 // By default set one server, 445 // By default set one server,
446 ConfigureNumServers(1); 446 ConfigureNumServers(1);
447 // and no retransmissions, 447 // and no retransmissions,
448 config_.attempts = 1; 448 config_.attempts = 1;
449 // but long enough timeout for memory tests. 449 // but long enough timeout for memory tests.
450 config_.timeout = TestTimeouts::action_timeout(); 450 config_.timeout = TestTimeouts::action_timeout();
451 ConfigureFactory(); 451 ConfigureFactory();
452 } 452 }
453 453
454 virtual void TearDown() OVERRIDE { 454 virtual void TearDown() override {
455 // Check that all socket data was at least written to. 455 // Check that all socket data was at least written to.
456 for (size_t i = 0; i < socket_data_.size(); ++i) { 456 for (size_t i = 0; i < socket_data_.size(); ++i) {
457 EXPECT_TRUE(socket_data_[i]->was_written()) << i; 457 EXPECT_TRUE(socket_data_[i]->was_written()) << i;
458 } 458 }
459 } 459 }
460 460
461 protected: 461 protected:
462 int GetNextId(int min, int max) { 462 int GetNextId(int min, int max) {
463 EXPECT_FALSE(transaction_ids_.empty()); 463 EXPECT_FALSE(transaction_ids_.empty());
464 int id = transaction_ids_.front(); 464 int id = transaction_ids_.front();
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 config_.timeout = TestTimeouts::tiny_timeout(); 1002 config_.timeout = TestTimeouts::tiny_timeout();
1003 ConfigureFactory(); 1003 ConfigureFactory();
1004 1004
1005 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); 1005 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT);
1006 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 1006 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
1007 } 1007 }
1008 1008
1009 } // namespace 1009 } // namespace
1010 1010
1011 } // namespace net 1011 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_transaction.cc ('k') | net/dns/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698