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 <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 30 matching lines...) Expand all Loading... | |
41 const char kSource[] = "source1"; | 41 const char kSource[] = "source1"; |
42 const char kSource2[] = "source2"; | 42 const char kSource2[] = "source2"; |
43 const char kRouteId[] = "routeId"; | 43 const char kRouteId[] = "routeId"; |
44 const char kRouteId2[] = "routeId2"; | 44 const char kRouteId2[] = "routeId2"; |
45 const char kSink[] = "sink"; | 45 const char kSink[] = "sink"; |
46 const char kSink2[] = "sink2"; | 46 const char kSink2[] = "sink2"; |
47 const char kSinkName[] = "sinkName"; | 47 const char kSinkName[] = "sinkName"; |
48 const char kPresentationId[] = "presentationId"; | 48 const char kPresentationId[] = "presentationId"; |
49 const char kOrigin[] = "http://origin/"; | 49 const char kOrigin[] = "http://origin/"; |
50 const int kTabId = 123; | 50 const int kTabId = 123; |
51 const uint8_t kBinaryMessage[] = {0x01, 0x02, 0x03, 0x04}; | |
Kevin M
2015/07/22 18:31:50
uint8
USE s.singapati at gmail.com
2015/07/23 19:52:53
kBinaryMessage is not used now.
| |
51 | 52 |
52 bool ArePresentationSessionMessagesEqual( | 53 bool ArePresentationSessionMessagesEqual( |
53 const content::PresentationSessionMessage* expected, | 54 const content::PresentationSessionMessage* expected, |
54 const content::PresentationSessionMessage* actual) { | 55 const content::PresentationSessionMessage* actual) { |
55 if (expected->presentation_url != actual->presentation_url || | 56 if (expected->presentation_url != actual->presentation_url || |
56 expected->presentation_id != actual->presentation_id || | 57 expected->presentation_id != actual->presentation_id || |
57 expected->type != actual->type) { | 58 expected->type != actual->type) { |
58 return false; | 59 return false; |
59 } | 60 } |
60 return expected->is_binary() ? *(expected->data) == *(actual->data) | 61 return expected->is_binary() ? *(expected->data) == *(actual->data) |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 })); | 384 })); |
384 | 385 |
385 SendMessageCallbackHandler handler; | 386 SendMessageCallbackHandler handler; |
386 EXPECT_CALL(handler, Invoke(true)); | 387 EXPECT_CALL(handler, Invoke(true)); |
387 router()->SendRouteMessage(kRouteId, kMessage, | 388 router()->SendRouteMessage(kRouteId, kMessage, |
388 base::Bind(&SendMessageCallbackHandler::Invoke, | 389 base::Bind(&SendMessageCallbackHandler::Invoke, |
389 base::Unretained(&handler))); | 390 base::Unretained(&handler))); |
390 ProcessEventLoop(); | 391 ProcessEventLoop(); |
391 } | 392 } |
392 | 393 |
394 TEST_F(MediaRouterMojoImplTest, SendRouteBinaryMessage) { | |
395 std::vector<uint8_t> in_data; | |
imcheng
2015/07/22 20:51:31
nit: you can pass in the data range during constru
USE s.singapati at gmail.com
2015/07/23 19:52:53
Done. Filling the array during construction.
| |
396 in_data.assign(kBinaryMessage, kBinaryMessage + sizeof(kBinaryMessage)); | |
Kevin M
2015/07/22 18:31:50
Use arraysize() instead of sizeof()
| |
397 | |
398 EXPECT_CALL(mock_media_route_provider_, | |
399 SendRouteBinaryMessageInternal(mojo::String(kRouteId), | |
400 std::vector<uint8_t>(in_data), _)) | |
401 .WillOnce(Invoke([]( | |
402 const MediaRoute::Id& route_id, const std::vector<uint8_t>& 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, in_data, base::Bind(&SendMessageCallbackHandler::Invoke, | |
411 base::Unretained(&handler))); | |
412 ProcessEventLoop(); | |
413 } | |
414 | |
393 TEST_F(MediaRouterMojoImplTest, ListenForRouteMessages) { | 415 TEST_F(MediaRouterMojoImplTest, ListenForRouteMessages) { |
394 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); | 416 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); |
395 mojo_messages[0] = interfaces::RouteMessage::New(); | 417 mojo_messages[0] = interfaces::RouteMessage::New(); |
396 mojo_messages[0]->route_id = "r1"; | 418 mojo_messages[0]->route_id = "r1"; |
397 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; | 419 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; |
398 mojo_messages[0]->message = "text"; | 420 mojo_messages[0]->message = "text"; |
399 mojo_messages[1] = interfaces::RouteMessage::New(); | 421 mojo_messages[1] = interfaces::RouteMessage::New(); |
400 mojo_messages[1]->route_id = "r2"; | 422 mojo_messages[1]->route_id = "r2"; |
401 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; | 423 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; |
402 mojo_messages[1]->data.push_back(1); | 424 mojo_messages[1]->data.push_back(1); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>( | 539 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>( |
518 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy))); | 540 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy))); |
519 media_router_proxy->RegisterMediaRouteProvider( | 541 media_router_proxy->RegisterMediaRouteProvider( |
520 media_route_provider_proxy.Pass(), | 542 media_route_provider_proxy.Pass(), |
521 base::Bind(&RegisterMediaRouteProviderHandler::Invoke, | 543 base::Bind(&RegisterMediaRouteProviderHandler::Invoke, |
522 base::Unretained(&provide_handler))); | 544 base::Unretained(&provide_handler))); |
523 message_loop.RunUntilIdle(); | 545 message_loop.RunUntilIdle(); |
524 } | 546 } |
525 | 547 |
526 } // namespace media_router | 548 } // namespace media_router |
OLD | NEW |