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

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

Issue 1245213002: [MediaRouter] Implement send binary message from PSDImpl to MRPManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass scoped_ptr<>, avoid copying Created 5 years, 4 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 })); 383 }));
384 384
385 SendMessageCallbackHandler handler; 385 SendMessageCallbackHandler handler;
386 EXPECT_CALL(handler, Invoke(true)); 386 EXPECT_CALL(handler, Invoke(true));
387 router()->SendRouteMessage(kRouteId, kMessage, 387 router()->SendRouteMessage(kRouteId, kMessage,
388 base::Bind(&SendMessageCallbackHandler::Invoke, 388 base::Bind(&SendMessageCallbackHandler::Invoke,
389 base::Unretained(&handler))); 389 base::Unretained(&handler)));
390 ProcessEventLoop(); 390 ProcessEventLoop();
391 } 391 }
392 392
393 TEST_F(MediaRouterMojoImplTest, SendRouteBinaryMessage) {
394 scoped_ptr<std::vector<uint8>> expected_binary_data(
395 new std::vector<uint8_t>(8, 1));
396
397 EXPECT_CALL(mock_media_route_provider_,
398 SendRouteBinaryMessageInternal(
399 mojo::String(kRouteId),
400 std::vector<uint8>(*expected_binary_data.get()), _))
401 .WillOnce(Invoke([](
402 const MediaRoute::Id& route_id, const std::vector<uint8>& data,
403 const interfaces::MediaRouteProvider::SendRouteMessageCallback& cb) {
404 cb.Run(true);
405 }));
406
407 SendMessageCallbackHandler handler;
408 EXPECT_CALL(handler, Invoke(true));
409 router()->SendRouteBinaryMessage(
410 kRouteId, expected_binary_data.Pass(),
411 base::Bind(&SendMessageCallbackHandler::Invoke,
412 base::Unretained(&handler)));
413 ProcessEventLoop();
414 }
415
393 TEST_F(MediaRouterMojoImplTest, ListenForRouteMessages) { 416 TEST_F(MediaRouterMojoImplTest, ListenForRouteMessages) {
394 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); 417 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2);
395 mojo_messages[0] = interfaces::RouteMessage::New(); 418 mojo_messages[0] = interfaces::RouteMessage::New();
396 mojo_messages[0]->route_id = "r1"; 419 mojo_messages[0]->route_id = "r1";
397 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 420 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT;
398 mojo_messages[0]->message = "text"; 421 mojo_messages[0]->message = "text";
399 mojo_messages[1] = interfaces::RouteMessage::New(); 422 mojo_messages[1] = interfaces::RouteMessage::New();
400 mojo_messages[1]->route_id = "r2"; 423 mojo_messages[1]->route_id = "r2";
401 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; 424 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY;
402 mojo_messages[1]->data.push_back(1); 425 mojo_messages[1]->data.push_back(1);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>( 540 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>(
518 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy))); 541 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy)));
519 media_router_proxy->RegisterMediaRouteProvider( 542 media_router_proxy->RegisterMediaRouteProvider(
520 media_route_provider_proxy.Pass(), 543 media_route_provider_proxy.Pass(),
521 base::Bind(&RegisterMediaRouteProviderHandler::Invoke, 544 base::Bind(&RegisterMediaRouteProviderHandler::Invoke,
522 base::Unretained(&provide_handler))); 545 base::Unretained(&provide_handler)));
523 message_loop.RunUntilIdle(); 546 message_loop.RunUntilIdle();
524 } 547 }
525 548
526 } // namespace media_router 549 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698