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

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

Issue 2679893002: [Media Router] Add ProvideSinks() Mojo API (Closed)
Patch Set: merge with https://codereview.chromium.org/2675033002/ Created 3 years, 10 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1); 1138 EXPECT_CALL(sink_handler, Invoke(kSinkId2)).Times(1);
1139 MediaSinkSearchResponseCallback sink_callback = base::Bind( 1139 MediaSinkSearchResponseCallback sink_callback = base::Bind(
1140 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler)); 1140 &SinkResponseCallbackHandler::Invoke, base::Unretained(&sink_handler));
1141 1141
1142 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback); 1142 router()->SearchSinks(kSinkId, kSource, search_input, domain, sink_callback);
1143 1143
1144 base::RunLoop run_loop; 1144 base::RunLoop run_loop;
1145 run_loop.RunUntilIdle(); 1145 run_loop.RunUntilIdle();
1146 } 1146 }
1147 1147
1148 TEST_F(MediaRouterMojoImplTest, ProvideSinks) {
1149 MediaRouter::MediaSinkList sinks;
1150 MediaSink sink(kSinkId, kSinkName, MediaSink::IconType::CAST);
1151 CastSinkExtraData extra_data;
1152 extra_data.capabilities = 2;
1153 extra_data.cast_channel_id = 3;
1154 MediaSinkInternal expected_sink(sink, extra_data);
1155 sinks.push_back(expected_sink);
1156 std::string provider_name = "cast";
1157
1158 EXPECT_CALL(mock_media_route_provider_, ProvideSinks(_, _))
1159 .WillOnce(Invoke([&](const std::string& actual_provider_name,
1160 const MediaRouter::MediaSinkList& actual_sinks) {
mark a. foltz 2017/03/01 06:31:43 Does MediaSink implement == and a copy constructor
zhaobin 2017/03/02 20:24:04 Done.
1161 EXPECT_EQ(provider_name, actual_provider_name);
1162 EXPECT_EQ(size_t(1), actual_sinks.size());
1163
1164 MediaSinkInternal actual_sink(actual_sinks[0]);
1165 EXPECT_EQ(kSinkId, actual_sink.sink().id());
1166 EXPECT_EQ(kSinkName, actual_sink.sink().name());
1167 EXPECT_EQ(MediaSink::IconType::CAST, actual_sink.sink().icon_type());
1168 EXPECT_FALSE(actual_sink.sink().description());
1169 EXPECT_FALSE(actual_sink.sink().domain());
1170
1171 EXPECT_TRUE(actual_sink.is_cast_sink());
1172 EXPECT_FALSE(actual_sink.cast_data().model_name);
1173 EXPECT_EQ(extra_data.capabilities,
1174 actual_sink.cast_data().capabilities);
1175 EXPECT_EQ(extra_data.cast_channel_id,
1176 actual_sink.cast_data().cast_channel_id);
1177 }));
1178
1179 router()->ProvideSinks(provider_name, sinks);
1180
1181 base::RunLoop run_loop;
1182 run_loop.RunUntilIdle();
1183 }
1184
1148 class MediaRouterMojoExtensionTest : public ::testing::Test { 1185 class MediaRouterMojoExtensionTest : public ::testing::Test {
1149 public: 1186 public:
1150 MediaRouterMojoExtensionTest() : process_manager_(nullptr) {} 1187 MediaRouterMojoExtensionTest() : process_manager_(nullptr) {}
1151 1188
1152 ~MediaRouterMojoExtensionTest() override {} 1189 ~MediaRouterMojoExtensionTest() override {}
1153 1190
1154 protected: 1191 protected:
1155 void SetUp() override { 1192 void SetUp() override {
1156 // Set the extension's version number to be identical to the browser's. 1193 // Set the extension's version number to be identical to the browser's.
1157 extension_ = 1194 extension_ =
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 EXPECT_CALL(mock_media_route_provider_, 1555 EXPECT_CALL(mock_media_route_provider_,
1519 UpdateMediaSinks(MediaSourceForDesktop().id())) 1556 UpdateMediaSinks(MediaSourceForDesktop().id()))
1520 .WillOnce(InvokeWithoutArgs([&run_loop2]() { 1557 .WillOnce(InvokeWithoutArgs([&run_loop2]() {
1521 run_loop2.Quit(); 1558 run_loop2.Quit();
1522 })); 1559 }));
1523 1560
1524 run_loop2.Run(); 1561 run_loop2.Run();
1525 } 1562 }
1526 1563
1527 } // namespace media_router 1564 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698