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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 sinks_observer.reset(); | 731 sinks_observer.reset(); |
732 extra_sinks_observer.reset(); | 732 extra_sinks_observer.reset(); |
733 unrelated_sinks_observer.reset(); | 733 unrelated_sinks_observer.reset(); |
734 cached_sinks_observer.reset(); | 734 cached_sinks_observer.reset(); |
735 cached_sinks_observer2.reset(); | 735 cached_sinks_observer2.reset(); |
736 run_loop2.Run(); | 736 run_loop2.Run(); |
737 } | 737 } |
738 | 738 |
739 TEST_F(MediaRouterMojoImplTest, | 739 TEST_F(MediaRouterMojoImplTest, |
740 RegisterMediaSinksObserverWithAvailabilityChange) { | 740 RegisterMediaSinksObserverWithAvailabilityChange) { |
741 | |
742 // When availability is UNAVAILABLE, no calls should be made to MRPM. | 741 // When availability is UNAVAILABLE, no calls should be made to MRPM. |
743 router()->OnSinkAvailabilityUpdated( | 742 router()->OnSinkAvailabilityUpdated( |
744 mojom::MediaRouter::SinkAvailability::UNAVAILABLE); | 743 mojom::MediaRouter::SinkAvailability::UNAVAILABLE); |
745 MediaSource media_source(kSource); | 744 MediaSource media_source(kSource); |
746 std::unique_ptr<MockMediaSinksObserver> sinks_observer( | 745 std::unique_ptr<MockMediaSinksObserver> sinks_observer( |
747 new MockMediaSinksObserver(router(), media_source, | 746 new MockMediaSinksObserver(router(), media_source, |
748 url::Origin(GURL(kOrigin)))); | 747 url::Origin(GURL(kOrigin)))); |
749 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty())); | 748 EXPECT_CALL(*sinks_observer, OnSinksReceived(IsEmpty())); |
750 EXPECT_TRUE(sinks_observer->Init()); | 749 EXPECT_TRUE(sinks_observer->Init()); |
751 MediaSource media_source2(kSource2); | 750 MediaSource media_source2(kSource2); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 EXPECT_CALL(mock_media_route_provider_, DetachRoute(kRouteId2)); | 1168 EXPECT_CALL(mock_media_route_provider_, DetachRoute(kRouteId2)); |
1170 ConnectProviderManagerService(); | 1169 ConnectProviderManagerService(); |
1171 ProcessEventLoop(); | 1170 ProcessEventLoop(); |
1172 } | 1171 } |
1173 | 1172 |
1174 TEST_F(MediaRouterMojoImplTest, SearchSinks) { | 1173 TEST_F(MediaRouterMojoImplTest, SearchSinks) { |
1175 std::string search_input("input"); | 1174 std::string search_input("input"); |
1176 std::string domain("google.com"); | 1175 std::string domain("google.com"); |
1177 MediaSource media_source(kSource); | 1176 MediaSource media_source(kSource); |
1178 | 1177 |
1179 EXPECT_CALL( | 1178 EXPECT_CALL(mock_media_route_provider_, |
1180 mock_media_route_provider_, SearchSinks_(kSinkId, kSource, _, _)) | 1179 SearchSinksInternal(kSinkId, kSource, _, _)) |
1181 .WillOnce(Invoke([&search_input, &domain]( | 1180 .WillOnce( |
1182 const std::string& sink_id, const std::string& source, | 1181 Invoke([&search_input, &domain]( |
1183 const mojom::SinkSearchCriteriaPtr& search_criteria, | 1182 const std::string& sink_id, const std::string& source, |
1184 const mojom::MediaRouteProvider::SearchSinksCallback& cb) { | 1183 const mojom::SinkSearchCriteriaPtr& search_criteria, |
1185 EXPECT_EQ(search_input, search_criteria->input); | 1184 const mojom::MediaRouteProvider::SearchSinksCallback& cb) { |
1186 EXPECT_EQ(domain, search_criteria->domain); | 1185 EXPECT_EQ(search_input, search_criteria->input); |
1187 cb.Run(kSinkId2); | 1186 EXPECT_EQ(domain, search_criteria->domain); |
1188 })); | 1187 cb.Run(kSinkId2); |
| 1188 })); |
1189 | 1189 |
1190 SinkResponseCallbackHandler sink_handler; | 1190 SinkResponseCallbackHandler sink_handler; |
1191 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1); | 1191 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1); |
1192 MediaSinkSearchResponseCallback sink_callback = base::Bind( | 1192 MediaSinkSearchResponseCallback sink_callback = base::Bind( |
1193 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler)); | 1193 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler)); |
1194 | 1194 |
1195 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback); | 1195 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback); |
1196 | 1196 |
1197 base::RunLoop run_loop; | 1197 base::RunLoop run_loop; |
1198 run_loop.RunUntilIdle(); | 1198 run_loop.RunUntilIdle(); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 EXPECT_CALL(mock_media_route_provider_, | 1571 EXPECT_CALL(mock_media_route_provider_, |
1572 UpdateMediaSinks(MediaSourceForDesktop().id())) | 1572 UpdateMediaSinks(MediaSourceForDesktop().id())) |
1573 .WillOnce(InvokeWithoutArgs([&run_loop2]() { | 1573 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
1574 run_loop2.Quit(); | 1574 run_loop2.Quit(); |
1575 })); | 1575 })); |
1576 | 1576 |
1577 run_loop2.Run(); | 1577 run_loop2.Run(); |
1578 } | 1578 } |
1579 | 1579 |
1580 } // namespace media_router | 1580 } // namespace media_router |
OLD | NEW |