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

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

Issue 1805813002: [Media Router] Wiring for searching route providers for new sinks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarifying pseudo sink comments Created 4 years, 8 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 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DoInvoke(result.route(), result.presentation_id(), result.error(), 115 DoInvoke(result.route(), result.presentation_id(), result.error(),
116 result.result_code()); 116 result.result_code());
117 } 117 }
118 MOCK_METHOD4(DoInvoke, 118 MOCK_METHOD4(DoInvoke,
119 void(const MediaRoute* route, 119 void(const MediaRoute* route,
120 const std::string& presentation_id, 120 const std::string& presentation_id,
121 const std::string& error_text, 121 const std::string& error_text,
122 RouteRequestResult::ResultCode result_code)); 122 RouteRequestResult::ResultCode result_code));
123 }; 123 };
124 124
125 class SinkResponseCallbackHandler {
126 public:
127 MOCK_METHOD1(Invoke, void(const std::string& sink_id));
128 };
129
125 class SendMessageCallbackHandler { 130 class SendMessageCallbackHandler {
126 public: 131 public:
127 MOCK_METHOD1(Invoke, void(bool)); 132 MOCK_METHOD1(Invoke, void(bool));
128 }; 133 };
129 134
130 class ListenForMessagesCallbackHandler { 135 class ListenForMessagesCallbackHandler {
131 public: 136 public:
132 ListenForMessagesCallbackHandler( 137 ListenForMessagesCallbackHandler(
133 ScopedVector<content::PresentationSessionMessage> expected_messages, 138 ScopedVector<content::PresentationSessionMessage> expected_messages,
134 bool pass_ownership) 139 bool pass_ownership)
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 run_loop.Run(); 1186 run_loop.Run();
1182 EXPECT_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id())) 1187 EXPECT_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id()))
1183 .Times(1) 1188 .Times(1)
1184 .WillRepeatedly(Return(false)); 1189 .WillRepeatedly(Return(false));
1185 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId))); 1190 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId)));
1186 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId2))); 1191 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId2)));
1187 ConnectProviderManagerService(); 1192 ConnectProviderManagerService();
1188 ProcessEventLoop(); 1193 ProcessEventLoop();
1189 } 1194 }
1190 1195
1196 TEST_F(MediaRouterMojoImplTest, SearchSinksAndCreateRoute) {
1197 std::string search_input("input");
1198 std::string domain("google.com");
1199 MediaSource media_source(kSource);
1200 MediaRoute expected_route(kRouteId, media_source, kSinkId2, "", false, "",
1201 false);
1202 auto& media_router_proxy = media_router_proxy_;
1203
1204 EXPECT_CALL(
1205 mock_media_route_provider_,
1206 SearchSinksAndCreateRoute_(mojo::String(kSinkId), mojo::String(kSource),
1207 _, _, mojo::String(kOrigin), kInvalidTabId, _,
1208 false, _))
1209 .WillOnce(Invoke([&search_input, &domain, &media_router_proxy](
1210 const mojo::String& sink_id, const mojo::String& source,
1211 const interfaces::SinkSearchCriteriaPtr& search_criteria,
1212 const mojo::String& presentation_id, const mojo::String& origin,
1213 int32_t tab_id, int64_t timeout_millis, bool off_the_record,
1214 const interfaces::MediaRouteProvider::
1215 SearchSinksAndCreateRouteCallback& cb) {
1216 interfaces::MediaRoutePtr route = interfaces::MediaRoute::New();
1217 route->media_source = source;
1218 route->media_sink_id = kSinkId2;
1219 route->media_route_id = kRouteId;
1220 route->description = kDescription;
1221 route->is_local = true;
1222 route->for_display = true;
1223 route->off_the_record = off_the_record;
1224 EXPECT_EQ(search_input, search_criteria->input);
1225 EXPECT_EQ(domain, search_criteria->domain);
1226 media_router_proxy->OnSearchSinkIdReceived(sink_id, kSinkId2);
1227 cb.Run(std::move(route), mojo::String(),
1228 interfaces::RouteRequestResultCode::OK);
1229 }));
1230
1231 base::RunLoop run_loop;
1232 base::RunLoop run_loop2;
1233 SinkResponseCallbackHandler sink_handler;
1234 EXPECT_CALL(sink_handler, Invoke(kSinkId2))
1235 .WillOnce(InvokeWithoutArgs([&run_loop] { run_loop.Quit(); }));
1236 RouteResponseCallbackHandler route_handler;
1237 EXPECT_CALL(route_handler, DoInvoke(Pointee(Equals(expected_route)), Not(""),
1238 "", RouteRequestResult::OK))
1239 .WillOnce(InvokeWithoutArgs([&run_loop2] { run_loop2.Quit(); }));
1240 std::vector<MediaRouteResponseCallback> route_response_callbacks;
1241 MediaSinkSearchResponseCallback sink_callback = base::Bind(
1242 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler));
1243 route_response_callbacks.push_back(base::Bind(
1244 &RouteResponseCallbackHandler::Invoke, base::Unretained(&route_handler)));
1245 router()->SearchSinksAndCreateRoute(
1246 kSinkId, kSource, search_input, domain, GURL(kOrigin), nullptr,
1247 route_response_callbacks, sink_callback,
1248 base::TimeDelta::FromMilliseconds(kTimeoutMillis), false);
1249 run_loop.Run();
1250 run_loop2.Run();
1251 }
1252
1191 class MediaRouterMojoExtensionTest : public ::testing::Test { 1253 class MediaRouterMojoExtensionTest : public ::testing::Test {
1192 public: 1254 public:
1193 MediaRouterMojoExtensionTest() 1255 MediaRouterMojoExtensionTest()
1194 : process_manager_(nullptr), 1256 : process_manager_(nullptr),
1195 message_loop_(mojo::common::MessagePumpMojo::Create()) {} 1257 message_loop_(mojo::common::MessagePumpMojo::Create()) {}
1196 1258
1197 ~MediaRouterMojoExtensionTest() override {} 1259 ~MediaRouterMojoExtensionTest() override {}
1198 1260
1199 protected: 1261 protected:
1200 void SetUp() override { 1262 void SetUp() override {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 EXPECT_CALL(mock_media_route_provider_, 1628 EXPECT_CALL(mock_media_route_provider_,
1567 UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id()))) 1629 UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id())))
1568 .WillOnce(InvokeWithoutArgs([&run_loop2]() { 1630 .WillOnce(InvokeWithoutArgs([&run_loop2]() {
1569 run_loop2.Quit(); 1631 run_loop2.Quit();
1570 })); 1632 }));
1571 1633
1572 run_loop2.Run(); 1634 run_loop2.Run();
1573 } 1635 }
1574 1636
1575 } // namespace media_router 1637 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698