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