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

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl_unittest.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 return expected->is_binary() ? *expected->data == *actual->data 77 return expected->is_binary() ? *expected->data == *actual->data
78 : expected->message == actual->message; 78 : expected->message == actual->message;
79 } 79 }
80 80
81 interfaces::IssuePtr CreateMojoIssue(const std::string& title) { 81 interfaces::IssuePtr CreateMojoIssue(const std::string& title) {
82 interfaces::IssuePtr mojoIssue = interfaces::Issue::New(); 82 interfaces::IssuePtr mojoIssue = interfaces::Issue::New();
83 mojoIssue->title = title; 83 mojoIssue->title = title;
84 mojoIssue->message = "msg"; 84 mojoIssue->message = "msg";
85 mojoIssue->route_id = ""; 85 mojoIssue->route_id = "";
86 mojoIssue->default_action = 86 mojoIssue->default_action = interfaces::Issue::ActionType::DISMISS;
87 interfaces::Issue::ActionType::ACTION_TYPE_DISMISS;
88 mojoIssue->secondary_actions = 87 mojoIssue->secondary_actions =
89 mojo::Array<interfaces::Issue::ActionType>::New(0); 88 mojo::Array<interfaces::Issue::ActionType>::New(0);
90 mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING; 89 mojoIssue->severity = interfaces::Issue::Severity::WARNING;
91 mojoIssue->is_blocking = false; 90 mojoIssue->is_blocking = false;
92 mojoIssue->help_url = ""; 91 mojoIssue->help_url = "";
93 return mojoIssue; 92 return mojoIssue;
94 } 93 }
95 94
96 } // namespace 95 } // namespace
97 96
98 class RouteResponseCallbackHandler { 97 class RouteResponseCallbackHandler {
99 public: 98 public:
100 MOCK_METHOD3(Invoke, 99 MOCK_METHOD3(Invoke,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 })); 459 }));
461 media_router_proxy_->OnIssue(std::move(mojo_issue2)); 460 media_router_proxy_->OnIssue(std::move(mojo_issue2));
462 run_loop2.Run(); 461 run_loop2.Run();
463 462
464 issue_observer1.UnregisterObserver(); 463 issue_observer1.UnregisterObserver();
465 issue_observer2.UnregisterObserver(); 464 issue_observer2.UnregisterObserver();
466 } 465 }
467 466
468 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaSinksObserver) { 467 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaSinksObserver) {
469 router()->OnSinkAvailabilityUpdated( 468 router()->OnSinkAvailabilityUpdated(
470 interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); 469 interfaces::MediaRouter::SinkAvailability::AVAILABLE);
471 MediaSource media_source(kSource); 470 MediaSource media_source(kSource);
472 471
473 // These should only be called once even if there is more than one observer 472 // These should only be called once even if there is more than one observer
474 // for a given source. 473 // for a given source.
475 EXPECT_CALL(mock_media_route_provider_, 474 EXPECT_CALL(mock_media_route_provider_,
476 StartObservingMediaSinks(mojo::String(kSource))); 475 StartObservingMediaSinks(mojo::String(kSource)));
477 EXPECT_CALL(mock_media_route_provider_, 476 EXPECT_CALL(mock_media_route_provider_,
478 StartObservingMediaSinks(mojo::String(kSource2))); 477 StartObservingMediaSinks(mojo::String(kSource2)));
479 478
480 scoped_ptr<MockMediaSinksObserver> sinks_observer( 479 scoped_ptr<MockMediaSinksObserver> sinks_observer(
(...skipping 11 matching lines...) Expand all
492 expected_sinks.push_back( 491 expected_sinks.push_back(
493 MediaSink(kSinkId, kSinkName, MediaSink::IconType::CAST)); 492 MediaSink(kSinkId, kSinkName, MediaSink::IconType::CAST));
494 expected_sinks.push_back( 493 expected_sinks.push_back(
495 MediaSink(kSinkId2, kSinkName, MediaSink::IconType::CAST)); 494 MediaSink(kSinkId2, kSinkName, MediaSink::IconType::CAST));
496 495
497 mojo::Array<interfaces::MediaSinkPtr> mojo_sinks(2); 496 mojo::Array<interfaces::MediaSinkPtr> mojo_sinks(2);
498 mojo_sinks[0] = interfaces::MediaSink::New(); 497 mojo_sinks[0] = interfaces::MediaSink::New();
499 mojo_sinks[0]->sink_id = kSinkId; 498 mojo_sinks[0]->sink_id = kSinkId;
500 mojo_sinks[0]->name = kSinkName; 499 mojo_sinks[0]->name = kSinkName;
501 mojo_sinks[0]->icon_type = 500 mojo_sinks[0]->icon_type =
502 media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; 501 media_router::interfaces::MediaSink::IconType::CAST;
503 mojo_sinks[1] = interfaces::MediaSink::New(); 502 mojo_sinks[1] = interfaces::MediaSink::New();
504 mojo_sinks[1]->sink_id = kSinkId2; 503 mojo_sinks[1]->sink_id = kSinkId2;
505 mojo_sinks[1]->name = kSinkName; 504 mojo_sinks[1]->name = kSinkName;
506 mojo_sinks[1]->icon_type = 505 mojo_sinks[1]->icon_type =
507 media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; 506 media_router::interfaces::MediaSink::IconType::CAST;
508 507
509 base::RunLoop run_loop; 508 base::RunLoop run_loop;
510 EXPECT_CALL(*sinks_observer, OnSinksReceived(SequenceEquals(expected_sinks))); 509 EXPECT_CALL(*sinks_observer, OnSinksReceived(SequenceEquals(expected_sinks)));
511 EXPECT_CALL(*extra_sinks_observer, 510 EXPECT_CALL(*extra_sinks_observer,
512 OnSinksReceived(SequenceEquals(expected_sinks))) 511 OnSinksReceived(SequenceEquals(expected_sinks)))
513 .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); 512 .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); }));
514 media_router_proxy_->OnSinksReceived(media_source.id(), 513 media_router_proxy_->OnSinksReceived(media_source.id(),
515 std::move(mojo_sinks)); 514 std::move(mojo_sinks));
516 run_loop.Run(); 515 run_loop.Run();
517 516
(...skipping 18 matching lines...) Expand all
536 extra_sinks_observer.reset(); 535 extra_sinks_observer.reset();
537 unrelated_sinks_observer.reset(); 536 unrelated_sinks_observer.reset();
538 cached_sinks_observer.reset(); 537 cached_sinks_observer.reset();
539 run_loop2.Run(); 538 run_loop2.Run();
540 } 539 }
541 540
542 TEST_F(MediaRouterMojoImplTest, 541 TEST_F(MediaRouterMojoImplTest,
543 RegisterMediaSinksObserverWithAvailabilityChange) { 542 RegisterMediaSinksObserverWithAvailabilityChange) {
544 // When availability is UNAVAILABLE, no calls should be made to MRPM. 543 // When availability is UNAVAILABLE, no calls should be made to MRPM.
545 router()->OnSinkAvailabilityUpdated( 544 router()->OnSinkAvailabilityUpdated(
546 interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE); 545 interfaces::MediaRouter::SinkAvailability::UNAVAILABLE);
547 MediaSource media_source(kSource); 546 MediaSource media_source(kSource);
548 scoped_ptr<MockMediaSinksObserver> sinks_observer( 547 scoped_ptr<MockMediaSinksObserver> sinks_observer(
549 new MockMediaSinksObserver(router(), media_source)); 548 new MockMediaSinksObserver(router(), media_source));
550 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty())); 549 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty()));
551 EXPECT_TRUE(sinks_observer->Init()); 550 EXPECT_TRUE(sinks_observer->Init());
552 MediaSource media_source2(kSource2); 551 MediaSource media_source2(kSource2);
553 scoped_ptr<MockMediaSinksObserver> sinks_observer2( 552 scoped_ptr<MockMediaSinksObserver> sinks_observer2(
554 new MockMediaSinksObserver(router(), media_source2)); 553 new MockMediaSinksObserver(router(), media_source2));
555 EXPECT_CALL(*sinks_observer2, OnSinksReceived(IsEmpty())); 554 EXPECT_CALL(*sinks_observer2, OnSinksReceived(IsEmpty()));
556 EXPECT_TRUE(sinks_observer2->Init()); 555 EXPECT_TRUE(sinks_observer2->Init());
557 EXPECT_CALL(mock_media_route_provider_, 556 EXPECT_CALL(mock_media_route_provider_,
558 StartObservingMediaSinks(mojo::String(kSource))) 557 StartObservingMediaSinks(mojo::String(kSource)))
559 .Times(0); 558 .Times(0);
560 EXPECT_CALL(mock_media_route_provider_, 559 EXPECT_CALL(mock_media_route_provider_,
561 StartObservingMediaSinks(mojo::String(kSource2))) 560 StartObservingMediaSinks(mojo::String(kSource2)))
562 .Times(0); 561 .Times(0);
563 ProcessEventLoop(); 562 ProcessEventLoop();
564 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_)); 563 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_));
565 564
566 // When availability transitions AVAILABLE, existing sink queries should be 565 // When availability transitions AVAILABLE, existing sink queries should be
567 // sent to MRPM. 566 // sent to MRPM.
568 router()->OnSinkAvailabilityUpdated( 567 router()->OnSinkAvailabilityUpdated(
569 interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); 568 interfaces::MediaRouter::SinkAvailability::AVAILABLE);
570 EXPECT_CALL(mock_media_route_provider_, 569 EXPECT_CALL(mock_media_route_provider_,
571 StartObservingMediaSinks(mojo::String(kSource))) 570 StartObservingMediaSinks(mojo::String(kSource)))
572 .Times(1); 571 .Times(1);
573 EXPECT_CALL(mock_media_route_provider_, 572 EXPECT_CALL(mock_media_route_provider_,
574 StartObservingMediaSinks(mojo::String(kSource2))) 573 StartObservingMediaSinks(mojo::String(kSource2)))
575 .Times(1); 574 .Times(1);
576 ProcessEventLoop(); 575 ProcessEventLoop();
577 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_)); 576 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_));
578 577
579 // No change in availability status; no calls should be made to MRPM. 578 // No change in availability status; no calls should be made to MRPM.
580 router()->OnSinkAvailabilityUpdated( 579 router()->OnSinkAvailabilityUpdated(
581 interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); 580 interfaces::MediaRouter::SinkAvailability::AVAILABLE);
582 EXPECT_CALL(mock_media_route_provider_, 581 EXPECT_CALL(mock_media_route_provider_,
583 StartObservingMediaSinks(mojo::String(kSource))) 582 StartObservingMediaSinks(mojo::String(kSource)))
584 .Times(0); 583 .Times(0);
585 EXPECT_CALL(mock_media_route_provider_, 584 EXPECT_CALL(mock_media_route_provider_,
586 StartObservingMediaSinks(mojo::String(kSource2))) 585 StartObservingMediaSinks(mojo::String(kSource2)))
587 .Times(0); 586 .Times(0);
588 ProcessEventLoop(); 587 ProcessEventLoop();
589 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_)); 588 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_));
590 589
591 // When availability is UNAVAILABLE, queries are already removed from MRPM. 590 // When availability is UNAVAILABLE, queries are already removed from MRPM.
592 // Unregistering observer won't result in call to MRPM to remove query. 591 // Unregistering observer won't result in call to MRPM to remove query.
593 router()->OnSinkAvailabilityUpdated( 592 router()->OnSinkAvailabilityUpdated(
594 interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE); 593 interfaces::MediaRouter::SinkAvailability::UNAVAILABLE);
595 EXPECT_CALL(mock_media_route_provider_, 594 EXPECT_CALL(mock_media_route_provider_,
596 StopObservingMediaSinks(mojo::String(kSource))) 595 StopObservingMediaSinks(mojo::String(kSource)))
597 .Times(0); 596 .Times(0);
598 sinks_observer.reset(); 597 sinks_observer.reset();
599 ProcessEventLoop(); 598 ProcessEventLoop();
600 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_)); 599 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_media_route_provider_));
601 600
602 // When availability is AVAILABLE, call is made to MRPM to remove query when 601 // When availability is AVAILABLE, call is made to MRPM to remove query when
603 // observer is unregistered. 602 // observer is unregistered.
604 router()->OnSinkAvailabilityUpdated( 603 router()->OnSinkAvailabilityUpdated(
605 interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); 604 interfaces::MediaRouter::SinkAvailability::AVAILABLE);
606 EXPECT_CALL(mock_media_route_provider_, 605 EXPECT_CALL(mock_media_route_provider_,
607 StopObservingMediaSinks(mojo::String(kSource2))); 606 StopObservingMediaSinks(mojo::String(kSource2)));
608 sinks_observer2.reset(); 607 sinks_observer2.reset();
609 ProcessEventLoop(); 608 ProcessEventLoop();
610 } 609 }
611 610
612 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaRoutesObserver) { 611 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaRoutesObserver) {
613 MockMediaRouter mock_router; 612 MockMediaRouter mock_router;
614 MediaSource media_source(kSource); 613 MediaSource media_source(kSource);
615 MediaSource different_media_source(kSource2); 614 MediaSource different_media_source(kSource2);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 router()->SendRouteBinaryMessage( 738 router()->SendRouteBinaryMessage(
740 kRouteId, std::move(expected_binary_data), 739 kRouteId, std::move(expected_binary_data),
741 base::Bind(&SendMessageCallbackHandler::Invoke, 740 base::Bind(&SendMessageCallbackHandler::Invoke,
742 base::Unretained(&handler))); 741 base::Unretained(&handler)));
743 run_loop.Run(); 742 run_loop.Run();
744 } 743 }
745 744
746 TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesSingleObserver) { 745 TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesSingleObserver) {
747 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); 746 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2);
748 mojo_messages[0] = interfaces::RouteMessage::New(); 747 mojo_messages[0] = interfaces::RouteMessage::New();
749 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 748 mojo_messages[0]->type = interfaces::RouteMessage::Type::TEXT;
750 mojo_messages[0]->message = "text"; 749 mojo_messages[0]->message = "text";
751 mojo_messages[1] = interfaces::RouteMessage::New(); 750 mojo_messages[1] = interfaces::RouteMessage::New();
752 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; 751 mojo_messages[1]->type = interfaces::RouteMessage::Type::BINARY;
753 mojo_messages[1]->data.push_back(1); 752 mojo_messages[1]->data.push_back(1);
754 753
755 ScopedVector<content::PresentationSessionMessage> expected_messages; 754 ScopedVector<content::PresentationSessionMessage> expected_messages;
756 scoped_ptr<content::PresentationSessionMessage> message; 755 scoped_ptr<content::PresentationSessionMessage> message;
757 message.reset(new content::PresentationSessionMessage( 756 message.reset(new content::PresentationSessionMessage(
758 content::PresentationMessageType::TEXT)); 757 content::PresentationMessageType::TEXT));
759 message->message = "text"; 758 message->message = "text";
760 expected_messages.push_back(std::move(message)); 759 expected_messages.push_back(std::move(message));
761 760
762 message.reset(new content::PresentationSessionMessage( 761 message.reset(new content::PresentationSessionMessage(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 InvokeWithoutArgs([&run_loop2]() { 798 InvokeWithoutArgs([&run_loop2]() {
800 run_loop2.Quit(); 799 run_loop2.Quit();
801 }))); 800 })));
802 run_loop2.Run(); 801 run_loop2.Run();
803 802
804 base::RunLoop run_loop3; 803 base::RunLoop run_loop3;
805 // Stop listening for messages. In particular, MediaRouterMojoImpl will not 804 // Stop listening for messages. In particular, MediaRouterMojoImpl will not
806 // call ListenForRouteMessages again when it sees there are no more observers. 805 // call ListenForRouteMessages again when it sees there are no more observers.
807 mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1); 806 mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1);
808 mojo_messages_2[0] = interfaces::RouteMessage::New(); 807 mojo_messages_2[0] = interfaces::RouteMessage::New();
809 mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 808 mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TEXT;
810 mojo_messages_2[0]->message = "foo"; 809 mojo_messages_2[0]->message = "foo";
811 observer.reset(); 810 observer.reset();
812 mojo_callback_2.Run(std::move(mojo_messages_2), false); 811 mojo_callback_2.Run(std::move(mojo_messages_2), false);
813 EXPECT_CALL(mock_media_route_provider_, StopListeningForRouteMessages(_)) 812 EXPECT_CALL(mock_media_route_provider_, StopListeningForRouteMessages(_))
814 .WillOnce(InvokeWithoutArgs([&run_loop3]() { 813 .WillOnce(InvokeWithoutArgs([&run_loop3]() {
815 run_loop3.Quit(); 814 run_loop3.Quit();
816 })); 815 }));
817 run_loop3.Run(); 816 run_loop3.Run();
818 } 817 }
819 818
820 TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesMultipleObservers) { 819 TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesMultipleObservers) {
821 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); 820 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2);
822 mojo_messages[0] = interfaces::RouteMessage::New(); 821 mojo_messages[0] = interfaces::RouteMessage::New();
823 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 822 mojo_messages[0]->type = interfaces::RouteMessage::Type::TEXT;
824 mojo_messages[0]->message = "text"; 823 mojo_messages[0]->message = "text";
825 mojo_messages[1] = interfaces::RouteMessage::New(); 824 mojo_messages[1] = interfaces::RouteMessage::New();
826 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; 825 mojo_messages[1]->type = interfaces::RouteMessage::Type::BINARY;
827 mojo_messages[1]->data.push_back(1); 826 mojo_messages[1]->data.push_back(1);
828 827
829 ScopedVector<content::PresentationSessionMessage> expected_messages; 828 ScopedVector<content::PresentationSessionMessage> expected_messages;
830 scoped_ptr<content::PresentationSessionMessage> message; 829 scoped_ptr<content::PresentationSessionMessage> message;
831 message.reset(new content::PresentationSessionMessage( 830 message.reset(new content::PresentationSessionMessage(
832 content::PresentationMessageType::TEXT)); 831 content::PresentationMessageType::TEXT));
833 message->message = "text"; 832 message->message = "text";
834 expected_messages.push_back(std::move(message)); 833 expected_messages.push_back(std::move(message));
835 834
836 message.reset(new content::PresentationSessionMessage( 835 message.reset(new content::PresentationSessionMessage(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 InvokeWithoutArgs([&run_loop2]() { 878 InvokeWithoutArgs([&run_loop2]() {
880 run_loop2.Quit(); 879 run_loop2.Quit();
881 }))); 880 })));
882 run_loop2.Run(); 881 run_loop2.Run();
883 882
884 base::RunLoop run_loop3; 883 base::RunLoop run_loop3;
885 // Stop listening for messages. In particular, MediaRouterMojoImpl will not 884 // Stop listening for messages. In particular, MediaRouterMojoImpl will not
886 // call ListenForRouteMessages again when it sees there are no more observers. 885 // call ListenForRouteMessages again when it sees there are no more observers.
887 mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1); 886 mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1);
888 mojo_messages_2[0] = interfaces::RouteMessage::New(); 887 mojo_messages_2[0] = interfaces::RouteMessage::New();
889 mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 888 mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TEXT;
890 mojo_messages_2[0]->message = "foo"; 889 mojo_messages_2[0]->message = "foo";
891 observer1.reset(); 890 observer1.reset();
892 observer2.reset(); 891 observer2.reset();
893 mojo_callback_2.Run(std::move(mojo_messages_2), false); 892 mojo_callback_2.Run(std::move(mojo_messages_2), false);
894 EXPECT_CALL(mock_media_route_provider_, StopListeningForRouteMessages(_)) 893 EXPECT_CALL(mock_media_route_provider_, StopListeningForRouteMessages(_))
895 .WillOnce(InvokeWithoutArgs([&run_loop3]() { 894 .WillOnce(InvokeWithoutArgs([&run_loop3]() {
896 run_loop3.Quit(); 895 run_loop3.Quit();
897 })); 896 }));
898 run_loop3.Run(); 897 run_loop3.Run();
899 } 898 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 route_id, 939 route_id,
941 base::Bind(&MockPresentationConnectionStateChangedCallback::Run, 940 base::Bind(&MockPresentationConnectionStateChangedCallback::Run,
942 base::Unretained(&callback))); 941 base::Unretained(&callback)));
943 942
944 base::RunLoop run_loop; 943 base::RunLoop run_loop;
945 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED)) 944 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
946 .WillOnce(InvokeWithoutArgs([&run_loop]() { 945 .WillOnce(InvokeWithoutArgs([&run_loop]() {
947 run_loop.Quit(); 946 run_loop.Quit();
948 })); 947 }));
949 media_router_proxy_->OnPresentationConnectionStateChanged( 948 media_router_proxy_->OnPresentationConnectionStateChanged(
950 route_id, 949 route_id, PresentationConnectionState::CLOSED);
951 PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
952 run_loop.Run(); 950 run_loop.Run();
953 951
954 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&callback)); 952 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&callback));
955 953
956 base::RunLoop run_loop2; 954 base::RunLoop run_loop2;
957 // Right now we don't keep track of previous state so the callback will be 955 // Right now we don't keep track of previous state so the callback will be
958 // invoked with the same state again. 956 // invoked with the same state again.
959 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED)) 957 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
960 .WillOnce(InvokeWithoutArgs([&run_loop2]() { 958 .WillOnce(InvokeWithoutArgs([&run_loop2]() {
961 run_loop2.Quit(); 959 run_loop2.Quit();
962 })); 960 }));
963 media_router_proxy_->OnPresentationConnectionStateChanged( 961 media_router_proxy_->OnPresentationConnectionStateChanged(
964 route_id, 962 route_id, PresentationConnectionState::CLOSED);
965 PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
966 run_loop2.Run(); 963 run_loop2.Run();
967 964
968 // Callback has been removed, so we don't expect it to be called anymore. 965 // Callback has been removed, so we don't expect it to be called anymore.
969 subscription.reset(); 966 subscription.reset();
970 EXPECT_TRUE(router()->presentation_connection_state_callbacks_.empty()); 967 EXPECT_TRUE(router()->presentation_connection_state_callbacks_.empty());
971 968
972 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED)) 969 EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
973 .Times(0); 970 .Times(0);
974 media_router_proxy_->OnPresentationConnectionStateChanged( 971 media_router_proxy_->OnPresentationConnectionStateChanged(
975 route_id, 972 route_id, PresentationConnectionState::CLOSED);
976 PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
977 ProcessEventLoop(); 973 ProcessEventLoop();
978 } 974 }
979 975
980 TEST_F(MediaRouterMojoImplTest, HasLocalRoute) { 976 TEST_F(MediaRouterMojoImplTest, HasLocalRoute) {
981 EXPECT_FALSE(router()->HasLocalDisplayRoute()); 977 EXPECT_FALSE(router()->HasLocalDisplayRoute());
982 interfaces::MediaRoutePtr mojo_route1 = interfaces::MediaRoute::New(); 978 interfaces::MediaRoutePtr mojo_route1 = interfaces::MediaRoute::New();
983 mojo_route1->media_route_id = "routeId1"; 979 mojo_route1->media_route_id = "routeId1";
984 mojo_route1->media_sink_id = "sinkId"; 980 mojo_route1->media_sink_id = "sinkId";
985 mojo_route1->is_local = false; 981 mojo_route1->is_local = false;
986 mojo_route1->for_display = false; 982 mojo_route1->for_display = false;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 .WillRepeatedly(InvokeWithoutArgs([&run_loop2, &count]() { 1277 .WillRepeatedly(InvokeWithoutArgs([&run_loop2, &count]() {
1282 if (++count == MediaRouterMojoImpl::kMaxPendingRequests) 1278 if (++count == MediaRouterMojoImpl::kMaxPendingRequests)
1283 run_loop2.Quit(); 1279 run_loop2.Quit();
1284 })); 1280 }));
1285 RegisterMediaRouteProvider(); 1281 RegisterMediaRouteProvider();
1286 run_loop.Run(); 1282 run_loop.Run();
1287 run_loop2.Run(); 1283 run_loop2.Run();
1288 } 1284 }
1289 1285
1290 } // namespace media_router 1286 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_mojo_impl.cc ('k') | chrome/browser/media/router/media_router_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698