| OLD | NEW |
| 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 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 sinks_observer.reset(); | 730 sinks_observer.reset(); |
| 731 extra_sinks_observer.reset(); | 731 extra_sinks_observer.reset(); |
| 732 unrelated_sinks_observer.reset(); | 732 unrelated_sinks_observer.reset(); |
| 733 cached_sinks_observer.reset(); | 733 cached_sinks_observer.reset(); |
| 734 cached_sinks_observer2.reset(); | 734 cached_sinks_observer2.reset(); |
| 735 run_loop2.Run(); | 735 run_loop2.Run(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 TEST_F(MediaRouterMojoImplTest, | 738 TEST_F(MediaRouterMojoImplTest, |
| 739 RegisterMediaSinksObserverWithAvailabilityChange) { | 739 RegisterMediaSinksObserverWithAvailabilityChange) { |
| 740 | |
| 741 // When availability is UNAVAILABLE, no calls should be made to MRPM. | 740 // When availability is UNAVAILABLE, no calls should be made to MRPM. |
| 742 router()->OnSinkAvailabilityUpdated( | 741 router()->OnSinkAvailabilityUpdated( |
| 743 mojom::MediaRouter::SinkAvailability::UNAVAILABLE); | 742 mojom::MediaRouter::SinkAvailability::UNAVAILABLE); |
| 744 MediaSource media_source(kSource); | 743 MediaSource media_source(kSource); |
| 745 std::unique_ptr<MockMediaSinksObserver> sinks_observer( | 744 std::unique_ptr<MockMediaSinksObserver> sinks_observer( |
| 746 new MockMediaSinksObserver(router(), media_source, | 745 new MockMediaSinksObserver(router(), media_source, |
| 747 url::Origin(GURL(kOrigin)))); | 746 url::Origin(GURL(kOrigin)))); |
| 748 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty())); | 747 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty())); |
| 749 EXPECT_TRUE(sinks_observer->Init()); | 748 EXPECT_TRUE(sinks_observer->Init()); |
| 750 MediaSource media_source2(kSource2); | 749 MediaSource media_source2(kSource2); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 EXPECT_CALL(mock_media_route_provider_, DetachRoute(kRouteId2)); | 1111 EXPECT_CALL(mock_media_route_provider_, DetachRoute(kRouteId2)); |
| 1113 ConnectProviderManagerService(); | 1112 ConnectProviderManagerService(); |
| 1114 ProcessEventLoop(); | 1113 ProcessEventLoop(); |
| 1115 } | 1114 } |
| 1116 | 1115 |
| 1117 TEST_F(MediaRouterMojoImplTest, SearchSinks) { | 1116 TEST_F(MediaRouterMojoImplTest, SearchSinks) { |
| 1118 std::string search_input("input"); | 1117 std::string search_input("input"); |
| 1119 std::string domain("google.com"); | 1118 std::string domain("google.com"); |
| 1120 MediaSource media_source(kSource); | 1119 MediaSource media_source(kSource); |
| 1121 | 1120 |
| 1122 EXPECT_CALL( | 1121 EXPECT_CALL(mock_media_route_provider_, |
| 1123 mock_media_route_provider_, SearchSinks_(kSinkId, kSource, _, _)) | 1122 SearchSinksInternal(kSinkId, kSource, _, _)) |
| 1124 .WillOnce(Invoke([&search_input, &domain]( | 1123 .WillOnce( |
| 1125 const std::string& sink_id, const std::string& source, | 1124 Invoke([&search_input, &domain]( |
| 1126 const mojom::SinkSearchCriteriaPtr& search_criteria, | 1125 const std::string& sink_id, const std::string& source, |
| 1127 const mojom::MediaRouteProvider::SearchSinksCallback& cb) { | 1126 const mojom::SinkSearchCriteriaPtr& search_criteria, |
| 1128 EXPECT_EQ(search_input, search_criteria->input); | 1127 const mojom::MediaRouteProvider::SearchSinksCallback& cb) { |
| 1129 EXPECT_EQ(domain, search_criteria->domain); | 1128 EXPECT_EQ(search_input, search_criteria->input); |
| 1130 cb.Run(kSinkId2); | 1129 EXPECT_EQ(domain, search_criteria->domain); |
| 1131 })); | 1130 cb.Run(kSinkId2); |
| 1131 })); |
| 1132 | 1132 |
| 1133 SinkResponseCallbackHandler sink_handler; | 1133 SinkResponseCallbackHandler sink_handler; |
| 1134 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1); | 1134 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1); |
| 1135 MediaSinkSearchResponseCallback sink_callback = base::Bind( | 1135 MediaSinkSearchResponseCallback sink_callback = base::Bind( |
| 1136 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler)); | 1136 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler)); |
| 1137 | 1137 |
| 1138 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback); | 1138 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback); |
| 1139 | 1139 |
| 1140 base::RunLoop run_loop; | 1140 base::RunLoop run_loop; |
| 1141 run_loop.RunUntilIdle(); | 1141 run_loop.RunUntilIdle(); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 EXPECT_CALL(mock_media_route_provider_, | 1514 EXPECT_CALL(mock_media_route_provider_, |
| 1515 UpdateMediaSinks(MediaSourceForDesktop().id())) | 1515 UpdateMediaSinks(MediaSourceForDesktop().id())) |
| 1516 .WillOnce(InvokeWithoutArgs([&run_loop2]() { | 1516 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
| 1517 run_loop2.Quit(); | 1517 run_loop2.Quit(); |
| 1518 })); | 1518 })); |
| 1519 | 1519 |
| 1520 run_loop2.Run(); | 1520 run_loop2.Run(); |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 } // namespace media_router | 1523 } // namespace media_router |
| OLD | NEW |