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

Unified Diff: net/dns/mdns_cache_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/dns/mdns_cache_unittest.cc
diff --git a/net/dns/mdns_cache_unittest.cc b/net/dns/mdns_cache_unittest.cc
index c12ad6b6ec3c830fbb88489aea4d8c41df3ea5f4..5bd0ce9f7bfed11081aa1ec0ec1ed24720e12b0d 100644
--- a/net/dns/mdns_cache_unittest.cc
+++ b/net/dns/mdns_cache_unittest.cc
@@ -19,110 +19,82 @@ using ::testing::StrictMock;
namespace net {
static const uint8 kTestResponsesDifferentAnswers[] = {
- // Answer 1
- // ghs.l.google.com in DNS format.
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
-
- // Answer 2
- // Pointer to answer 1
- 0xc0, 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 122, // RDATA is the IP: 74.125.95.122
+ // Answer 1
+ // ghs.l.google.com in DNS format.
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+
+ // Answer 2
+ // Pointer to answer 1
+ 0xc0, 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 122, // RDATA is the IP: 74.125.95.122
};
static const uint8 kTestResponsesSameAnswers[] = {
- // Answer 1
- // ghs.l.google.com in DNS format.
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
-
- // Answer 2
- // Pointer to answer 1
- 0xc0, 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 112, // TTL (4 bytes) is 112 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+ // Answer 1
+ // ghs.l.google.com in DNS format.
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+
+ // Answer 2
+ // Pointer to answer 1
+ 0xc0, 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 112, // TTL (4 bytes) is 112 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
};
static const uint8 kTestResponseTwoRecords[] = {
- // Answer 1
- // ghs.l.google.com in DNS format. (A)
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
-
- // Answer 2
- // ghs.l.google.com in DNS format. (AAAA)
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x1c, // TYPE is AAA.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 16, // RDLENGTH is 16 bytes.
- 0x4a, 0x7d, 0x4a, 0x7d,
- 0x5f, 0x79, 0x5f, 0x79,
- 0x5f, 0x79, 0x5f, 0x79,
- 0x5f, 0x79, 0x5f, 0x79,
+ // Answer 1
+ // ghs.l.google.com in DNS format. (A)
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+
+ // Answer 2
+ // ghs.l.google.com in DNS format. (AAAA)
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x1c, // TYPE is AAA.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 16, // RDLENGTH is 16 bytes.
+ 0x4a, 0x7d, 0x4a, 0x7d, 0x5f, 0x79, 0x5f, 0x79, 0x5f, 0x79,
+ 0x5f, 0x79, 0x5f, 0x79, 0x5f, 0x79,
};
static const uint8 kTestResponsesGoodbyePacket[] = {
- // Answer 1
- // ghs.l.google.com in DNS format. (Goodbye packet)
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 0, // TTL (4 bytes) is zero.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
-
- // Answer 2
- // ghs.l.google.com in DNS format.
- 3, 'g', 'h', 's',
- 1, 'l',
- 6, 'g', 'o', 'o', 'g', 'l', 'e',
- 3, 'c', 'o', 'm',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
- 0, 4, // RDLENGTH is 4 bytes.
- 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+ // Answer 1
+ // ghs.l.google.com in DNS format. (Goodbye packet)
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 0, // TTL (4 bytes) is zero.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
+
+ // Answer 2
+ // ghs.l.google.com in DNS format.
+ 3, 'g', 'h', 's', 1, 'l', 6, 'g', 'o', 'o',
+ 'g', 'l', 'e', 3, 'c', 'o', 'm', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0, 0, 0, 53, // TTL (4 bytes) is 53 seconds.
+ 0, 4, // RDLENGTH is 4 bytes.
+ 74, 125, 95, 121, // RDATA is the IP: 74.125.95.121
};
class RecordRemovalMock {
@@ -132,8 +104,7 @@ class RecordRemovalMock {
class MDnsCacheTest : public ::testing::Test {
public:
- MDnsCacheTest()
- : default_time_(base::Time::FromDoubleT(1234.0)) {}
+ MDnsCacheTest() : default_time_(base::Time::FromDoubleT(1234.0)) {}
virtual ~MDnsCacheTest() {}
protected:
@@ -144,7 +115,8 @@ class MDnsCacheTest : public ::testing::Test {
// Test a single insert, corresponding lookup, and unsuccessful lookup.
TEST_F(MDnsCacheTest, InsertLookupSingle) {
- DnsRecordParser parser(kT1ResponseDatagram, sizeof(kT1ResponseDatagram),
+ DnsRecordParser parser(kT1ResponseDatagram,
+ sizeof(kT1ResponseDatagram),
sizeof(dns_protocol::Header));
parser.SkipQuestion();
@@ -159,8 +131,8 @@ TEST_F(MDnsCacheTest, InsertLookupSingle) {
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record2.Pass()));
- cache_.FindDnsRecords(ARecordRdata::kType, "ghs.l.google.com", &results,
- default_time_);
+ cache_.FindDnsRecords(
+ ARecordRdata::kType, "ghs.l.google.com", &results, default_time_);
EXPECT_EQ(1u, results.size());
EXPECT_EQ(default_time_, results.front()->time_created());
@@ -168,15 +140,16 @@ TEST_F(MDnsCacheTest, InsertLookupSingle) {
EXPECT_EQ("ghs.l.google.com", results.front()->name());
results.clear();
- cache_.FindDnsRecords(PtrRecordRdata::kType, "ghs.l.google.com", &results,
- default_time_);
+ cache_.FindDnsRecords(
+ PtrRecordRdata::kType, "ghs.l.google.com", &results, default_time_);
EXPECT_EQ(0u, results.size());
}
// Test that records expire when their ttl has passed.
TEST_F(MDnsCacheTest, Expiration) {
- DnsRecordParser parser(kT1ResponseDatagram, sizeof(kT1ResponseDatagram),
+ DnsRecordParser parser(kT1ResponseDatagram,
+ sizeof(kT1ResponseDatagram),
sizeof(dns_protocol::Header));
parser.SkipQuestion();
scoped_ptr<const RecordParsed> record1;
@@ -195,30 +168,30 @@ TEST_F(MDnsCacheTest, Expiration) {
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record1.Pass()));
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record2.Pass()));
- cache_.FindDnsRecords(ARecordRdata::kType, "ghs.l.google.com", &results,
- default_time_);
+ cache_.FindDnsRecords(
+ ARecordRdata::kType, "ghs.l.google.com", &results, default_time_);
EXPECT_EQ(1u, results.size());
EXPECT_EQ(default_time_ + ttl2, cache_.next_expiration());
-
- cache_.FindDnsRecords(ARecordRdata::kType, "ghs.l.google.com", &results,
- default_time_ + ttl2);
+ cache_.FindDnsRecords(
+ ARecordRdata::kType, "ghs.l.google.com", &results, default_time_ + ttl2);
EXPECT_EQ(0u, results.size());
EXPECT_CALL(record_removal_, OnRecordRemoved(record_to_be_deleted));
- cache_.CleanupRecords(default_time_ + ttl2, base::Bind(
- &RecordRemovalMock::OnRecordRemoved, base::Unretained(&record_removal_)));
+ cache_.CleanupRecords(default_time_ + ttl2,
+ base::Bind(&RecordRemovalMock::OnRecordRemoved,
+ base::Unretained(&record_removal_)));
// To make sure that we've indeed removed them from the map, check no funny
// business happens once they're deleted for good.
EXPECT_EQ(default_time_ + ttl1, cache_.next_expiration());
- cache_.FindDnsRecords(ARecordRdata::kType, "ghs.l.google.com", &results,
- default_time_ + ttl2);
+ cache_.FindDnsRecords(
+ ARecordRdata::kType, "ghs.l.google.com", &results, default_time_ + ttl2);
EXPECT_EQ(0u, results.size());
}
@@ -238,24 +211,22 @@ TEST_F(MDnsCacheTest, RecordChange) {
record2 = RecordParsed::CreateFrom(&parser, default_time_);
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record1.Pass()));
- EXPECT_EQ(MDnsCache::RecordChanged,
- cache_.UpdateDnsRecord(record2.Pass()));
+ EXPECT_EQ(MDnsCache::RecordChanged, cache_.UpdateDnsRecord(record2.Pass()));
}
// Test that a new record replacing an otherwise identical one already in the
// cache causes the cache to output a "no change" event.
TEST_F(MDnsCacheTest, RecordNoChange) {
- DnsRecordParser parser(kTestResponsesSameAnswers,
- sizeof(kTestResponsesSameAnswers),
- 0);
+ DnsRecordParser parser(
+ kTestResponsesSameAnswers, sizeof(kTestResponsesSameAnswers), 0);
scoped_ptr<const RecordParsed> record1;
scoped_ptr<const RecordParsed> record2;
std::vector<const RecordParsed*> results;
record1 = RecordParsed::CreateFrom(&parser, default_time_);
- record2 = RecordParsed::CreateFrom(&parser, default_time_ +
- base::TimeDelta::FromSeconds(1));
+ record2 = RecordParsed::CreateFrom(
+ &parser, default_time_ + base::TimeDelta::FromSeconds(1));
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record1.Pass()));
EXPECT_EQ(MDnsCache::NoChange, cache_.UpdateDnsRecord(record2.Pass()));
@@ -264,9 +235,8 @@ TEST_F(MDnsCacheTest, RecordNoChange) {
// Test that the next expiration time of the cache is updated properly on record
// insertion.
TEST_F(MDnsCacheTest, RecordPreemptExpirationTime) {
- DnsRecordParser parser(kTestResponsesSameAnswers,
- sizeof(kTestResponsesSameAnswers),
- 0);
+ DnsRecordParser parser(
+ kTestResponsesSameAnswers, sizeof(kTestResponsesSameAnswers), 0);
scoped_ptr<const RecordParsed> record1;
scoped_ptr<const RecordParsed> record2;
@@ -288,9 +258,8 @@ TEST_F(MDnsCacheTest, RecordPreemptExpirationTime) {
// records to the cache if they are not already there, and eventually removing
// records from the cache if they are.
TEST_F(MDnsCacheTest, GoodbyePacket) {
- DnsRecordParser parser(kTestResponsesGoodbyePacket,
- sizeof(kTestResponsesGoodbyePacket),
- 0);
+ DnsRecordParser parser(
+ kTestResponsesGoodbyePacket, sizeof(kTestResponsesGoodbyePacket), 0);
scoped_ptr<const RecordParsed> record_goodbye;
scoped_ptr<const RecordParsed> record_hello;
@@ -299,9 +268,8 @@ TEST_F(MDnsCacheTest, GoodbyePacket) {
record_goodbye = RecordParsed::CreateFrom(&parser, default_time_);
record_hello = RecordParsed::CreateFrom(&parser, default_time_);
- parser = DnsRecordParser(kTestResponsesGoodbyePacket,
- sizeof(kTestResponsesGoodbyePacket),
- 0);
+ parser = DnsRecordParser(
+ kTestResponsesGoodbyePacket, sizeof(kTestResponsesGoodbyePacket), 0);
record_goodbye2 = RecordParsed::CreateFrom(&parser, default_time_);
base::TimeDelta ttl = base::TimeDelta::FromSeconds(record_hello->ttl());
@@ -319,9 +287,8 @@ TEST_F(MDnsCacheTest, GoodbyePacket) {
}
TEST_F(MDnsCacheTest, AnyRRType) {
- DnsRecordParser parser(kTestResponseTwoRecords,
- sizeof(kTestResponseTwoRecords),
- 0);
+ DnsRecordParser parser(
+ kTestResponseTwoRecords, sizeof(kTestResponseTwoRecords), 0);
scoped_ptr<const RecordParsed> record1;
scoped_ptr<const RecordParsed> record2;
@@ -346,7 +313,8 @@ TEST_F(MDnsCacheTest, AnyRRType) {
}
TEST_F(MDnsCacheTest, RemoveRecord) {
- DnsRecordParser parser(kT1ResponseDatagram, sizeof(kT1ResponseDatagram),
+ DnsRecordParser parser(kT1ResponseDatagram,
+ sizeof(kT1ResponseDatagram),
sizeof(dns_protocol::Header));
parser.SkipQuestion();
@@ -356,8 +324,10 @@ TEST_F(MDnsCacheTest, RemoveRecord) {
record1 = RecordParsed::CreateFrom(&parser, default_time_);
EXPECT_EQ(MDnsCache::RecordAdded, cache_.UpdateDnsRecord(record1.Pass()));
- cache_.FindDnsRecords(dns_protocol::kTypeCNAME, "codereview.chromium.org",
- &results, default_time_);
+ cache_.FindDnsRecords(dns_protocol::kTypeCNAME,
+ "codereview.chromium.org",
+ &results,
+ default_time_);
EXPECT_EQ(1u, results.size());
@@ -366,8 +336,10 @@ TEST_F(MDnsCacheTest, RemoveRecord) {
EXPECT_EQ(record_out.get(), results.front());
- cache_.FindDnsRecords(dns_protocol::kTypeCNAME, "codereview.chromium.org",
- &results, default_time_);
+ cache_.FindDnsRecords(dns_protocol::kTypeCNAME,
+ "codereview.chromium.org",
+ &results,
+ default_time_);
EXPECT_EQ(0u, results.size());
}

Powered by Google App Engine
This is Rietveld 408576698