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

Unified Diff: net/dns/mdns_client_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_client_unittest.cc
diff --git a/net/dns/mdns_client_unittest.cc b/net/dns/mdns_client_unittest.cc
index 0186839da04aa80fefd9ab11c7b389adadeed51d..50c5fd541ca71f734205a64cf3b06fdc79985759 100644
--- a/net/dns/mdns_client_unittest.cc
+++ b/net/dns/mdns_client_unittest.cc
@@ -28,328 +28,270 @@ namespace net {
namespace {
-const uint8 kSamplePacket1[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x00, // TTL (4 bytes) is 1 second;
- 0x00, 0x01,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x0c,
-
- // Answer 2
- 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e', 'r',
- 0xc0, 0x14, // Pointer to "._tcp.local"
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 49 seconds.
- 0x24, 0x75,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x32
-};
+const uint8
+ kSamplePacket1
+ [] =
+ {
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
+ 0x04, '_', 't', 'c', 'p', 0x05, 'l', 'o',
+ 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x00, // TTL (4 bytes) is 1 second;
+ 0x00, 0x01, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x0c,
+
+ // Answer 2
+ 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e',
+ 'r', 0xc0, 0x14, // Pointer to "._tcp.local"
+ 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 49 seconds.
+ 0x24, 0x75, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x32};
const uint8 kCorruptedPacketBadQuestion[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x01, // One question
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Question is corrupted and cannot be read.
- 0x99, 'h', 'e', 'l', 'l', 'o',
- 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x99, // RDLENGTH is impossible
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x0c,
-
- // Answer 2
- 0x08, '_', 'p', 'r', // Useless trailing data.
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x01, // One question
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Question is corrupted and cannot be read.
+ 0x99, 'h', 'e', 'l', 'l', 'o', 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x99, // RDLENGTH is impossible
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x0c,
+
+ // Answer 2
+ 0x08, '_', 'p', 'r', // Useless trailing data.
};
const uint8 kCorruptedPacketUnsalvagable[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x99, // RDLENGTH is impossible
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x0c,
-
- // Answer 2
- 0x08, '_', 'p', 'r', // Useless trailing data.
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x99, // RDLENGTH is impossible
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x0c,
+
+ // Answer 2
+ 0x08, '_', 'p', 'r', // Useless trailing data.
};
const uint8 kCorruptedPacketDoubleRecord[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x06, 'p', 'r', 'i', 'v', 'e', 't',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x04, // RDLENGTH is 4
- 0x05, 0x03,
- 0xc0, 0x0c,
-
- // Answer 2 -- Same key
- 0x06, 'p', 'r', 'i', 'v', 'e', 't',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x04, // RDLENGTH is 4
- 0x02, 0x03,
- 0x04, 0x05,
-};
-
-const uint8 kCorruptedPacketSalvagable[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x99, 'h', 'e', 'l', 'l', 'o', // Bad RDATA format.
- 0xc0, 0x0c,
-
- // Answer 2
- 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e', 'r',
- 0xc0, 0x14, // Pointer to "._tcp.local"
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 49 seconds.
- 0x24, 0x75,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x32
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x06, 'p', 'r', 'i', 'v', 'e', 't', 0x05,
+ 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x04, // RDLENGTH is 4
+ 0x05, 0x03, 0xc0, 0x0c,
+
+ // Answer 2 -- Same key
+ 0x06, 'p', 'r', 'i', 'v', 'e', 't', 0x05,
+ 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x04, // RDLENGTH is 4
+ 0x02, 0x03, 0x04, 0x05,
};
-const uint8 kSamplePacket2[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x02, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'z', 'z', 'z', 'z', 'z',
- 0xc0, 0x0c,
-
- // Answer 2
- 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e', 'r',
- 0xc0, 0x14, // Pointer to "._tcp.local"
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'z', 'z', 'z', 'z', 'z',
- 0xc0, 0x32
-};
+const uint8
+ kCorruptedPacketSalvagable
+ [] =
+ {
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
+ 0x04, '_', 't', 'c', 'p', 0x05, 'l', 'o',
+ 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x99, 'h', 'e', 'l', 'l', 'o', // Bad RDATA format.
+ 0xc0, 0x0c,
+
+ // Answer 2
+ 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e',
+ 'r', 0xc0, 0x14, // Pointer to "._tcp.local"
+ 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 49 seconds.
+ 0x24, 0x75, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x32};
+
+const uint8
+ kSamplePacket2
+ [] =
+ {
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x02, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
+ 0x04, '_', 't', 'c', 'p', 0x05, 'l', 'o',
+ 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'z', 'z', 'z', 'z', 'z', 0xc0, 0x0c,
+
+ // Answer 2
+ 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e',
+ 'r', 0xc0, 0x14, // Pointer to "._tcp.local"
+ 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'z', 'z', 'z', 'z', 'z', 0xc0, 0x32};
const uint8 kQueryPacketPrivet[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x00, 0x00, // No flags.
- 0x00, 0x01, // One question.
- 0x00, 0x00, // 0 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Question
- // This part is echoed back from the respective query.
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x00, 0x00, // No flags.
+ 0x00, 0x01, // One question.
+ 0x00, 0x00, // 0 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Question
+ // This part is echoed back from the respective query.
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
};
const uint8 kQueryPacketPrivetA[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x00, 0x00, // No flags.
- 0x00, 0x01, // One question.
- 0x00, 0x00, // 0 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Question
- // This part is echoed back from the respective query.
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x00, 0x00, // No flags.
+ 0x00, 0x01, // One question.
+ 0x00, 0x00, // 0 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Question
+ // This part is echoed back from the respective query.
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't',
+ 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
};
const uint8 kSamplePacketAdditionalOnly[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x00, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x01, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'h', 'e', 'l', 'l', 'o',
- 0xc0, 0x0c,
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x00, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x01, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'h', 'e', 'l', 'l', 'o', 0xc0, 0x0c,
};
const uint8 kSamplePacketNsec[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x01, // 1 RR (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x2f, // TYPE is NSEC.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
- 0x24, 0x74,
- 0x00, 0x06, // RDLENGTH is 6 bytes.
- 0xc0, 0x0c,
- 0x00, 0x02, 0x00, 0x08 // Only A record present
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x01, // 1 RR (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x2f, // TYPE is NSEC.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
+ 0x24, 0x74, 0x00, 0x06, // RDLENGTH is 6 bytes.
+ 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x08 // Only A record present
};
const uint8 kSamplePacketAPrivet[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x01, // 1 RR (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x01, // TYPE is A.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x00, // TTL (4 bytes) is 5 seconds
- 0x00, 0x05,
- 0x00, 0x04, // RDLENGTH is 4 bytes.
- 0xc0, 0x0c,
- 0x00, 0x02,
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x01, // 1 RR (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't',
+ 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x01, // TYPE is A.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x00, // TTL (4 bytes) is 5 seconds
+ 0x00, 0x05, 0x00, 0x04, // RDLENGTH is 4 bytes.
+ 0xc0, 0x0c, 0x00, 0x02,
};
const uint8 kSamplePacketGoodbye[] = {
- // Header
- 0x00, 0x00, // ID is zeroed out
- 0x81, 0x80, // Standard query response, RA, no error
- 0x00, 0x00, // No questions (for simplicity)
- 0x00, 0x01, // 2 RRs (answers)
- 0x00, 0x00, // 0 authority RRs
- 0x00, 0x00, // 0 additional RRs
-
- // Answer 1
- 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't',
- 0x04, '_', 't', 'c', 'p',
- 0x05, 'l', 'o', 'c', 'a', 'l',
- 0x00,
- 0x00, 0x0c, // TYPE is PTR.
- 0x00, 0x01, // CLASS is IN.
- 0x00, 0x00, // TTL (4 bytes) is zero;
- 0x00, 0x00,
- 0x00, 0x08, // RDLENGTH is 8 bytes.
- 0x05, 'z', 'z', 'z', 'z', 'z',
- 0xc0, 0x0c,
+ // Header
+ 0x00, 0x00, // ID is zeroed out
+ 0x81, 0x80, // Standard query response, RA, no error
+ 0x00, 0x00, // No questions (for simplicity)
+ 0x00, 0x01, // 2 RRs (answers)
+ 0x00, 0x00, // 0 authority RRs
+ 0x00, 0x00, // 0 additional RRs
+
+ // Answer 1
+ 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
+ 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
+ 0x00, 0x01, // CLASS is IN.
+ 0x00, 0x00, // TTL (4 bytes) is zero;
+ 0x00, 0x00, 0x00, 0x08, // RDLENGTH is 8 bytes.
+ 0x05, 'z', 'z', 'z', 'z', 'z', 0xc0, 0x0c,
};
std::string MakeString(const uint8* data, unsigned size) {
@@ -363,9 +305,7 @@ class PtrRecordCopyContainer {
bool is_set() const { return set_; }
- void SaveWithDummyArg(int unused, const RecordParsed* value) {
- Save(value);
- }
+ void SaveWithDummyArg(int unused, const RecordParsed* value) { Save(value); }
void Save(const RecordParsed* value) {
set_ = true;
@@ -397,12 +337,13 @@ class MDnsTest : public ::testing::Test {
void RunFor(base::TimeDelta time_period);
void Stop();
- MOCK_METHOD2(MockableRecordCallback, void(MDnsTransaction::Result result,
- const RecordParsed* record));
-
- MOCK_METHOD2(MockableRecordCallback2, void(MDnsTransaction::Result result,
- const RecordParsed* record));
+ MOCK_METHOD2(MockableRecordCallback,
+ void(MDnsTransaction::Result result,
+ const RecordParsed* record));
+ MOCK_METHOD2(MockableRecordCallback2,
+ void(MDnsTransaction::Result result,
+ const RecordParsed* record));
protected:
void ExpectPacket(const uint8* packet, unsigned size);
@@ -437,8 +378,7 @@ void MDnsTest::SimulatePacketReceive(const uint8* packet, unsigned size) {
}
void MDnsTest::ExpectPacket(const uint8* packet, unsigned size) {
- EXPECT_CALL(socket_factory_, OnSendTo(MakeString(packet, size)))
- .Times(2);
+ EXPECT_CALL(socket_factory_, OnSendTo(MakeString(packet, size))).Times(2);
}
void MDnsTest::DeleteTransaction() {
@@ -451,8 +391,8 @@ void MDnsTest::DeleteBothListeners() {
}
void MDnsTest::RunFor(base::TimeDelta time_period) {
- base::CancelableCallback<void()> callback(base::Bind(&MDnsTest::Stop,
- base::Unretained(this)));
+ base::CancelableCallback<void()> callback(
+ base::Bind(&MDnsTest::Stop, base::Unretained(this)));
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE, callback.callback(), time_period);
@@ -471,12 +411,10 @@ TEST_F(MDnsTest, PassiveListeners) {
PtrRecordCopyContainer record_privet;
PtrRecordCopyContainer record_printer;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_privet);
- scoped_ptr<MDnsListener> listener_printer =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_printer._tcp.local",
- &delegate_printer);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
+ scoped_ptr<MDnsListener> listener_printer = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_printer._tcp.local", &delegate_printer);
ASSERT_TRUE(listener_privet->Start());
ASSERT_TRUE(listener_printer->Start());
@@ -485,16 +423,13 @@ TEST_F(MDnsTest, PassiveListeners) {
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.Times(Exactly(1))
- .WillOnce(Invoke(
- &record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg));
EXPECT_CALL(delegate_printer, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.Times(Exactly(1))
- .WillOnce(Invoke(
- &record_printer,
- &PtrRecordCopyContainer::SaveWithDummyArg));
-
+ .WillOnce(
+ Invoke(&record_printer, &PtrRecordCopyContainer::SaveWithDummyArg));
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
@@ -515,17 +450,15 @@ TEST_F(MDnsTest, PassiveListenersCacheCleanup) {
PtrRecordCopyContainer record_privet;
PtrRecordCopyContainer record_privet2;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
ASSERT_TRUE(listener_privet->Start());
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.Times(Exactly(1))
- .WillOnce(Invoke(
- &record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg));
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
@@ -535,9 +468,9 @@ TEST_F(MDnsTest, PassiveListenersCacheCleanup) {
// Expect record is removed when its TTL expires.
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _))
.Times(Exactly(1))
- .WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::Stop),
- Invoke(&record_privet2,
- &PtrRecordCopyContainer::SaveWithDummyArg)));
+ .WillOnce(DoAll(
+ InvokeWithoutArgs(this, &MDnsTest::Stop),
+ Invoke(&record_privet2, &PtrRecordCopyContainer::SaveWithDummyArg)));
RunFor(base::TimeDelta::FromSeconds(record_privet.ttl() + 1));
@@ -550,17 +483,15 @@ TEST_F(MDnsTest, MalformedPacket) {
PtrRecordCopyContainer record_printer;
- scoped_ptr<MDnsListener> listener_printer =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_printer._tcp.local",
- &delegate_printer);
+ scoped_ptr<MDnsListener> listener_printer = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_printer._tcp.local", &delegate_printer);
ASSERT_TRUE(listener_printer->Start());
EXPECT_CALL(delegate_printer, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.Times(Exactly(1))
- .WillOnce(Invoke(
- &record_printer,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_printer, &PtrRecordCopyContainer::SaveWithDummyArg));
// First, send unsalvagable packet to ensure we can deal with it.
SimulatePacketReceive(kCorruptedPacketUnsalvagable,
@@ -583,10 +514,10 @@ TEST_F(MDnsTest, TransactionWithEmptyCache) {
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -596,8 +527,8 @@ TEST_F(MDnsTest, TransactionWithEmptyCache) {
EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _))
.Times(Exactly(1))
- .WillOnce(Invoke(&record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg));
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
@@ -608,9 +539,9 @@ TEST_F(MDnsTest, TransactionWithEmptyCache) {
TEST_F(MDnsTest, TransactionCacheOnlyNoResult) {
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_CACHE | MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -624,28 +555,25 @@ TEST_F(MDnsTest, TransactionCacheOnlyNoResult) {
TEST_F(MDnsTest, TransactionWithCache) {
// Listener to force the client to listen
StrictMock<MockListenerDelegate> delegate_irrelevant;
- scoped_ptr<MDnsListener> listener_irrelevant =
- test_client_.CreateListener(dns_protocol::kTypeA,
- "codereview.chromium.local",
- &delegate_irrelevant);
+ scoped_ptr<MDnsListener> listener_irrelevant = test_client_.CreateListener(
+ dns_protocol::kTypeA, "codereview.chromium.local", &delegate_irrelevant);
ASSERT_TRUE(listener_irrelevant->Start());
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
-
PtrRecordCopyContainer record_privet;
EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _))
- .WillOnce(Invoke(&record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg));
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -660,17 +588,15 @@ TEST_F(MDnsTest, AdditionalRecords) {
PtrRecordCopyContainer record_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
ASSERT_TRUE(listener_privet->Start());
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.Times(Exactly(1))
- .WillOnce(Invoke(
- &record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg));
SimulatePacketReceive(kSamplePacketAdditionalOnly,
sizeof(kSamplePacketAdditionalOnly));
@@ -684,10 +610,10 @@ TEST_F(MDnsTest, TransactionTimeout) {
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -706,9 +632,9 @@ TEST_F(MDnsTest, TransactionMultipleRecords) {
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE ,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -719,10 +645,10 @@ TEST_F(MDnsTest, TransactionMultipleRecords) {
EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _))
.Times(Exactly(2))
- .WillOnce(Invoke(&record_privet,
- &PtrRecordCopyContainer::SaveWithDummyArg))
- .WillOnce(Invoke(&record_privet2,
- &PtrRecordCopyContainer::SaveWithDummyArg));
+ .WillOnce(
+ Invoke(&record_privet, &PtrRecordCopyContainer::SaveWithDummyArg))
+ .WillOnce(
+ Invoke(&record_privet2, &PtrRecordCopyContainer::SaveWithDummyArg));
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
SimulatePacketReceive(kSamplePacket2, sizeof(kSamplePacket2));
@@ -743,17 +669,16 @@ TEST_F(MDnsTest, TransactionReentrantDelete) {
ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet));
transaction_ = test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
- base::Bind(&MDnsTest::MockableRecordCallback,
- base::Unretained(this)));
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
+ base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this)));
ASSERT_TRUE(transaction_->Start());
- EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS,
- NULL))
+ EXPECT_CALL(*this,
+ MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, NULL))
.Times(Exactly(1))
.WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::DeleteTransaction),
InvokeWithoutArgs(this, &MDnsTest::Stop)));
@@ -766,18 +691,16 @@ TEST_F(MDnsTest, TransactionReentrantDelete) {
TEST_F(MDnsTest, TransactionReentrantDeleteFromCache) {
StrictMock<MockListenerDelegate> delegate_irrelevant;
scoped_ptr<MDnsListener> listener_irrelevant = test_client_.CreateListener(
- dns_protocol::kTypeA, "codereview.chromium.local",
- &delegate_irrelevant);
+ dns_protocol::kTypeA, "codereview.chromium.local", &delegate_irrelevant);
ASSERT_TRUE(listener_irrelevant->Start());
SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1));
transaction_ = test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE,
- base::Bind(&MDnsTest::MockableRecordCallback,
- base::Unretained(this)));
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE,
+ base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this)));
EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _))
.Times(Exactly(1))
@@ -791,32 +714,26 @@ TEST_F(MDnsTest, TransactionReentrantDeleteFromCache) {
TEST_F(MDnsTest, TransactionReentrantCacheLookupStart) {
ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet));
- scoped_ptr<MDnsTransaction> transaction1 =
- test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
+ scoped_ptr<MDnsTransaction> transaction1 = test_client_.CreateTransaction(
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
MDnsTransaction::SINGLE_RESULT,
- base::Bind(&MDnsTest::MockableRecordCallback,
- base::Unretained(this)));
+ base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this)));
- scoped_ptr<MDnsTransaction> transaction2 =
- test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_printer._tcp.local",
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
- base::Bind(&MDnsTest::MockableRecordCallback2,
- base::Unretained(this)));
+ scoped_ptr<MDnsTransaction> transaction2 = test_client_.CreateTransaction(
+ dns_protocol::kTypePTR,
+ "_printer._tcp.local",
+ MDnsTransaction::QUERY_CACHE | MDnsTransaction::SINGLE_RESULT,
+ base::Bind(&MDnsTest::MockableRecordCallback2, base::Unretained(this)));
- EXPECT_CALL(*this, MockableRecordCallback2(MDnsTransaction::RESULT_RECORD,
- _))
+ EXPECT_CALL(*this, MockableRecordCallback2(MDnsTransaction::RESULT_RECORD, _))
.Times(Exactly(1));
- EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD,
- _))
+ EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _))
.Times(Exactly(1))
- .WillOnce(IgnoreResult(InvokeWithoutArgs(transaction2.get(),
- &MDnsTransaction::Start)));
+ .WillOnce(IgnoreResult(
+ InvokeWithoutArgs(transaction2.get(), &MDnsTransaction::Start)));
ASSERT_TRUE(transaction1->Start());
@@ -838,9 +755,8 @@ TEST_F(MDnsTest, GoodbyePacketNotification) {
TEST_F(MDnsTest, GoodbyePacketRemoval) {
StrictMock<MockListenerDelegate> delegate_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
ASSERT_TRUE(listener_privet->Start());
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
@@ -863,13 +779,11 @@ TEST_F(MDnsTest, GoodbyePacketRemoval) {
TEST_F(MDnsTest, ListenerReentrantDelete) {
StrictMock<MockListenerDelegate> delegate_privet;
- listener1_ = test_client_.CreateListener(dns_protocol::kTypePTR,
- "_privet._tcp.local",
- &delegate_privet);
+ listener1_ = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
- listener2_ = test_client_.CreateListener(dns_protocol::kTypePTR,
- "_privet._tcp.local",
- &delegate_privet);
+ listener2_ = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet);
ASSERT_TRUE(listener1_->Start());
@@ -896,9 +810,8 @@ TEST_F(MDnsTest, DoubleRecordDisagreeing) {
IPAddressNumber address;
StrictMock<MockListenerDelegate> delegate_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypeA, "privet.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypeA, "privet.local", &delegate_privet);
ASSERT_TRUE(listener_privet->Start());
@@ -914,33 +827,30 @@ TEST_F(MDnsTest, DoubleRecordDisagreeing) {
TEST_F(MDnsTest, NsecWithListener) {
StrictMock<MockListenerDelegate> delegate_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet);
// Test to make sure nsec callback is NOT called for PTR
// (which is marked as existing).
StrictMock<MockListenerDelegate> delegate_privet2;
- scoped_ptr<MDnsListener> listener_privet2 =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_privet2);
+ scoped_ptr<MDnsListener> listener_privet2 = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet2);
ASSERT_TRUE(listener_privet->Start());
EXPECT_CALL(delegate_privet,
OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA));
- SimulatePacketReceive(kSamplePacketNsec,
- sizeof(kSamplePacketNsec));
+ SimulatePacketReceive(kSamplePacketNsec, sizeof(kSamplePacketNsec));
}
TEST_F(MDnsTest, NsecWithTransactionFromNetwork) {
scoped_ptr<MDnsTransaction> transaction_privet =
test_client_.CreateTransaction(
- dns_protocol::kTypeA, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypeA,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -951,30 +861,27 @@ TEST_F(MDnsTest, NsecWithTransactionFromNetwork) {
EXPECT_CALL(*this,
MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL));
- SimulatePacketReceive(kSamplePacketNsec,
- sizeof(kSamplePacketNsec));
+ SimulatePacketReceive(kSamplePacketNsec, sizeof(kSamplePacketNsec));
}
TEST_F(MDnsTest, NsecWithTransactionFromCache) {
// Force mDNS to listen.
StrictMock<MockListenerDelegate> delegate_irrelevant;
- scoped_ptr<MDnsListener> listener_irrelevant =
- test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local",
- &delegate_irrelevant);
+ scoped_ptr<MDnsListener> listener_irrelevant = test_client_.CreateListener(
+ dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_irrelevant);
listener_irrelevant->Start();
- SimulatePacketReceive(kSamplePacketNsec,
- sizeof(kSamplePacketNsec));
+ SimulatePacketReceive(kSamplePacketNsec, sizeof(kSamplePacketNsec));
EXPECT_CALL(*this,
MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL));
scoped_ptr<MDnsTransaction> transaction_privet_a =
test_client_.CreateTransaction(
- dns_protocol::kTypeA, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypeA,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -985,10 +892,10 @@ TEST_F(MDnsTest, NsecWithTransactionFromCache) {
scoped_ptr<MDnsTransaction> transaction_privet_ptr =
test_client_.CreateTransaction(
- dns_protocol::kTypePTR, "_privet._tcp.local",
- MDnsTransaction::QUERY_NETWORK |
- MDnsTransaction::QUERY_CACHE |
- MDnsTransaction::SINGLE_RESULT,
+ dns_protocol::kTypePTR,
+ "_privet._tcp.local",
+ MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE |
+ MDnsTransaction::SINGLE_RESULT,
base::Bind(&MDnsTest::MockableRecordCallback,
base::Unretained(this)));
@@ -999,9 +906,8 @@ TEST_F(MDnsTest, NsecWithTransactionFromCache) {
TEST_F(MDnsTest, NsecConflictRemoval) {
StrictMock<MockListenerDelegate> delegate_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet);
ASSERT_TRUE(listener_privet->Start());
@@ -1011,8 +917,7 @@ TEST_F(MDnsTest, NsecConflictRemoval) {
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _))
.WillOnce(SaveArg<1>(&record1));
- SimulatePacketReceive(kSamplePacketAPrivet,
- sizeof(kSamplePacketAPrivet));
+ SimulatePacketReceive(kSamplePacketAPrivet, sizeof(kSamplePacketAPrivet));
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _))
.WillOnce(SaveArg<1>(&record2));
@@ -1020,32 +925,28 @@ TEST_F(MDnsTest, NsecConflictRemoval) {
EXPECT_CALL(delegate_privet,
OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA));
- SimulatePacketReceive(kSamplePacketNsec,
- sizeof(kSamplePacketNsec));
+ SimulatePacketReceive(kSamplePacketNsec, sizeof(kSamplePacketNsec));
EXPECT_EQ(record1, record2);
}
-
TEST_F(MDnsTest, RefreshQuery) {
StrictMock<MockListenerDelegate> delegate_privet;
- scoped_ptr<MDnsListener> listener_privet =
- test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local",
- &delegate_privet);
+ scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener(
+ dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet);
listener_privet->SetActiveRefresh(true);
ASSERT_TRUE(listener_privet->Start());
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _));
- SimulatePacketReceive(kSamplePacketAPrivet,
- sizeof(kSamplePacketAPrivet));
+ SimulatePacketReceive(kSamplePacketAPrivet, sizeof(kSamplePacketAPrivet));
// Expecting 2 calls (one for ipv4 and one for ipv6) for each of the 2
// scheduled refresh queries.
- EXPECT_CALL(socket_factory_, OnSendTo(
- MakeString(kQueryPacketPrivetA, sizeof(kQueryPacketPrivetA))))
- .Times(4);
+ EXPECT_CALL(socket_factory_,
+ OnSendTo(MakeString(kQueryPacketPrivetA,
+ sizeof(kQueryPacketPrivetA)))).Times(4);
EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _));
@@ -1062,9 +963,7 @@ class SimpleMockSocketFactory : public MDnsSocketFactory {
sockets->swap(sockets_);
}
- void PushSocket(DatagramServerSocket* socket) {
- sockets_.push_back(socket);
- }
+ void PushSocket(DatagramServerSocket* socket) { sockets_.push_back(socket); }
private:
ScopedVector<DatagramServerSocket> sockets_;
@@ -1083,8 +982,7 @@ class MockMDnsConnectionDelegate : public MDnsConnection::Delegate {
class MDnsConnectionTest : public ::testing::Test {
public:
- MDnsConnectionTest() : connection_(&delegate_) {
- }
+ MDnsConnectionTest() : connection_(&delegate_) {}
protected:
// Follow successful connection initialization.
@@ -1095,9 +993,7 @@ class MDnsConnectionTest : public ::testing::Test {
factory_.PushSocket(socket_ipv4_);
}
- bool InitConnection() {
- return connection_.Init(&factory_);
- }
+ bool InitConnection() { return connection_.Init(&factory_); }
StrictMock<MockMDnsConnectionDelegate> delegate_;
@@ -1109,15 +1005,15 @@ class MDnsConnectionTest : public ::testing::Test {
};
TEST_F(MDnsConnectionTest, ReceiveSynchronous) {
- std::string sample_packet = MakeString(kSamplePacket1,
- sizeof(kSamplePacket1));
+ std::string sample_packet =
+ MakeString(kSamplePacket1, sizeof(kSamplePacket1));
socket_ipv6_->SetResponsePacket(sample_packet);
EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _))
.WillOnce(Return(ERR_IO_PENDING));
EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _))
.WillOnce(
- Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvNow))
+ Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvNow))
.WillOnce(Return(ERR_IO_PENDING));
EXPECT_CALL(delegate_, HandlePacketInternal(sample_packet));
@@ -1126,14 +1022,14 @@ TEST_F(MDnsConnectionTest, ReceiveSynchronous) {
}
TEST_F(MDnsConnectionTest, ReceiveAsynchronous) {
- std::string sample_packet = MakeString(kSamplePacket1,
- sizeof(kSamplePacket1));
+ std::string sample_packet =
+ MakeString(kSamplePacket1, sizeof(kSamplePacket1));
socket_ipv6_->SetResponsePacket(sample_packet);
EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _))
.WillOnce(Return(ERR_IO_PENDING));
EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _))
.WillOnce(
- Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvLater))
+ Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvLater))
.WillOnce(Return(ERR_IO_PENDING));
ASSERT_TRUE(InitConnection());
@@ -1144,8 +1040,8 @@ TEST_F(MDnsConnectionTest, ReceiveAsynchronous) {
}
TEST_F(MDnsConnectionTest, Send) {
- std::string sample_packet = MakeString(kSamplePacket1,
- sizeof(kSamplePacket1));
+ std::string sample_packet =
+ MakeString(kSamplePacket1, sizeof(kSamplePacket1));
scoped_refptr<IOBufferWithSize> buf(
new IOBufferWithSize(sizeof kSamplePacket1));
@@ -1172,7 +1068,7 @@ TEST_F(MDnsConnectionTest, Error) {
EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _))
.WillOnce(Return(ERR_IO_PENDING));
EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _))
- .WillOnce(DoAll(SaveArg<3>(&callback), Return(ERR_IO_PENDING)));
+ .WillOnce(DoAll(SaveArg<3>(&callback), Return(ERR_IO_PENDING)));
ASSERT_TRUE(InitConnection());

Powered by Google App Engine
This is Rietveld 408576698