| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <queue> | 5 #include <queue> |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/clock.h" |
| 10 #include "base/time/default_clock.h" |
| 11 #include "base/timer/mock_timer.h" |
| 9 #include "net/base/rand_callback.h" | 12 #include "net/base/rand_callback.h" |
| 10 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
| 11 #include "net/dns/mdns_client_impl.h" | 14 #include "net/dns/mdns_client_impl.h" |
| 12 #include "net/dns/mock_mdns_socket_factory.h" | 15 #include "net/dns/mock_mdns_socket_factory.h" |
| 13 #include "net/dns/record_rdata.h" | 16 #include "net/dns/record_rdata.h" |
| 14 #include "net/udp/udp_client_socket.h" | 17 #include "net/udp/udp_client_socket.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 20 |
| 18 using ::testing::Invoke; | 21 using ::testing::Invoke; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 0xc0, 0x14, // Pointer to "._tcp.local" | 218 0xc0, 0x14, // Pointer to "._tcp.local" |
| 216 0x00, 0x0c, // TYPE is PTR. | 219 0x00, 0x0c, // TYPE is PTR. |
| 217 0x00, 0x01, // CLASS is IN. | 220 0x00, 0x01, // CLASS is IN. |
| 218 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds. | 221 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds. |
| 219 0x24, 0x74, | 222 0x24, 0x74, |
| 220 0x00, 0x08, // RDLENGTH is 8 bytes. | 223 0x00, 0x08, // RDLENGTH is 8 bytes. |
| 221 0x05, 'z', 'z', 'z', 'z', 'z', | 224 0x05, 'z', 'z', 'z', 'z', 'z', |
| 222 0xc0, 0x32 | 225 0xc0, 0x32 |
| 223 }; | 226 }; |
| 224 | 227 |
| 228 const uint8 kSamplePacket3[] = { |
| 229 // Header |
| 230 0x00, 0x00, // ID is zeroed out |
| 231 0x81, 0x80, // Standard query response, RA, no error |
| 232 0x00, 0x00, // No questions (for simplicity) |
| 233 0x00, 0x02, // 2 RRs (answers) |
| 234 0x00, 0x00, // 0 authority RRs |
| 235 0x00, 0x00, // 0 additional RRs |
| 236 |
| 237 // Answer 1 |
| 238 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', // |
| 239 0x04, '_', 't', 'c', 'p', // |
| 240 0x05, 'l', 'o', 'c', 'a', 'l', // |
| 241 0x00, 0x00, 0x0c, // TYPE is PTR. |
| 242 0x00, 0x01, // CLASS is IN. |
| 243 0x00, 0x00, // TTL (4 bytes) is 1 second; |
| 244 0x00, 0x01, // |
| 245 0x00, 0x08, // RDLENGTH is 8 bytes. |
| 246 0x05, 'h', 'e', 'l', 'l', 'o', // |
| 247 0xc0, 0x0c, // |
| 248 |
| 249 // Answer 2 |
| 250 0x08, '_', 'p', 'r', 'i', 'n', 't', 'e', 'r', // |
| 251 0xc0, 0x14, // Pointer to "._tcp.local" |
| 252 0x00, 0x0c, // TYPE is PTR. |
| 253 0x00, 0x01, // CLASS is IN. |
| 254 0x00, 0x00, // TTL (4 bytes) is 3 seconds. |
| 255 0x00, 0x03, // |
| 256 0x00, 0x08, // RDLENGTH is 8 bytes. |
| 257 0x05, 'h', 'e', 'l', 'l', 'o', // |
| 258 0xc0, 0x32}; |
| 259 |
| 225 const uint8 kQueryPacketPrivet[] = { | 260 const uint8 kQueryPacketPrivet[] = { |
| 226 // Header | 261 // Header |
| 227 0x00, 0x00, // ID is zeroed out | 262 0x00, 0x00, // ID is zeroed out |
| 228 0x00, 0x00, // No flags. | 263 0x00, 0x00, // No flags. |
| 229 0x00, 0x01, // One question. | 264 0x00, 0x01, // One question. |
| 230 0x00, 0x00, // 0 RRs (answers) | 265 0x00, 0x00, // 0 RRs (answers) |
| 231 0x00, 0x00, // 0 authority RRs | 266 0x00, 0x00, // 0 authority RRs |
| 232 0x00, 0x00, // 0 additional RRs | 267 0x00, 0x00, // 0 additional RRs |
| 233 | 268 |
| 234 // Question | 269 // Question |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 const std::string& ptrdomain() { return ptrdomain_; } | 417 const std::string& ptrdomain() { return ptrdomain_; } |
| 383 int ttl() { return ttl_; } | 418 int ttl() { return ttl_; } |
| 384 | 419 |
| 385 private: | 420 private: |
| 386 bool set_; | 421 bool set_; |
| 387 std::string name_; | 422 std::string name_; |
| 388 std::string ptrdomain_; | 423 std::string ptrdomain_; |
| 389 int ttl_; | 424 int ttl_; |
| 390 }; | 425 }; |
| 391 | 426 |
| 427 class MockClock : public base::DefaultClock { |
| 428 public: |
| 429 MockClock() : base::DefaultClock() {} |
| 430 virtual ~MockClock() {} |
| 431 |
| 432 MOCK_METHOD0(Now, base::Time()); |
| 433 |
| 434 private: |
| 435 DISALLOW_COPY_AND_ASSIGN(MockClock); |
| 436 }; |
| 437 |
| 438 class MockTimer : public base::MockTimer { |
| 439 public: |
| 440 MockTimer() : base::MockTimer(false, false) {} |
| 441 ~MockTimer() {} |
| 442 |
| 443 void Start(const tracked_objects::Location& posted_from, |
| 444 base::TimeDelta delay, |
| 445 const base::Closure& user_task) { |
| 446 StartObserver(posted_from, delay, user_task); |
| 447 base::MockTimer::Start(posted_from, delay, user_task); |
| 448 } |
| 449 |
| 450 // StartObserver is invoked when MockTimer::Start() is called. |
| 451 // Does not replace the behavior of MockTimer::Start(). |
| 452 MOCK_METHOD3(StartObserver, |
| 453 void(const tracked_objects::Location& posted_from, |
| 454 base::TimeDelta delay, |
| 455 const base::Closure& user_task)); |
| 456 |
| 457 private: |
| 458 DISALLOW_COPY_AND_ASSIGN(MockTimer); |
| 459 }; |
| 460 |
| 461 } // namespace |
| 462 |
| 392 class MDnsTest : public ::testing::Test { | 463 class MDnsTest : public ::testing::Test { |
| 393 public: | 464 public: |
| 394 virtual void SetUp() override; | 465 void SetUp() override; |
| 395 void DeleteTransaction(); | 466 void DeleteTransaction(); |
| 396 void DeleteBothListeners(); | 467 void DeleteBothListeners(); |
| 397 void RunFor(base::TimeDelta time_period); | 468 void RunFor(base::TimeDelta time_period); |
| 398 void Stop(); | 469 void Stop(); |
| 399 | 470 |
| 400 MOCK_METHOD2(MockableRecordCallback, void(MDnsTransaction::Result result, | 471 MOCK_METHOD2(MockableRecordCallback, void(MDnsTransaction::Result result, |
| 401 const RecordParsed* record)); | 472 const RecordParsed* record)); |
| 402 | 473 |
| 403 MOCK_METHOD2(MockableRecordCallback2, void(MDnsTransaction::Result result, | 474 MOCK_METHOD2(MockableRecordCallback2, void(MDnsTransaction::Result result, |
| 404 const RecordParsed* record)); | 475 const RecordParsed* record)); |
| 405 | 476 |
| 406 | |
| 407 protected: | 477 protected: |
| 408 void ExpectPacket(const uint8* packet, unsigned size); | 478 void ExpectPacket(const uint8* packet, unsigned size); |
| 409 void SimulatePacketReceive(const uint8* packet, unsigned size); | 479 void SimulatePacketReceive(const uint8* packet, unsigned size); |
| 410 | 480 |
| 411 MDnsClientImpl test_client_; | 481 scoped_ptr<MDnsClientImpl> test_client_; |
| 412 IPEndPoint mdns_ipv4_endpoint_; | 482 IPEndPoint mdns_ipv4_endpoint_; |
| 413 StrictMock<MockMDnsSocketFactory> socket_factory_; | 483 StrictMock<MockMDnsSocketFactory> socket_factory_; |
| 414 | 484 |
| 415 // Transactions and listeners that can be deleted by class methods for | 485 // Transactions and listeners that can be deleted by class methods for |
| 416 // reentrancy tests. | 486 // reentrancy tests. |
| 417 scoped_ptr<MDnsTransaction> transaction_; | 487 scoped_ptr<MDnsTransaction> transaction_; |
| 418 scoped_ptr<MDnsListener> listener1_; | 488 scoped_ptr<MDnsListener> listener1_; |
| 419 scoped_ptr<MDnsListener> listener2_; | 489 scoped_ptr<MDnsListener> listener2_; |
| 420 }; | 490 }; |
| 421 | 491 |
| 422 class MockListenerDelegate : public MDnsListener::Delegate { | 492 class MockListenerDelegate : public MDnsListener::Delegate { |
| 423 public: | 493 public: |
| 424 MOCK_METHOD2(OnRecordUpdate, | 494 MOCK_METHOD2(OnRecordUpdate, |
| 425 void(MDnsListener::UpdateType update, | 495 void(MDnsListener::UpdateType update, |
| 426 const RecordParsed* records)); | 496 const RecordParsed* records)); |
| 427 MOCK_METHOD2(OnNsecRecord, void(const std::string&, unsigned)); | 497 MOCK_METHOD2(OnNsecRecord, void(const std::string&, unsigned)); |
| 428 MOCK_METHOD0(OnCachePurged, void()); | 498 MOCK_METHOD0(OnCachePurged, void()); |
| 429 }; | 499 }; |
| 430 | 500 |
| 431 void MDnsTest::SetUp() { | 501 void MDnsTest::SetUp() { |
| 432 test_client_.StartListening(&socket_factory_); | 502 test_client_.reset(new MDnsClientImpl()); |
| 503 test_client_->StartListening(&socket_factory_); |
| 433 } | 504 } |
| 434 | 505 |
| 435 void MDnsTest::SimulatePacketReceive(const uint8* packet, unsigned size) { | 506 void MDnsTest::SimulatePacketReceive(const uint8* packet, unsigned size) { |
| 436 socket_factory_.SimulateReceive(packet, size); | 507 socket_factory_.SimulateReceive(packet, size); |
| 437 } | 508 } |
| 438 | 509 |
| 439 void MDnsTest::ExpectPacket(const uint8* packet, unsigned size) { | 510 void MDnsTest::ExpectPacket(const uint8* packet, unsigned size) { |
| 440 EXPECT_CALL(socket_factory_, OnSendTo(MakeString(packet, size))) | 511 EXPECT_CALL(socket_factory_, OnSendTo(MakeString(packet, size))) |
| 441 .Times(2); | 512 .Times(2); |
| 442 } | 513 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 464 base::MessageLoop::current()->Quit(); | 535 base::MessageLoop::current()->Quit(); |
| 465 } | 536 } |
| 466 | 537 |
| 467 TEST_F(MDnsTest, PassiveListeners) { | 538 TEST_F(MDnsTest, PassiveListeners) { |
| 468 StrictMock<MockListenerDelegate> delegate_privet; | 539 StrictMock<MockListenerDelegate> delegate_privet; |
| 469 StrictMock<MockListenerDelegate> delegate_printer; | 540 StrictMock<MockListenerDelegate> delegate_printer; |
| 470 | 541 |
| 471 PtrRecordCopyContainer record_privet; | 542 PtrRecordCopyContainer record_privet; |
| 472 PtrRecordCopyContainer record_printer; | 543 PtrRecordCopyContainer record_printer; |
| 473 | 544 |
| 474 scoped_ptr<MDnsListener> listener_privet = | 545 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 475 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 546 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 476 &delegate_privet); | 547 scoped_ptr<MDnsListener> listener_printer = test_client_->CreateListener( |
| 477 scoped_ptr<MDnsListener> listener_printer = | 548 dns_protocol::kTypePTR, "_printer._tcp.local", &delegate_printer); |
| 478 test_client_.CreateListener(dns_protocol::kTypePTR, "_printer._tcp.local", | |
| 479 &delegate_printer); | |
| 480 | 549 |
| 481 ASSERT_TRUE(listener_privet->Start()); | 550 ASSERT_TRUE(listener_privet->Start()); |
| 482 ASSERT_TRUE(listener_printer->Start()); | 551 ASSERT_TRUE(listener_printer->Start()); |
| 483 | 552 |
| 484 // Send the same packet twice to ensure no records are double-counted. | 553 // Send the same packet twice to ensure no records are double-counted. |
| 485 | 554 |
| 486 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 555 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 487 .Times(Exactly(1)) | 556 .Times(Exactly(1)) |
| 488 .WillOnce(Invoke( | 557 .WillOnce(Invoke( |
| 489 &record_privet, | 558 &record_privet, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 508 listener_privet.reset(); | 577 listener_privet.reset(); |
| 509 listener_printer.reset(); | 578 listener_printer.reset(); |
| 510 } | 579 } |
| 511 | 580 |
| 512 TEST_F(MDnsTest, PassiveListenersCacheCleanup) { | 581 TEST_F(MDnsTest, PassiveListenersCacheCleanup) { |
| 513 StrictMock<MockListenerDelegate> delegate_privet; | 582 StrictMock<MockListenerDelegate> delegate_privet; |
| 514 | 583 |
| 515 PtrRecordCopyContainer record_privet; | 584 PtrRecordCopyContainer record_privet; |
| 516 PtrRecordCopyContainer record_privet2; | 585 PtrRecordCopyContainer record_privet2; |
| 517 | 586 |
| 518 scoped_ptr<MDnsListener> listener_privet = | 587 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 519 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 588 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 520 &delegate_privet); | |
| 521 | 589 |
| 522 ASSERT_TRUE(listener_privet->Start()); | 590 ASSERT_TRUE(listener_privet->Start()); |
| 523 | 591 |
| 524 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 592 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 525 .Times(Exactly(1)) | 593 .Times(Exactly(1)) |
| 526 .WillOnce(Invoke( | 594 .WillOnce(Invoke( |
| 527 &record_privet, | 595 &record_privet, |
| 528 &PtrRecordCopyContainer::SaveWithDummyArg)); | 596 &PtrRecordCopyContainer::SaveWithDummyArg)); |
| 529 | 597 |
| 530 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 598 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 531 | 599 |
| 532 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", | 600 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", |
| 533 "hello._privet._tcp.local")); | 601 "hello._privet._tcp.local")); |
| 534 | 602 |
| 535 // Expect record is removed when its TTL expires. | 603 // Expect record is removed when its TTL expires. |
| 536 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) | 604 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) |
| 537 .Times(Exactly(1)) | 605 .Times(Exactly(1)) |
| 538 .WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::Stop), | 606 .WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::Stop), |
| 539 Invoke(&record_privet2, | 607 Invoke(&record_privet2, |
| 540 &PtrRecordCopyContainer::SaveWithDummyArg))); | 608 &PtrRecordCopyContainer::SaveWithDummyArg))); |
| 541 | 609 |
| 542 RunFor(base::TimeDelta::FromSeconds(record_privet.ttl() + 1)); | 610 RunFor(base::TimeDelta::FromSeconds(record_privet.ttl() + 1)); |
| 543 | 611 |
| 544 EXPECT_TRUE(record_privet2.IsRecordWith("_privet._tcp.local", | 612 EXPECT_TRUE(record_privet2.IsRecordWith("_privet._tcp.local", |
| 545 "hello._privet._tcp.local")); | 613 "hello._privet._tcp.local")); |
| 546 } | 614 } |
| 547 | 615 |
| 616 // Ensure that the cleanup task scheduler won't schedule cleanup tasks in the |
| 617 // past if the system clock creeps past the expiration time while in the |
| 618 // cleanup dispatcher. |
| 619 TEST_F(MDnsTest, CacheCleanupWithShortTTL) { |
| 620 // Use a nonzero starting time as a base. |
| 621 base::Time start_time = base::Time() + base::TimeDelta::FromSeconds(1); |
| 622 |
| 623 MockClock* clock = new MockClock; |
| 624 MockTimer* timer = new MockTimer; |
| 625 |
| 626 test_client_.reset( |
| 627 new MDnsClientImpl(make_scoped_ptr(clock), make_scoped_ptr(timer))); |
| 628 test_client_->StartListening(&socket_factory_); |
| 629 |
| 630 EXPECT_CALL(*timer, StartObserver(_, _, _)).Times(1); |
| 631 EXPECT_CALL(*clock, Now()) |
| 632 .Times(3) |
| 633 .WillRepeatedly(Return(start_time)) |
| 634 .RetiresOnSaturation(); |
| 635 |
| 636 // Receive two records with different TTL values. |
| 637 // TTL(privet)=1.0s |
| 638 // TTL(printer)=3.0s |
| 639 StrictMock<MockListenerDelegate> delegate_privet; |
| 640 StrictMock<MockListenerDelegate> delegate_printer; |
| 641 |
| 642 PtrRecordCopyContainer record_privet; |
| 643 PtrRecordCopyContainer record_printer; |
| 644 |
| 645 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 646 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 647 scoped_ptr<MDnsListener> listener_printer = test_client_->CreateListener( |
| 648 dns_protocol::kTypePTR, "_printer._tcp.local", &delegate_printer); |
| 649 |
| 650 ASSERT_TRUE(listener_privet->Start()); |
| 651 ASSERT_TRUE(listener_printer->Start()); |
| 652 |
| 653 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 654 .Times(Exactly(1)); |
| 655 EXPECT_CALL(delegate_printer, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 656 .Times(Exactly(1)); |
| 657 |
| 658 SimulatePacketReceive(kSamplePacket3, sizeof(kSamplePacket3)); |
| 659 |
| 660 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) |
| 661 .Times(Exactly(1)); |
| 662 |
| 663 // Set the clock to 2.0s, which should clean up the 'privet' record, but not |
| 664 // the printer. The mock clock will change Now() mid-execution from 2s to 4s. |
| 665 // Note: expectations are FILO-ordered -- t+2 seconds is returned, then t+4. |
| 666 EXPECT_CALL(*clock, Now()) |
| 667 .WillOnce(Return(start_time + base::TimeDelta::FromSeconds(4))) |
| 668 .RetiresOnSaturation(); |
| 669 EXPECT_CALL(*clock, Now()) |
| 670 .WillOnce(Return(start_time + base::TimeDelta::FromSeconds(2))) |
| 671 .RetiresOnSaturation(); |
| 672 |
| 673 EXPECT_CALL(*timer, StartObserver(_, base::TimeDelta(), _)); |
| 674 |
| 675 timer->Fire(); |
| 676 } |
| 677 |
| 548 TEST_F(MDnsTest, MalformedPacket) { | 678 TEST_F(MDnsTest, MalformedPacket) { |
| 549 StrictMock<MockListenerDelegate> delegate_printer; | 679 StrictMock<MockListenerDelegate> delegate_printer; |
| 550 | 680 |
| 551 PtrRecordCopyContainer record_printer; | 681 PtrRecordCopyContainer record_printer; |
| 552 | 682 |
| 553 scoped_ptr<MDnsListener> listener_printer = | 683 scoped_ptr<MDnsListener> listener_printer = test_client_->CreateListener( |
| 554 test_client_.CreateListener(dns_protocol::kTypePTR, "_printer._tcp.local", | 684 dns_protocol::kTypePTR, "_printer._tcp.local", &delegate_printer); |
| 555 &delegate_printer); | |
| 556 | 685 |
| 557 ASSERT_TRUE(listener_printer->Start()); | 686 ASSERT_TRUE(listener_printer->Start()); |
| 558 | 687 |
| 559 EXPECT_CALL(delegate_printer, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 688 EXPECT_CALL(delegate_printer, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 560 .Times(Exactly(1)) | 689 .Times(Exactly(1)) |
| 561 .WillOnce(Invoke( | 690 .WillOnce(Invoke( |
| 562 &record_printer, | 691 &record_printer, |
| 563 &PtrRecordCopyContainer::SaveWithDummyArg)); | 692 &PtrRecordCopyContainer::SaveWithDummyArg)); |
| 564 | 693 |
| 565 // First, send unsalvagable packet to ensure we can deal with it. | 694 // First, send unsalvagable packet to ensure we can deal with it. |
| 566 SimulatePacketReceive(kCorruptedPacketUnsalvagable, | 695 SimulatePacketReceive(kCorruptedPacketUnsalvagable, |
| 567 sizeof(kCorruptedPacketUnsalvagable)); | 696 sizeof(kCorruptedPacketUnsalvagable)); |
| 568 | 697 |
| 569 // Regression test: send a packet where the question cannot be read. | 698 // Regression test: send a packet where the question cannot be read. |
| 570 SimulatePacketReceive(kCorruptedPacketBadQuestion, | 699 SimulatePacketReceive(kCorruptedPacketBadQuestion, |
| 571 sizeof(kCorruptedPacketBadQuestion)); | 700 sizeof(kCorruptedPacketBadQuestion)); |
| 572 | 701 |
| 573 // Then send salvagable packet to ensure we can extract useful records. | 702 // Then send salvagable packet to ensure we can extract useful records. |
| 574 SimulatePacketReceive(kCorruptedPacketSalvagable, | 703 SimulatePacketReceive(kCorruptedPacketSalvagable, |
| 575 sizeof(kCorruptedPacketSalvagable)); | 704 sizeof(kCorruptedPacketSalvagable)); |
| 576 | 705 |
| 577 EXPECT_TRUE(record_printer.IsRecordWith("_printer._tcp.local", | 706 EXPECT_TRUE(record_printer.IsRecordWith("_printer._tcp.local", |
| 578 "hello._printer._tcp.local")); | 707 "hello._printer._tcp.local")); |
| 579 } | 708 } |
| 580 | 709 |
| 581 TEST_F(MDnsTest, TransactionWithEmptyCache) { | 710 TEST_F(MDnsTest, TransactionWithEmptyCache) { |
| 582 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); | 711 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); |
| 583 | 712 |
| 584 scoped_ptr<MDnsTransaction> transaction_privet = | 713 scoped_ptr<MDnsTransaction> transaction_privet = |
| 585 test_client_.CreateTransaction( | 714 test_client_->CreateTransaction( |
| 586 dns_protocol::kTypePTR, "_privet._tcp.local", | 715 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 587 MDnsTransaction::QUERY_NETWORK | | 716 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 588 MDnsTransaction::QUERY_CACHE | | 717 MDnsTransaction::SINGLE_RESULT, |
| 589 MDnsTransaction::SINGLE_RESULT, | |
| 590 base::Bind(&MDnsTest::MockableRecordCallback, | 718 base::Bind(&MDnsTest::MockableRecordCallback, |
| 591 base::Unretained(this))); | 719 base::Unretained(this))); |
| 592 | 720 |
| 593 ASSERT_TRUE(transaction_privet->Start()); | 721 ASSERT_TRUE(transaction_privet->Start()); |
| 594 | 722 |
| 595 PtrRecordCopyContainer record_privet; | 723 PtrRecordCopyContainer record_privet; |
| 596 | 724 |
| 597 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) | 725 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) |
| 598 .Times(Exactly(1)) | 726 .Times(Exactly(1)) |
| 599 .WillOnce(Invoke(&record_privet, | 727 .WillOnce(Invoke(&record_privet, |
| 600 &PtrRecordCopyContainer::SaveWithDummyArg)); | 728 &PtrRecordCopyContainer::SaveWithDummyArg)); |
| 601 | 729 |
| 602 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 730 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 603 | 731 |
| 604 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", | 732 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", |
| 605 "hello._privet._tcp.local")); | 733 "hello._privet._tcp.local")); |
| 606 } | 734 } |
| 607 | 735 |
| 608 TEST_F(MDnsTest, TransactionCacheOnlyNoResult) { | 736 TEST_F(MDnsTest, TransactionCacheOnlyNoResult) { |
| 609 scoped_ptr<MDnsTransaction> transaction_privet = | 737 scoped_ptr<MDnsTransaction> transaction_privet = |
| 610 test_client_.CreateTransaction( | 738 test_client_->CreateTransaction( |
| 611 dns_protocol::kTypePTR, "_privet._tcp.local", | 739 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 612 MDnsTransaction::QUERY_CACHE | | 740 MDnsTransaction::QUERY_CACHE | MDnsTransaction::SINGLE_RESULT, |
| 613 MDnsTransaction::SINGLE_RESULT, | |
| 614 base::Bind(&MDnsTest::MockableRecordCallback, | 741 base::Bind(&MDnsTest::MockableRecordCallback, |
| 615 base::Unretained(this))); | 742 base::Unretained(this))); |
| 616 | 743 |
| 617 EXPECT_CALL(*this, | 744 EXPECT_CALL(*this, |
| 618 MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, _)) | 745 MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, _)) |
| 619 .Times(Exactly(1)); | 746 .Times(Exactly(1)); |
| 620 | 747 |
| 621 ASSERT_TRUE(transaction_privet->Start()); | 748 ASSERT_TRUE(transaction_privet->Start()); |
| 622 } | 749 } |
| 623 | 750 |
| 624 TEST_F(MDnsTest, TransactionWithCache) { | 751 TEST_F(MDnsTest, TransactionWithCache) { |
| 625 // Listener to force the client to listen | 752 // Listener to force the client to listen |
| 626 StrictMock<MockListenerDelegate> delegate_irrelevant; | 753 StrictMock<MockListenerDelegate> delegate_irrelevant; |
| 627 scoped_ptr<MDnsListener> listener_irrelevant = | 754 scoped_ptr<MDnsListener> listener_irrelevant = test_client_->CreateListener( |
| 628 test_client_.CreateListener(dns_protocol::kTypeA, | 755 dns_protocol::kTypeA, "codereview.chromium.local", &delegate_irrelevant); |
| 629 "codereview.chromium.local", | |
| 630 &delegate_irrelevant); | |
| 631 | 756 |
| 632 ASSERT_TRUE(listener_irrelevant->Start()); | 757 ASSERT_TRUE(listener_irrelevant->Start()); |
| 633 | 758 |
| 634 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 759 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 635 | 760 |
| 636 | 761 |
| 637 PtrRecordCopyContainer record_privet; | 762 PtrRecordCopyContainer record_privet; |
| 638 | 763 |
| 639 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) | 764 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) |
| 640 .WillOnce(Invoke(&record_privet, | 765 .WillOnce(Invoke(&record_privet, |
| 641 &PtrRecordCopyContainer::SaveWithDummyArg)); | 766 &PtrRecordCopyContainer::SaveWithDummyArg)); |
| 642 | 767 |
| 643 scoped_ptr<MDnsTransaction> transaction_privet = | 768 scoped_ptr<MDnsTransaction> transaction_privet = |
| 644 test_client_.CreateTransaction( | 769 test_client_->CreateTransaction( |
| 645 dns_protocol::kTypePTR, "_privet._tcp.local", | 770 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 646 MDnsTransaction::QUERY_NETWORK | | 771 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 647 MDnsTransaction::QUERY_CACHE | | 772 MDnsTransaction::SINGLE_RESULT, |
| 648 MDnsTransaction::SINGLE_RESULT, | |
| 649 base::Bind(&MDnsTest::MockableRecordCallback, | 773 base::Bind(&MDnsTest::MockableRecordCallback, |
| 650 base::Unretained(this))); | 774 base::Unretained(this))); |
| 651 | 775 |
| 652 ASSERT_TRUE(transaction_privet->Start()); | 776 ASSERT_TRUE(transaction_privet->Start()); |
| 653 | 777 |
| 654 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", | 778 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", |
| 655 "hello._privet._tcp.local")); | 779 "hello._privet._tcp.local")); |
| 656 } | 780 } |
| 657 | 781 |
| 658 TEST_F(MDnsTest, AdditionalRecords) { | 782 TEST_F(MDnsTest, AdditionalRecords) { |
| 659 StrictMock<MockListenerDelegate> delegate_privet; | 783 StrictMock<MockListenerDelegate> delegate_privet; |
| 660 | 784 |
| 661 PtrRecordCopyContainer record_privet; | 785 PtrRecordCopyContainer record_privet; |
| 662 | 786 |
| 663 scoped_ptr<MDnsListener> listener_privet = | 787 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 664 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 788 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 665 &delegate_privet); | |
| 666 | 789 |
| 667 ASSERT_TRUE(listener_privet->Start()); | 790 ASSERT_TRUE(listener_privet->Start()); |
| 668 | 791 |
| 669 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 792 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 670 .Times(Exactly(1)) | 793 .Times(Exactly(1)) |
| 671 .WillOnce(Invoke( | 794 .WillOnce(Invoke( |
| 672 &record_privet, | 795 &record_privet, |
| 673 &PtrRecordCopyContainer::SaveWithDummyArg)); | 796 &PtrRecordCopyContainer::SaveWithDummyArg)); |
| 674 | 797 |
| 675 SimulatePacketReceive(kSamplePacketAdditionalOnly, | 798 SimulatePacketReceive(kSamplePacketAdditionalOnly, |
| 676 sizeof(kSamplePacketAdditionalOnly)); | 799 sizeof(kSamplePacketAdditionalOnly)); |
| 677 | 800 |
| 678 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", | 801 EXPECT_TRUE(record_privet.IsRecordWith("_privet._tcp.local", |
| 679 "hello._privet._tcp.local")); | 802 "hello._privet._tcp.local")); |
| 680 } | 803 } |
| 681 | 804 |
| 682 TEST_F(MDnsTest, TransactionTimeout) { | 805 TEST_F(MDnsTest, TransactionTimeout) { |
| 683 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); | 806 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); |
| 684 | 807 |
| 685 scoped_ptr<MDnsTransaction> transaction_privet = | 808 scoped_ptr<MDnsTransaction> transaction_privet = |
| 686 test_client_.CreateTransaction( | 809 test_client_->CreateTransaction( |
| 687 dns_protocol::kTypePTR, "_privet._tcp.local", | 810 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 688 MDnsTransaction::QUERY_NETWORK | | 811 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 689 MDnsTransaction::QUERY_CACHE | | 812 MDnsTransaction::SINGLE_RESULT, |
| 690 MDnsTransaction::SINGLE_RESULT, | |
| 691 base::Bind(&MDnsTest::MockableRecordCallback, | 813 base::Bind(&MDnsTest::MockableRecordCallback, |
| 692 base::Unretained(this))); | 814 base::Unretained(this))); |
| 693 | 815 |
| 694 ASSERT_TRUE(transaction_privet->Start()); | 816 ASSERT_TRUE(transaction_privet->Start()); |
| 695 | 817 |
| 696 EXPECT_CALL(*this, | 818 EXPECT_CALL(*this, |
| 697 MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, NULL)) | 819 MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, NULL)) |
| 698 .Times(Exactly(1)) | 820 .Times(Exactly(1)) |
| 699 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::Stop)); | 821 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::Stop)); |
| 700 | 822 |
| 701 RunFor(base::TimeDelta::FromSeconds(4)); | 823 RunFor(base::TimeDelta::FromSeconds(4)); |
| 702 } | 824 } |
| 703 | 825 |
| 704 TEST_F(MDnsTest, TransactionMultipleRecords) { | 826 TEST_F(MDnsTest, TransactionMultipleRecords) { |
| 705 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); | 827 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); |
| 706 | 828 |
| 707 scoped_ptr<MDnsTransaction> transaction_privet = | 829 scoped_ptr<MDnsTransaction> transaction_privet = |
| 708 test_client_.CreateTransaction( | 830 test_client_->CreateTransaction( |
| 709 dns_protocol::kTypePTR, "_privet._tcp.local", | 831 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 710 MDnsTransaction::QUERY_NETWORK | | 832 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE, |
| 711 MDnsTransaction::QUERY_CACHE , | |
| 712 base::Bind(&MDnsTest::MockableRecordCallback, | 833 base::Bind(&MDnsTest::MockableRecordCallback, |
| 713 base::Unretained(this))); | 834 base::Unretained(this))); |
| 714 | 835 |
| 715 ASSERT_TRUE(transaction_privet->Start()); | 836 ASSERT_TRUE(transaction_privet->Start()); |
| 716 | 837 |
| 717 PtrRecordCopyContainer record_privet; | 838 PtrRecordCopyContainer record_privet; |
| 718 PtrRecordCopyContainer record_privet2; | 839 PtrRecordCopyContainer record_privet2; |
| 719 | 840 |
| 720 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) | 841 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) |
| 721 .Times(Exactly(2)) | 842 .Times(Exactly(2)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 735 | 856 |
| 736 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_DONE, NULL)) | 857 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_DONE, NULL)) |
| 737 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::Stop)); | 858 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::Stop)); |
| 738 | 859 |
| 739 RunFor(base::TimeDelta::FromSeconds(4)); | 860 RunFor(base::TimeDelta::FromSeconds(4)); |
| 740 } | 861 } |
| 741 | 862 |
| 742 TEST_F(MDnsTest, TransactionReentrantDelete) { | 863 TEST_F(MDnsTest, TransactionReentrantDelete) { |
| 743 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); | 864 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); |
| 744 | 865 |
| 745 transaction_ = test_client_.CreateTransaction( | 866 transaction_ = test_client_->CreateTransaction( |
| 746 dns_protocol::kTypePTR, "_privet._tcp.local", | 867 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 747 MDnsTransaction::QUERY_NETWORK | | 868 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 748 MDnsTransaction::QUERY_CACHE | | 869 MDnsTransaction::SINGLE_RESULT, |
| 749 MDnsTransaction::SINGLE_RESULT, | 870 base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this))); |
| 750 base::Bind(&MDnsTest::MockableRecordCallback, | |
| 751 base::Unretained(this))); | |
| 752 | 871 |
| 753 ASSERT_TRUE(transaction_->Start()); | 872 ASSERT_TRUE(transaction_->Start()); |
| 754 | 873 |
| 755 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, | 874 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_NO_RESULTS, |
| 756 NULL)) | 875 NULL)) |
| 757 .Times(Exactly(1)) | 876 .Times(Exactly(1)) |
| 758 .WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::DeleteTransaction), | 877 .WillOnce(DoAll(InvokeWithoutArgs(this, &MDnsTest::DeleteTransaction), |
| 759 InvokeWithoutArgs(this, &MDnsTest::Stop))); | 878 InvokeWithoutArgs(this, &MDnsTest::Stop))); |
| 760 | 879 |
| 761 RunFor(base::TimeDelta::FromSeconds(4)); | 880 RunFor(base::TimeDelta::FromSeconds(4)); |
| 762 | 881 |
| 763 EXPECT_EQ(NULL, transaction_.get()); | 882 EXPECT_EQ(NULL, transaction_.get()); |
| 764 } | 883 } |
| 765 | 884 |
| 766 TEST_F(MDnsTest, TransactionReentrantDeleteFromCache) { | 885 TEST_F(MDnsTest, TransactionReentrantDeleteFromCache) { |
| 767 StrictMock<MockListenerDelegate> delegate_irrelevant; | 886 StrictMock<MockListenerDelegate> delegate_irrelevant; |
| 768 scoped_ptr<MDnsListener> listener_irrelevant = test_client_.CreateListener( | 887 scoped_ptr<MDnsListener> listener_irrelevant = test_client_->CreateListener( |
| 769 dns_protocol::kTypeA, "codereview.chromium.local", | 888 dns_protocol::kTypeA, "codereview.chromium.local", &delegate_irrelevant); |
| 770 &delegate_irrelevant); | |
| 771 ASSERT_TRUE(listener_irrelevant->Start()); | 889 ASSERT_TRUE(listener_irrelevant->Start()); |
| 772 | 890 |
| 773 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 891 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 774 | 892 |
| 775 transaction_ = test_client_.CreateTransaction( | 893 transaction_ = test_client_->CreateTransaction( |
| 776 dns_protocol::kTypePTR, "_privet._tcp.local", | 894 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 777 MDnsTransaction::QUERY_NETWORK | | 895 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE, |
| 778 MDnsTransaction::QUERY_CACHE, | 896 base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this))); |
| 779 base::Bind(&MDnsTest::MockableRecordCallback, | |
| 780 base::Unretained(this))); | |
| 781 | 897 |
| 782 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) | 898 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, _)) |
| 783 .Times(Exactly(1)) | 899 .Times(Exactly(1)) |
| 784 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::DeleteTransaction)); | 900 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::DeleteTransaction)); |
| 785 | 901 |
| 786 ASSERT_TRUE(transaction_->Start()); | 902 ASSERT_TRUE(transaction_->Start()); |
| 787 | 903 |
| 788 EXPECT_EQ(NULL, transaction_.get()); | 904 EXPECT_EQ(NULL, transaction_.get()); |
| 789 } | 905 } |
| 790 | 906 |
| 791 TEST_F(MDnsTest, TransactionReentrantCacheLookupStart) { | 907 TEST_F(MDnsTest, TransactionReentrantCacheLookupStart) { |
| 792 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); | 908 ExpectPacket(kQueryPacketPrivet, sizeof(kQueryPacketPrivet)); |
| 793 | 909 |
| 794 scoped_ptr<MDnsTransaction> transaction1 = | 910 scoped_ptr<MDnsTransaction> transaction1 = test_client_->CreateTransaction( |
| 795 test_client_.CreateTransaction( | 911 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 796 dns_protocol::kTypePTR, "_privet._tcp.local", | 912 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 797 MDnsTransaction::QUERY_NETWORK | | |
| 798 MDnsTransaction::QUERY_CACHE | | |
| 799 MDnsTransaction::SINGLE_RESULT, | 913 MDnsTransaction::SINGLE_RESULT, |
| 800 base::Bind(&MDnsTest::MockableRecordCallback, | 914 base::Bind(&MDnsTest::MockableRecordCallback, base::Unretained(this))); |
| 801 base::Unretained(this))); | |
| 802 | 915 |
| 803 scoped_ptr<MDnsTransaction> transaction2 = | 916 scoped_ptr<MDnsTransaction> transaction2 = test_client_->CreateTransaction( |
| 804 test_client_.CreateTransaction( | 917 dns_protocol::kTypePTR, "_printer._tcp.local", |
| 805 dns_protocol::kTypePTR, "_printer._tcp.local", | 918 MDnsTransaction::QUERY_CACHE | MDnsTransaction::SINGLE_RESULT, |
| 806 MDnsTransaction::QUERY_CACHE | | 919 base::Bind(&MDnsTest::MockableRecordCallback2, base::Unretained(this))); |
| 807 MDnsTransaction::SINGLE_RESULT, | |
| 808 base::Bind(&MDnsTest::MockableRecordCallback2, | |
| 809 base::Unretained(this))); | |
| 810 | 920 |
| 811 EXPECT_CALL(*this, MockableRecordCallback2(MDnsTransaction::RESULT_RECORD, | 921 EXPECT_CALL(*this, MockableRecordCallback2(MDnsTransaction::RESULT_RECORD, |
| 812 _)) | 922 _)) |
| 813 .Times(Exactly(1)); | 923 .Times(Exactly(1)); |
| 814 | 924 |
| 815 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, | 925 EXPECT_CALL(*this, MockableRecordCallback(MDnsTransaction::RESULT_RECORD, |
| 816 _)) | 926 _)) |
| 817 .Times(Exactly(1)) | 927 .Times(Exactly(1)) |
| 818 .WillOnce(IgnoreResult(InvokeWithoutArgs(transaction2.get(), | 928 .WillOnce(IgnoreResult(InvokeWithoutArgs(transaction2.get(), |
| 819 &MDnsTransaction::Start))); | 929 &MDnsTransaction::Start))); |
| 820 | 930 |
| 821 ASSERT_TRUE(transaction1->Start()); | 931 ASSERT_TRUE(transaction1->Start()); |
| 822 | 932 |
| 823 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 933 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 824 } | 934 } |
| 825 | 935 |
| 826 TEST_F(MDnsTest, GoodbyePacketNotification) { | 936 TEST_F(MDnsTest, GoodbyePacketNotification) { |
| 827 StrictMock<MockListenerDelegate> delegate_privet; | 937 StrictMock<MockListenerDelegate> delegate_privet; |
| 828 | 938 |
| 829 scoped_ptr<MDnsListener> listener_privet = test_client_.CreateListener( | 939 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 830 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); | 940 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 831 ASSERT_TRUE(listener_privet->Start()); | 941 ASSERT_TRUE(listener_privet->Start()); |
| 832 | 942 |
| 833 SimulatePacketReceive(kSamplePacketGoodbye, sizeof(kSamplePacketGoodbye)); | 943 SimulatePacketReceive(kSamplePacketGoodbye, sizeof(kSamplePacketGoodbye)); |
| 834 | 944 |
| 835 RunFor(base::TimeDelta::FromSeconds(2)); | 945 RunFor(base::TimeDelta::FromSeconds(2)); |
| 836 } | 946 } |
| 837 | 947 |
| 838 TEST_F(MDnsTest, GoodbyePacketRemoval) { | 948 TEST_F(MDnsTest, GoodbyePacketRemoval) { |
| 839 StrictMock<MockListenerDelegate> delegate_privet; | 949 StrictMock<MockListenerDelegate> delegate_privet; |
| 840 | 950 |
| 841 scoped_ptr<MDnsListener> listener_privet = | 951 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 842 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 952 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 843 &delegate_privet); | |
| 844 ASSERT_TRUE(listener_privet->Start()); | 953 ASSERT_TRUE(listener_privet->Start()); |
| 845 | 954 |
| 846 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 955 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 847 .Times(Exactly(1)); | 956 .Times(Exactly(1)); |
| 848 | 957 |
| 849 SimulatePacketReceive(kSamplePacket2, sizeof(kSamplePacket2)); | 958 SimulatePacketReceive(kSamplePacket2, sizeof(kSamplePacket2)); |
| 850 | 959 |
| 851 SimulatePacketReceive(kSamplePacketGoodbye, sizeof(kSamplePacketGoodbye)); | 960 SimulatePacketReceive(kSamplePacketGoodbye, sizeof(kSamplePacketGoodbye)); |
| 852 | 961 |
| 853 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) | 962 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) |
| 854 .Times(Exactly(1)); | 963 .Times(Exactly(1)); |
| 855 | 964 |
| 856 RunFor(base::TimeDelta::FromSeconds(2)); | 965 RunFor(base::TimeDelta::FromSeconds(2)); |
| 857 } | 966 } |
| 858 | 967 |
| 859 // In order to reliably test reentrant listener deletes, we create two listeners | 968 // In order to reliably test reentrant listener deletes, we create two listeners |
| 860 // and have each of them delete both, so we're guaranteed to try and deliver a | 969 // and have each of them delete both, so we're guaranteed to try and deliver a |
| 861 // callback to at least one deleted listener. | 970 // callback to at least one deleted listener. |
| 862 | 971 |
| 863 TEST_F(MDnsTest, ListenerReentrantDelete) { | 972 TEST_F(MDnsTest, ListenerReentrantDelete) { |
| 864 StrictMock<MockListenerDelegate> delegate_privet; | 973 StrictMock<MockListenerDelegate> delegate_privet; |
| 865 | 974 |
| 866 listener1_ = test_client_.CreateListener(dns_protocol::kTypePTR, | 975 listener1_ = test_client_->CreateListener( |
| 867 "_privet._tcp.local", | 976 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 868 &delegate_privet); | |
| 869 | 977 |
| 870 listener2_ = test_client_.CreateListener(dns_protocol::kTypePTR, | 978 listener2_ = test_client_->CreateListener( |
| 871 "_privet._tcp.local", | 979 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet); |
| 872 &delegate_privet); | |
| 873 | 980 |
| 874 ASSERT_TRUE(listener1_->Start()); | 981 ASSERT_TRUE(listener1_->Start()); |
| 875 | 982 |
| 876 ASSERT_TRUE(listener2_->Start()); | 983 ASSERT_TRUE(listener2_->Start()); |
| 877 | 984 |
| 878 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 985 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 879 .Times(Exactly(1)) | 986 .Times(Exactly(1)) |
| 880 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::DeleteBothListeners)); | 987 .WillOnce(InvokeWithoutArgs(this, &MDnsTest::DeleteBothListeners)); |
| 881 | 988 |
| 882 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); | 989 SimulatePacketReceive(kSamplePacket1, sizeof(kSamplePacket1)); |
| 883 | 990 |
| 884 EXPECT_EQ(NULL, listener1_.get()); | 991 EXPECT_EQ(NULL, listener1_.get()); |
| 885 EXPECT_EQ(NULL, listener2_.get()); | 992 EXPECT_EQ(NULL, listener2_.get()); |
| 886 } | 993 } |
| 887 | 994 |
| 888 ACTION_P(SaveIPAddress, ip_container) { | 995 ACTION_P(SaveIPAddress, ip_container) { |
| 889 ::testing::StaticAssertTypeEq<const RecordParsed*, arg1_type>(); | 996 ::testing::StaticAssertTypeEq<const RecordParsed*, arg1_type>(); |
| 890 ::testing::StaticAssertTypeEq<IPAddressNumber*, ip_container_type>(); | 997 ::testing::StaticAssertTypeEq<IPAddressNumber*, ip_container_type>(); |
| 891 | 998 |
| 892 *ip_container = arg1->template rdata<ARecordRdata>()->address(); | 999 *ip_container = arg1->template rdata<ARecordRdata>()->address(); |
| 893 } | 1000 } |
| 894 | 1001 |
| 895 TEST_F(MDnsTest, DoubleRecordDisagreeing) { | 1002 TEST_F(MDnsTest, DoubleRecordDisagreeing) { |
| 896 IPAddressNumber address; | 1003 IPAddressNumber address; |
| 897 StrictMock<MockListenerDelegate> delegate_privet; | 1004 StrictMock<MockListenerDelegate> delegate_privet; |
| 898 | 1005 |
| 899 scoped_ptr<MDnsListener> listener_privet = | 1006 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 900 test_client_.CreateListener(dns_protocol::kTypeA, "privet.local", | 1007 dns_protocol::kTypeA, "privet.local", &delegate_privet); |
| 901 &delegate_privet); | |
| 902 | 1008 |
| 903 ASSERT_TRUE(listener_privet->Start()); | 1009 ASSERT_TRUE(listener_privet->Start()); |
| 904 | 1010 |
| 905 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 1011 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 906 .Times(Exactly(1)) | 1012 .Times(Exactly(1)) |
| 907 .WillOnce(SaveIPAddress(&address)); | 1013 .WillOnce(SaveIPAddress(&address)); |
| 908 | 1014 |
| 909 SimulatePacketReceive(kCorruptedPacketDoubleRecord, | 1015 SimulatePacketReceive(kCorruptedPacketDoubleRecord, |
| 910 sizeof(kCorruptedPacketDoubleRecord)); | 1016 sizeof(kCorruptedPacketDoubleRecord)); |
| 911 | 1017 |
| 912 EXPECT_EQ("2.3.4.5", IPAddressToString(address)); | 1018 EXPECT_EQ("2.3.4.5", IPAddressToString(address)); |
| 913 } | 1019 } |
| 914 | 1020 |
| 915 TEST_F(MDnsTest, NsecWithListener) { | 1021 TEST_F(MDnsTest, NsecWithListener) { |
| 916 StrictMock<MockListenerDelegate> delegate_privet; | 1022 StrictMock<MockListenerDelegate> delegate_privet; |
| 917 scoped_ptr<MDnsListener> listener_privet = | 1023 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 918 test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local", | 1024 dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet); |
| 919 &delegate_privet); | |
| 920 | 1025 |
| 921 // Test to make sure nsec callback is NOT called for PTR | 1026 // Test to make sure nsec callback is NOT called for PTR |
| 922 // (which is marked as existing). | 1027 // (which is marked as existing). |
| 923 StrictMock<MockListenerDelegate> delegate_privet2; | 1028 StrictMock<MockListenerDelegate> delegate_privet2; |
| 924 scoped_ptr<MDnsListener> listener_privet2 = | 1029 scoped_ptr<MDnsListener> listener_privet2 = test_client_->CreateListener( |
| 925 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 1030 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_privet2); |
| 926 &delegate_privet2); | |
| 927 | 1031 |
| 928 ASSERT_TRUE(listener_privet->Start()); | 1032 ASSERT_TRUE(listener_privet->Start()); |
| 929 | 1033 |
| 930 EXPECT_CALL(delegate_privet, | 1034 EXPECT_CALL(delegate_privet, |
| 931 OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA)); | 1035 OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA)); |
| 932 | 1036 |
| 933 SimulatePacketReceive(kSamplePacketNsec, | 1037 SimulatePacketReceive(kSamplePacketNsec, |
| 934 sizeof(kSamplePacketNsec)); | 1038 sizeof(kSamplePacketNsec)); |
| 935 } | 1039 } |
| 936 | 1040 |
| 937 TEST_F(MDnsTest, NsecWithTransactionFromNetwork) { | 1041 TEST_F(MDnsTest, NsecWithTransactionFromNetwork) { |
| 938 scoped_ptr<MDnsTransaction> transaction_privet = | 1042 scoped_ptr<MDnsTransaction> transaction_privet = |
| 939 test_client_.CreateTransaction( | 1043 test_client_->CreateTransaction( |
| 940 dns_protocol::kTypeA, "_privet._tcp.local", | 1044 dns_protocol::kTypeA, "_privet._tcp.local", |
| 941 MDnsTransaction::QUERY_NETWORK | | 1045 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 942 MDnsTransaction::QUERY_CACHE | | 1046 MDnsTransaction::SINGLE_RESULT, |
| 943 MDnsTransaction::SINGLE_RESULT, | |
| 944 base::Bind(&MDnsTest::MockableRecordCallback, | 1047 base::Bind(&MDnsTest::MockableRecordCallback, |
| 945 base::Unretained(this))); | 1048 base::Unretained(this))); |
| 946 | 1049 |
| 947 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); | 1050 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); |
| 948 | 1051 |
| 949 ASSERT_TRUE(transaction_privet->Start()); | 1052 ASSERT_TRUE(transaction_privet->Start()); |
| 950 | 1053 |
| 951 EXPECT_CALL(*this, | 1054 EXPECT_CALL(*this, |
| 952 MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL)); | 1055 MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL)); |
| 953 | 1056 |
| 954 SimulatePacketReceive(kSamplePacketNsec, | 1057 SimulatePacketReceive(kSamplePacketNsec, |
| 955 sizeof(kSamplePacketNsec)); | 1058 sizeof(kSamplePacketNsec)); |
| 956 } | 1059 } |
| 957 | 1060 |
| 958 TEST_F(MDnsTest, NsecWithTransactionFromCache) { | 1061 TEST_F(MDnsTest, NsecWithTransactionFromCache) { |
| 959 // Force mDNS to listen. | 1062 // Force mDNS to listen. |
| 960 StrictMock<MockListenerDelegate> delegate_irrelevant; | 1063 StrictMock<MockListenerDelegate> delegate_irrelevant; |
| 961 scoped_ptr<MDnsListener> listener_irrelevant = | 1064 scoped_ptr<MDnsListener> listener_irrelevant = test_client_->CreateListener( |
| 962 test_client_.CreateListener(dns_protocol::kTypePTR, "_privet._tcp.local", | 1065 dns_protocol::kTypePTR, "_privet._tcp.local", &delegate_irrelevant); |
| 963 &delegate_irrelevant); | |
| 964 listener_irrelevant->Start(); | 1066 listener_irrelevant->Start(); |
| 965 | 1067 |
| 966 SimulatePacketReceive(kSamplePacketNsec, | 1068 SimulatePacketReceive(kSamplePacketNsec, |
| 967 sizeof(kSamplePacketNsec)); | 1069 sizeof(kSamplePacketNsec)); |
| 968 | 1070 |
| 969 EXPECT_CALL(*this, | 1071 EXPECT_CALL(*this, |
| 970 MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL)); | 1072 MockableRecordCallback(MDnsTransaction::RESULT_NSEC, NULL)); |
| 971 | 1073 |
| 972 scoped_ptr<MDnsTransaction> transaction_privet_a = | 1074 scoped_ptr<MDnsTransaction> transaction_privet_a = |
| 973 test_client_.CreateTransaction( | 1075 test_client_->CreateTransaction( |
| 974 dns_protocol::kTypeA, "_privet._tcp.local", | 1076 dns_protocol::kTypeA, "_privet._tcp.local", |
| 975 MDnsTransaction::QUERY_NETWORK | | 1077 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 976 MDnsTransaction::QUERY_CACHE | | 1078 MDnsTransaction::SINGLE_RESULT, |
| 977 MDnsTransaction::SINGLE_RESULT, | |
| 978 base::Bind(&MDnsTest::MockableRecordCallback, | 1079 base::Bind(&MDnsTest::MockableRecordCallback, |
| 979 base::Unretained(this))); | 1080 base::Unretained(this))); |
| 980 | 1081 |
| 981 ASSERT_TRUE(transaction_privet_a->Start()); | 1082 ASSERT_TRUE(transaction_privet_a->Start()); |
| 982 | 1083 |
| 983 // Test that a PTR transaction does NOT consider the same NSEC record to be a | 1084 // Test that a PTR transaction does NOT consider the same NSEC record to be a |
| 984 // valid answer to the query | 1085 // valid answer to the query |
| 985 | 1086 |
| 986 scoped_ptr<MDnsTransaction> transaction_privet_ptr = | 1087 scoped_ptr<MDnsTransaction> transaction_privet_ptr = |
| 987 test_client_.CreateTransaction( | 1088 test_client_->CreateTransaction( |
| 988 dns_protocol::kTypePTR, "_privet._tcp.local", | 1089 dns_protocol::kTypePTR, "_privet._tcp.local", |
| 989 MDnsTransaction::QUERY_NETWORK | | 1090 MDnsTransaction::QUERY_NETWORK | MDnsTransaction::QUERY_CACHE | |
| 990 MDnsTransaction::QUERY_CACHE | | 1091 MDnsTransaction::SINGLE_RESULT, |
| 991 MDnsTransaction::SINGLE_RESULT, | |
| 992 base::Bind(&MDnsTest::MockableRecordCallback, | 1092 base::Bind(&MDnsTest::MockableRecordCallback, |
| 993 base::Unretained(this))); | 1093 base::Unretained(this))); |
| 994 | 1094 |
| 995 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); | 1095 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); |
| 996 | 1096 |
| 997 ASSERT_TRUE(transaction_privet_ptr->Start()); | 1097 ASSERT_TRUE(transaction_privet_ptr->Start()); |
| 998 } | 1098 } |
| 999 | 1099 |
| 1000 TEST_F(MDnsTest, NsecConflictRemoval) { | 1100 TEST_F(MDnsTest, NsecConflictRemoval) { |
| 1001 StrictMock<MockListenerDelegate> delegate_privet; | 1101 StrictMock<MockListenerDelegate> delegate_privet; |
| 1002 scoped_ptr<MDnsListener> listener_privet = | 1102 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 1003 test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local", | 1103 dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet); |
| 1004 &delegate_privet); | |
| 1005 | 1104 |
| 1006 ASSERT_TRUE(listener_privet->Start()); | 1105 ASSERT_TRUE(listener_privet->Start()); |
| 1007 | 1106 |
| 1008 const RecordParsed* record1; | 1107 const RecordParsed* record1; |
| 1009 const RecordParsed* record2; | 1108 const RecordParsed* record2; |
| 1010 | 1109 |
| 1011 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) | 1110 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)) |
| 1012 .WillOnce(SaveArg<1>(&record1)); | 1111 .WillOnce(SaveArg<1>(&record1)); |
| 1013 | 1112 |
| 1014 SimulatePacketReceive(kSamplePacketAPrivet, | 1113 SimulatePacketReceive(kSamplePacketAPrivet, |
| 1015 sizeof(kSamplePacketAPrivet)); | 1114 sizeof(kSamplePacketAPrivet)); |
| 1016 | 1115 |
| 1017 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) | 1116 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_REMOVED, _)) |
| 1018 .WillOnce(SaveArg<1>(&record2)); | 1117 .WillOnce(SaveArg<1>(&record2)); |
| 1019 | 1118 |
| 1020 EXPECT_CALL(delegate_privet, | 1119 EXPECT_CALL(delegate_privet, |
| 1021 OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA)); | 1120 OnNsecRecord("_privet._tcp.local", dns_protocol::kTypeA)); |
| 1022 | 1121 |
| 1023 SimulatePacketReceive(kSamplePacketNsec, | 1122 SimulatePacketReceive(kSamplePacketNsec, |
| 1024 sizeof(kSamplePacketNsec)); | 1123 sizeof(kSamplePacketNsec)); |
| 1025 | 1124 |
| 1026 EXPECT_EQ(record1, record2); | 1125 EXPECT_EQ(record1, record2); |
| 1027 } | 1126 } |
| 1028 | 1127 |
| 1029 | 1128 |
| 1030 TEST_F(MDnsTest, RefreshQuery) { | 1129 TEST_F(MDnsTest, RefreshQuery) { |
| 1031 StrictMock<MockListenerDelegate> delegate_privet; | 1130 StrictMock<MockListenerDelegate> delegate_privet; |
| 1032 scoped_ptr<MDnsListener> listener_privet = | 1131 scoped_ptr<MDnsListener> listener_privet = test_client_->CreateListener( |
| 1033 test_client_.CreateListener(dns_protocol::kTypeA, "_privet._tcp.local", | 1132 dns_protocol::kTypeA, "_privet._tcp.local", &delegate_privet); |
| 1034 &delegate_privet); | |
| 1035 | 1133 |
| 1036 listener_privet->SetActiveRefresh(true); | 1134 listener_privet->SetActiveRefresh(true); |
| 1037 ASSERT_TRUE(listener_privet->Start()); | 1135 ASSERT_TRUE(listener_privet->Start()); |
| 1038 | 1136 |
| 1039 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)); | 1137 EXPECT_CALL(delegate_privet, OnRecordUpdate(MDnsListener::RECORD_ADDED, _)); |
| 1040 | 1138 |
| 1041 SimulatePacketReceive(kSamplePacketAPrivet, | 1139 SimulatePacketReceive(kSamplePacketAPrivet, |
| 1042 sizeof(kSamplePacketAPrivet)); | 1140 sizeof(kSamplePacketAPrivet)); |
| 1043 | 1141 |
| 1044 // Expecting 2 calls (one for ipv4 and one for ipv6) for each of the 2 | 1142 // Expecting 2 calls (one for ipv4 and one for ipv6) for each of the 2 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 MOCK_METHOD1(OnConnectionError, void(int error)); | 1178 MOCK_METHOD1(OnConnectionError, void(int error)); |
| 1081 }; | 1179 }; |
| 1082 | 1180 |
| 1083 class MDnsConnectionTest : public ::testing::Test { | 1181 class MDnsConnectionTest : public ::testing::Test { |
| 1084 public: | 1182 public: |
| 1085 MDnsConnectionTest() : connection_(&delegate_) { | 1183 MDnsConnectionTest() : connection_(&delegate_) { |
| 1086 } | 1184 } |
| 1087 | 1185 |
| 1088 protected: | 1186 protected: |
| 1089 // Follow successful connection initialization. | 1187 // Follow successful connection initialization. |
| 1090 virtual void SetUp() override { | 1188 void SetUp() override { |
| 1091 socket_ipv4_ = new MockMDnsDatagramServerSocket(ADDRESS_FAMILY_IPV4); | 1189 socket_ipv4_ = new MockMDnsDatagramServerSocket(ADDRESS_FAMILY_IPV4); |
| 1092 socket_ipv6_ = new MockMDnsDatagramServerSocket(ADDRESS_FAMILY_IPV6); | 1190 socket_ipv6_ = new MockMDnsDatagramServerSocket(ADDRESS_FAMILY_IPV6); |
| 1093 factory_.PushSocket(socket_ipv6_); | 1191 factory_.PushSocket(socket_ipv6_); |
| 1094 factory_.PushSocket(socket_ipv4_); | 1192 factory_.PushSocket(socket_ipv4_); |
| 1095 sample_packet_ = MakeString(kSamplePacket1, sizeof(kSamplePacket1)); | 1193 sample_packet_ = MakeString(kSamplePacket1, sizeof(kSamplePacket1)); |
| 1096 sample_buffer_ = new StringIOBuffer(sample_packet_); | 1194 sample_buffer_ = new StringIOBuffer(sample_packet_); |
| 1097 } | 1195 } |
| 1098 | 1196 |
| 1099 bool InitConnection() { | 1197 bool InitConnection() { |
| 1100 return connection_.Init(&factory_); | 1198 return connection_.Init(&factory_); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 EXPECT_CALL(*socket_ipv4_, | 1310 EXPECT_CALL(*socket_ipv4_, |
| 1213 SendToInternal(sample_packet_, "224.0.0.251:5353", _)) | 1311 SendToInternal(sample_packet_, "224.0.0.251:5353", _)) |
| 1214 .Times(0); | 1312 .Times(0); |
| 1215 // Expect call for the second IPv6 packed. | 1313 // Expect call for the second IPv6 packed. |
| 1216 EXPECT_CALL(*socket_ipv6_, | 1314 EXPECT_CALL(*socket_ipv6_, |
| 1217 SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) | 1315 SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) |
| 1218 .WillOnce(Return(OK)); | 1316 .WillOnce(Return(OK)); |
| 1219 callback.Run(OK); | 1317 callback.Run(OK); |
| 1220 } | 1318 } |
| 1221 | 1319 |
| 1222 } // namespace | |
| 1223 | |
| 1224 } // namespace net | 1320 } // namespace net |
| OLD | NEW |