Index: net/dns/dns_transaction_unittest.cc |
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc |
index e87564551c50e2e5d252e0d866ddb297011c18a7..f86aae1060b8aa821c478127c0b6038839bdc82b 100644 |
--- a/net/dns/dns_transaction_unittest.cc |
+++ b/net/dns/dns_transaction_unittest.cc |
@@ -3,10 +3,6 @@ |
// found in the LICENSE file. |
#include "net/dns/dns_transaction.h" |
- |
-#include <stdint.h> |
- |
-#include <limits> |
#include "base/bind.h" |
#include "base/memory/scoped_ptr.h" |
@@ -37,19 +33,19 @@ |
class DnsSocketData { |
public: |
// The ctor takes parameters for the DnsQuery. |
- DnsSocketData(uint16_t id, |
+ DnsSocketData(uint16 id, |
const char* dotted_name, |
- uint16_t qtype, |
+ uint16 qtype, |
IoMode mode, |
bool use_tcp) |
: query_(new DnsQuery(id, DomainFromDot(dotted_name), qtype)), |
use_tcp_(use_tcp) { |
if (use_tcp_) { |
- scoped_ptr<uint16_t> length(new uint16_t); |
+ scoped_ptr<uint16> length(new uint16); |
*length = base::HostToNet16(query_->io_buffer()->size()); |
writes_.push_back(MockWrite(mode, |
reinterpret_cast<const char*>(length.get()), |
- sizeof(uint16_t), num_reads_and_writes())); |
+ sizeof(uint16), num_reads_and_writes())); |
lengths_.push_back(length.Pass()); |
} |
writes_.push_back(MockWrite(mode, query_->io_buffer()->data(), |
@@ -61,16 +57,15 @@ |
// All responses must be added before GetProvider. |
// Adds pre-built DnsResponse. |tcp_length| will be used in TCP mode only. |
- void AddResponseWithLength(scoped_ptr<DnsResponse> response, |
- IoMode mode, |
- uint16_t tcp_length) { |
+ void AddResponseWithLength(scoped_ptr<DnsResponse> response, IoMode mode, |
+ uint16 tcp_length) { |
CHECK(!provider_.get()); |
if (use_tcp_) { |
- scoped_ptr<uint16_t> length(new uint16_t); |
+ scoped_ptr<uint16> length(new uint16); |
*length = base::HostToNet16(tcp_length); |
reads_.push_back(MockRead(mode, |
reinterpret_cast<const char*>(length.get()), |
- sizeof(uint16_t), num_reads_and_writes())); |
+ sizeof(uint16), num_reads_and_writes())); |
lengths_.push_back(length.Pass()); |
} |
reads_.push_back(MockRead(mode, response->io_buffer()->data(), |
@@ -81,12 +76,12 @@ |
// Adds pre-built DnsResponse. |
void AddResponse(scoped_ptr<DnsResponse> response, IoMode mode) { |
- uint16_t tcp_length = response->io_buffer()->size(); |
+ uint16 tcp_length = response->io_buffer()->size(); |
AddResponseWithLength(response.Pass(), mode, tcp_length); |
} |
// Adds pre-built response from |data| buffer. |
- void AddResponseData(const uint8_t* data, size_t length, IoMode mode) { |
+ void AddResponseData(const uint8* data, size_t length, IoMode mode) { |
CHECK(!provider_.get()); |
AddResponse(make_scoped_ptr( |
new DnsResponse(reinterpret_cast<const char*>(data), length, 0)), mode); |
@@ -126,14 +121,16 @@ |
return provider_.get(); |
} |
- uint16_t query_id() const { return query_->id(); } |
+ uint16 query_id() const { |
+ return query_->id(); |
+ } |
private: |
size_t num_reads_and_writes() const { return reads_.size() + writes_.size(); } |
scoped_ptr<DnsQuery> query_; |
bool use_tcp_; |
- std::vector<scoped_ptr<uint16_t>> lengths_; |
+ std::vector<scoped_ptr<uint16>> lengths_; |
std::vector<scoped_ptr<DnsResponse>> responses_; |
std::vector<MockWrite> writes_; |
std::vector<MockRead> reads_; |
@@ -223,14 +220,15 @@ |
public: |
// If |expected_answer_count| < 0 then it is the expected net error. |
TransactionHelper(const char* hostname, |
- uint16_t qtype, |
+ uint16 qtype, |
int expected_answer_count) |
: hostname_(hostname), |
qtype_(qtype), |
expected_answer_count_(expected_answer_count), |
cancel_in_callback_(false), |
quit_in_callback_(false), |
- completed_(false) {} |
+ completed_(false) { |
+ } |
// Mark that the transaction shall be destroyed immediately upon callback. |
void set_cancel_in_callback() { |
@@ -316,7 +314,7 @@ |
private: |
std::string hostname_; |
- uint16_t qtype_; |
+ uint16 qtype_; |
scoped_ptr<DnsTransaction> transaction_; |
int expected_answer_count_; |
bool cancel_in_callback_; |
@@ -366,10 +364,10 @@ |
// Add expected query for |dotted_name| and |qtype| with |id| and response |
// taken verbatim from |data| of |data_length| bytes. The transaction id in |
// |data| should equal |id|, unless testing mismatched response. |
- void AddQueryAndResponse(uint16_t id, |
+ void AddQueryAndResponse(uint16 id, |
const char* dotted_name, |
- uint16_t qtype, |
- const uint8_t* response_data, |
+ uint16 qtype, |
+ const uint8* response_data, |
size_t response_length, |
IoMode mode, |
bool use_tcp) { |
@@ -380,27 +378,27 @@ |
AddSocketData(data.Pass()); |
} |
- void AddAsyncQueryAndResponse(uint16_t id, |
+ void AddAsyncQueryAndResponse(uint16 id, |
const char* dotted_name, |
- uint16_t qtype, |
- const uint8_t* data, |
+ uint16 qtype, |
+ const uint8* data, |
size_t data_length) { |
AddQueryAndResponse(id, dotted_name, qtype, data, data_length, ASYNC, |
false); |
} |
- void AddSyncQueryAndResponse(uint16_t id, |
+ void AddSyncQueryAndResponse(uint16 id, |
const char* dotted_name, |
- uint16_t qtype, |
- const uint8_t* data, |
+ uint16 qtype, |
+ const uint8* data, |
size_t data_length) { |
AddQueryAndResponse(id, dotted_name, qtype, data, data_length, SYNCHRONOUS, |
false); |
} |
// Add expected query of |dotted_name| and |qtype| and no response. |
- void AddQueryAndTimeout(const char* dotted_name, uint16_t qtype) { |
- uint16_t id = base::RandInt(0, std::numeric_limits<uint16_t>::max()); |
+ void AddQueryAndTimeout(const char* dotted_name, uint16 qtype) { |
+ uint16 id = base::RandInt(0, kuint16max); |
scoped_ptr<DnsSocketData> data( |
new DnsSocketData(id, dotted_name, qtype, ASYNC, false)); |
AddSocketData(data.Pass()); |
@@ -409,27 +407,23 @@ |
// Add expected query of |dotted_name| and |qtype| and matching response with |
// no answer and RCODE set to |rcode|. The id will be generated randomly. |
void AddQueryAndRcode(const char* dotted_name, |
- uint16_t qtype, |
+ uint16 qtype, |
int rcode, |
IoMode mode, |
bool use_tcp) { |
CHECK_NE(dns_protocol::kRcodeNOERROR, rcode); |
- uint16_t id = base::RandInt(0, std::numeric_limits<uint16_t>::max()); |
+ uint16 id = base::RandInt(0, kuint16max); |
scoped_ptr<DnsSocketData> data( |
new DnsSocketData(id, dotted_name, qtype, mode, use_tcp)); |
data->AddRcode(rcode, mode); |
AddSocketData(data.Pass()); |
} |
- void AddAsyncQueryAndRcode(const char* dotted_name, |
- uint16_t qtype, |
- int rcode) { |
+ void AddAsyncQueryAndRcode(const char* dotted_name, uint16 qtype, int rcode) { |
AddQueryAndRcode(dotted_name, qtype, rcode, ASYNC, false); |
} |
- void AddSyncQueryAndRcode(const char* dotted_name, |
- uint16_t qtype, |
- int rcode) { |
+ void AddSyncQueryAndRcode(const char* dotted_name, uint16 qtype, int rcode) { |
AddQueryAndRcode(dotted_name, qtype, rcode, SYNCHRONOUS, false); |
} |
@@ -790,15 +784,19 @@ |
EXPECT_TRUE(helper2.Run(transaction_factory_.get())); |
} |
-const uint8_t kResponseNoData[] = { |
- 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, |
- // Question |
- 0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00, 0x01, |
- // Authority section, SOA record, TTL 0x3E6 |
- 0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6, |
- // Minimal RDATA, 18 bytes |
- 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
+const uint8 kResponseNoData[] = { |
+ 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, |
+ // Question |
+ 0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00, 0x01, |
+ // Authority section, SOA record, TTL 0x3E6 |
+ 0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6, |
+ // Minimal RDATA, 18 bytes |
+ 0x00, 0x12, |
+ 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, |
}; |
TEST_F(DnsTransactionTest, SuffixSearchStop) { |
@@ -917,7 +915,8 @@ |
make_scoped_ptr( |
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram), |
arraysize(kT0ResponseDatagram), 0)), |
- ASYNC, static_cast<uint16_t>(kT0QuerySize - 1)); |
+ ASYNC, |
+ static_cast<uint16>(kT0QuerySize - 1)); |
AddSocketData(data.Pass()); |
TransactionHelper helper0(kT0HostName, kT0Qtype, ERR_DNS_MALFORMED_RESPONSE); |
@@ -946,7 +945,8 @@ |
make_scoped_ptr( |
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram), |
arraysize(kT0ResponseDatagram) - 1, 0)), |
- ASYNC, static_cast<uint16_t>(arraysize(kT0ResponseDatagram))); |
+ ASYNC, |
+ static_cast<uint16>(arraysize(kT0ResponseDatagram))); |
// Then return a 0-length read. |
data->AddReadError(0, ASYNC); |
AddSocketData(data.Pass()); |
@@ -965,7 +965,8 @@ |
make_scoped_ptr( |
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram), |
arraysize(kT0ResponseDatagram) - 1, 0)), |
- SYNCHRONOUS, static_cast<uint16_t>(arraysize(kT0ResponseDatagram))); |
+ SYNCHRONOUS, |
+ static_cast<uint16>(arraysize(kT0ResponseDatagram))); |
// Then return a 0-length read. |
data->AddReadError(0, SYNCHRONOUS); |
AddSocketData(data.Pass()); |