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

Unified Diff: net/dns/mdns_client_unittest.cc

Issue 132693025: Add the ability for MDnsListener to actively refresh records (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « net/dns/mdns_client_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mdns_client_unittest.cc
diff --git a/net/dns/mdns_client_unittest.cc b/net/dns/mdns_client_unittest.cc
index 7ea4ac97448759a91bc3a1853c0374d8943bbe1f..24371c119e0c271c0acc2c15f2bcb74c43c22057 100644
--- a/net/dns/mdns_client_unittest.cc
+++ b/net/dns/mdns_client_unittest.cc
@@ -241,6 +241,25 @@ const uint8 kQueryPacketPrivet[] = {
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.
+};
+
const uint8 kSamplePacketAdditionalOnly[] = {
// Header
0x00, 0x00, // ID is zeroed out
@@ -303,8 +322,8 @@ const uint8 kSamplePacketAPrivet[] = {
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, 0x00, // TTL (4 bytes) is 5 seconds
+ 0x00, 0x05,
0x00, 0x04, // RDLENGTH is 4 bytes.
0xc0, 0x0c,
0x00, 0x02,
@@ -1008,6 +1027,31 @@ TEST_F(MDnsTest, NsecConflictRemoval) {
}
+TEST_F(MDnsTest, RefreshQuery) {
+ StrictMock<MockListenerDelegate> 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));
+
+ // Expecting 2 calls (one for ipv4 and one for ipv6) at 85% of the TTL and 2
+ // calls at 95% of the TTL.
szym 2014/01/29 19:08:39 nit: I'd remove the 85% and 95% numbers from this
Noam Samuel 2014/01/29 19:21:36 Done.
+ EXPECT_CALL(socket_factory_, OnSendTo(
+ MakeString(kQueryPacketPrivetA, sizeof(kQueryPacketPrivetA))))
+ .Times(4);
+
+ EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _));
+
+ RunFor(base::TimeDelta::FromSeconds(6));
+}
+
// Note: These tests assume that the ipv4 socket will always be created first.
// This is a simplifying assumption based on the way the code works now.
class SimpleMockSocketFactory : public MDnsSocketFactory {
« no previous file with comments | « net/dns/mdns_client_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698