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

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

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "chrome/browser/media/router/issue.h" 12 #include "chrome/browser/media/router/issue.h"
13 #include "chrome/browser/media/router/media_route.h" 13 #include "chrome/browser/media/router/media_route.h"
14 #include "chrome/browser/media/router/media_router_mojo_test.h" 14 #include "chrome/browser/media/router/media_router_mojo_test.h"
15 #include "chrome/browser/media/router/media_router_type_converters.h" 15 #include "chrome/browser/media/router/media_router_type_converters.h"
16 #include "chrome/browser/media/router/mock_media_router.h" 16 #include "chrome/browser/media/router/mock_media_router.h"
17 #include "chrome/browser/media/router/presentation_session_messages_observer.h"
17 #include "chrome/browser/media/router/test_helper.h" 18 #include "chrome/browser/media/router/test_helper.h"
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
19 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
20 #include "extensions/browser/extension_registry.h" 21 #include "extensions/browser/extension_registry.h"
21 #include "extensions/browser/process_manager.h" 22 #include "extensions/browser/process_manager.h"
22 #include "extensions/browser/process_manager_factory.h" 23 #include "extensions/browser/process_manager_factory.h"
23 #include "media/base/gmock_callback_support.h" 24 #include "media/base/gmock_callback_support.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 using testing::_; 28 using testing::_;
28 using testing::Eq; 29 using testing::Eq;
29 using testing::Invoke; 30 using testing::Invoke;
30 using testing::Mock; 31 using testing::Mock;
32 using testing::Not;
31 using testing::Pointee; 33 using testing::Pointee;
32 using testing::Return; 34 using testing::Return;
33 using testing::ReturnRef; 35 using testing::ReturnRef;
34 using testing::SaveArg; 36 using testing::SaveArg;
35 37
36 namespace media_router { 38 namespace media_router {
37 39
38 namespace { 40 namespace {
39 41
40 const char kDescription[] = "description"; 42 const char kDescription[] = "description";
41 const char kError[] = "error"; 43 const char kError[] = "error";
42 const char kExtensionId[] = "extension1234"; 44 const char kExtensionId[] = "extension1234";
43 const char kMessage[] = "message"; 45 const char kMessage[] = "message";
44 const char kSource[] = "source1"; 46 const char kSource[] = "source1";
45 const char kSource2[] = "source2"; 47 const char kSource2[] = "source2";
46 const char kRouteId[] = "routeId"; 48 const char kRouteId[] = "routeId";
47 const char kRouteId2[] = "routeId2"; 49 const char kRouteId2[] = "routeId2";
48 const char kSink[] = "sink"; 50 const char kSink[] = "sink";
49 const char kSink2[] = "sink2"; 51 const char kSink2[] = "sink2";
50 const char kSinkName[] = "sinkName"; 52 const char kSinkName[] = "sinkName";
51 const char kPresentationId[] = "presentationId"; 53 const char kPresentationId[] = "presentationId";
52 const char kOrigin[] = "http://origin/"; 54 const char kOrigin[] = "http://origin/";
53 const int kTabId = 123; 55 const int kTabId = 123;
54 const uint8 kBinaryMessage[] = {0x01, 0x02, 0x03, 0x04}; 56 const uint8 kBinaryMessage[] = {0x01, 0x02, 0x03, 0x04};
55 57
56 bool ArePresentationSessionMessagesEqual( 58 bool ArePresentationSessionMessagesEqual(
57 const content::PresentationSessionMessage* expected, 59 const content::PresentationSessionMessage* expected,
58 const content::PresentationSessionMessage* actual) { 60 const content::PresentationSessionMessage* actual) {
59 if (expected->presentation_url != actual->presentation_url || 61 if (expected->type != actual->type)
60 expected->presentation_id != actual->presentation_id ||
61 expected->type != actual->type) {
62 return false; 62 return false;
63 } 63
64 return expected->is_binary() ? *(expected->data) == *(actual->data) 64 return expected->is_binary() ? *expected->data == *actual->data
65 : *(expected->message) == *(actual->message); 65 : expected->message == actual->message;
66 } 66 }
67 67
68 interfaces::IssuePtr CreateMojoIssue(const std::string& title) { 68 interfaces::IssuePtr CreateMojoIssue(const std::string& title) {
69 interfaces::IssuePtr mojoIssue = interfaces::Issue::New(); 69 interfaces::IssuePtr mojoIssue = interfaces::Issue::New();
70 mojoIssue->title = title; 70 mojoIssue->title = title;
71 mojoIssue->message = "msg"; 71 mojoIssue->message = "msg";
72 mojoIssue->route_id = ""; 72 mojoIssue->route_id = "";
73 mojoIssue->default_action = interfaces::Issue::ActionType::ACTION_TYPE_OK; 73 mojoIssue->default_action = interfaces::Issue::ActionType::ACTION_TYPE_OK;
74 mojoIssue->secondary_actions = 74 mojoIssue->secondary_actions =
75 mojo::Array<interfaces::Issue::ActionType>::New(0); 75 mojo::Array<interfaces::Issue::ActionType>::New(0);
76 mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING; 76 mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING;
77 mojoIssue->is_blocking = false; 77 mojoIssue->is_blocking = false;
78 mojoIssue->help_url = ""; 78 mojoIssue->help_url = "";
79 return mojoIssue.Pass(); 79 return mojoIssue.Pass();
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 class RouteResponseCallbackHandler { 84 class RouteResponseCallbackHandler {
85 public: 85 public:
86 MOCK_METHOD2(Invoke, 86 MOCK_METHOD3(Invoke,
87 void(const MediaRoute* route, const std::string& error_text)); 87 void(const MediaRoute* route,
88 const std::string& presentation_id,
89 const std::string& error_text));
88 }; 90 };
89 91
90 class SendMessageCallbackHandler { 92 class SendMessageCallbackHandler {
91 public: 93 public:
92 MOCK_METHOD1(Invoke, void(bool)); 94 MOCK_METHOD1(Invoke, void(bool));
93 }; 95 };
94 96
95 class ListenForMessagesCallbackHandler { 97 class ListenForMessagesCallbackHandler {
96 public: 98 public:
97 ListenForMessagesCallbackHandler(scoped_ptr< 99 ListenForMessagesCallbackHandler(
98 ScopedVector<content::PresentationSessionMessage>> expected_messages) 100 ScopedVector<content::PresentationSessionMessage> expected_messages)
99 : expected_messages_(expected_messages.Pass()) {} 101 : expected_messages_(expected_messages.Pass()) {}
100 void Invoke( 102 void Invoke(
101 scoped_ptr<ScopedVector<content::PresentationSessionMessage>> messages) { 103 const ScopedVector<content::PresentationSessionMessage>& messages) {
102 InvokeObserver(); 104 InvokeObserver();
103 EXPECT_EQ(messages->size(), expected_messages_->size()); 105 EXPECT_EQ(messages.size(), expected_messages_.size());
104 const auto& expected = expected_messages_->get(); 106 for (size_t i = 0; i < expected_messages_.size(); ++i) {
105 const auto& actual = messages->get(); 107 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_messages_[i],
106 for (size_t i = 0; i < expected_messages_->size(); ++i) { 108 messages[i]));
107 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected[i], actual[i]));
108 } 109 }
109 } 110 }
110 111
111 MOCK_METHOD0(InvokeObserver, void()); 112 MOCK_METHOD0(InvokeObserver, void());
112 113
113 private: 114 private:
114 scoped_ptr<ScopedVector<content::PresentationSessionMessage>> 115 ScopedVector<content::PresentationSessionMessage> expected_messages_;
115 expected_messages_;
116 }; 116 };
117 117
118 template <typename T> 118 template <typename T>
119 void StoreAndRun(T* result, const base::Closure& closure, const T& result_val) { 119 void StoreAndRun(T* result, const base::Closure& closure, const T& result_val) {
120 *result = result_val; 120 *result = result_val;
121 closure.Run(); 121 closure.Run();
122 } 122 }
123 123
124 class MediaRouterMojoImplTest : public MediaRouterMojoTest { 124 class MediaRouterMojoImplTest : public MediaRouterMojoTest {
125 public: 125 public:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 mojo::String(kOrigin), kTabId, _)) 177 mojo::String(kOrigin), kTabId, _))
178 .WillOnce(Invoke([&route]( 178 .WillOnce(Invoke([&route](
179 const mojo::String& source, const mojo::String& sink, 179 const mojo::String& source, const mojo::String& sink,
180 const mojo::String& presentation_id, const mojo::String& origin, 180 const mojo::String& presentation_id, const mojo::String& origin,
181 int tab_id, 181 int tab_id,
182 const interfaces::MediaRouteProvider::CreateRouteCallback& cb) { 182 const interfaces::MediaRouteProvider::CreateRouteCallback& cb) {
183 cb.Run(route.Pass(), mojo::String()); 183 cb.Run(route.Pass(), mojo::String());
184 })); 184 }));
185 185
186 RouteResponseCallbackHandler handler; 186 RouteResponseCallbackHandler handler;
187 EXPECT_CALL(handler, Invoke(Pointee(Equals(expected_route)), "")); 187 EXPECT_CALL(handler, Invoke(Pointee(Equals(expected_route)), Not(""), ""));
188 std::vector<MediaRouteResponseCallback> route_response_callbacks; 188 std::vector<MediaRouteResponseCallback> route_response_callbacks;
189 route_response_callbacks.push_back(base::Bind( 189 route_response_callbacks.push_back(base::Bind(
190 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); 190 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler)));
191 router()->CreateRoute(kSource, kSink, GURL(kOrigin), kTabId, 191 router()->CreateRoute(kSource, kSink, GURL(kOrigin), kTabId,
192 route_response_callbacks); 192 route_response_callbacks);
193 ProcessEventLoop(); 193 ProcessEventLoop();
194 } 194 }
195 195
196 TEST_F(MediaRouterMojoImplTest, CreateRouteFails) { 196 TEST_F(MediaRouterMojoImplTest, CreateRouteFails) {
197 EXPECT_CALL(mock_media_route_provider_, 197 EXPECT_CALL(mock_media_route_provider_,
198 CreateRoute(mojo::String(kSource), mojo::String(kSink), _, 198 CreateRoute(mojo::String(kSource), mojo::String(kSink), _,
199 mojo::String(kOrigin), kTabId, _)) 199 mojo::String(kOrigin), kTabId, _))
200 .WillOnce(Invoke( 200 .WillOnce(Invoke(
201 [](const mojo::String& source, const mojo::String& sink, 201 [](const mojo::String& source, const mojo::String& sink,
202 const mojo::String& presentation_id, const mojo::String& origin, 202 const mojo::String& presentation_id, const mojo::String& origin,
203 int tab_id, 203 int tab_id,
204 const interfaces::MediaRouteProvider::CreateRouteCallback& cb) { 204 const interfaces::MediaRouteProvider::CreateRouteCallback& cb) {
205 cb.Run(interfaces::MediaRoutePtr(), mojo::String(kError)); 205 cb.Run(interfaces::MediaRoutePtr(), mojo::String(kError));
206 })); 206 }));
207 207
208 RouteResponseCallbackHandler handler; 208 RouteResponseCallbackHandler handler;
209 EXPECT_CALL(handler, Invoke(nullptr, kError)); 209 EXPECT_CALL(handler, Invoke(nullptr, "", kError));
210 std::vector<MediaRouteResponseCallback> route_response_callbacks; 210 std::vector<MediaRouteResponseCallback> route_response_callbacks;
211 route_response_callbacks.push_back(base::Bind( 211 route_response_callbacks.push_back(base::Bind(
212 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); 212 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler)));
213 router()->CreateRoute(kSource, kSink, GURL(kOrigin), kTabId, 213 router()->CreateRoute(kSource, kSink, GURL(kOrigin), kTabId,
214 route_response_callbacks); 214 route_response_callbacks);
215 ProcessEventLoop(); 215 ProcessEventLoop();
216 } 216 }
217 217
218 TEST_F(MediaRouterMojoImplTest, JoinRoute) { 218 TEST_F(MediaRouterMojoImplTest, JoinRoute) {
219 MediaRoute expected_route(kRouteId, MediaSource(std::string(kSource)), 219 MediaRoute expected_route(kRouteId, MediaSource(std::string(kSource)),
(...skipping 13 matching lines...) Expand all
233 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), 233 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId),
234 mojo::String(kOrigin), kTabId, _)) 234 mojo::String(kOrigin), kTabId, _))
235 .WillOnce(Invoke([&route]( 235 .WillOnce(Invoke([&route](
236 const mojo::String& source, const mojo::String& presentation_id, 236 const mojo::String& source, const mojo::String& presentation_id,
237 const mojo::String& origin, int tab_id, 237 const mojo::String& origin, int tab_id,
238 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) { 238 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) {
239 cb.Run(route.Pass(), mojo::String()); 239 cb.Run(route.Pass(), mojo::String());
240 })); 240 }));
241 241
242 RouteResponseCallbackHandler handler; 242 RouteResponseCallbackHandler handler;
243 EXPECT_CALL(handler, Invoke(Pointee(Equals(expected_route)), "")); 243 EXPECT_CALL(handler, Invoke(Pointee(Equals(expected_route)), Not(""), ""));
244 std::vector<MediaRouteResponseCallback> route_response_callbacks; 244 std::vector<MediaRouteResponseCallback> route_response_callbacks;
245 route_response_callbacks.push_back(base::Bind( 245 route_response_callbacks.push_back(base::Bind(
246 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); 246 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler)));
247 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), kTabId, 247 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), kTabId,
248 route_response_callbacks); 248 route_response_callbacks);
249 ProcessEventLoop(); 249 ProcessEventLoop();
250 } 250 }
251 251
252 TEST_F(MediaRouterMojoImplTest, JoinRouteFails) { 252 TEST_F(MediaRouterMojoImplTest, JoinRouteFails) {
253 EXPECT_CALL(mock_media_route_provider_, 253 EXPECT_CALL(mock_media_route_provider_,
254 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), 254 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId),
255 mojo::String(kOrigin), kTabId, _)) 255 mojo::String(kOrigin), kTabId, _))
256 .WillOnce(Invoke( 256 .WillOnce(Invoke(
257 [](const mojo::String& source, const mojo::String& presentation_id, 257 [](const mojo::String& source, const mojo::String& presentation_id,
258 const mojo::String& origin, int tab_id, 258 const mojo::String& origin, int tab_id,
259 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) { 259 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) {
260 cb.Run(interfaces::MediaRoutePtr(), mojo::String(kError)); 260 cb.Run(interfaces::MediaRoutePtr(), mojo::String(kError));
261 })); 261 }));
262 262
263 RouteResponseCallbackHandler handler; 263 RouteResponseCallbackHandler handler;
264 EXPECT_CALL(handler, Invoke(nullptr, kError)); 264 EXPECT_CALL(handler, Invoke(nullptr, "", kError));
265 std::vector<MediaRouteResponseCallback> route_response_callbacks; 265 std::vector<MediaRouteResponseCallback> route_response_callbacks;
266 route_response_callbacks.push_back(base::Bind( 266 route_response_callbacks.push_back(base::Bind(
267 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); 267 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler)));
268 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), kTabId, 268 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), kTabId,
269 route_response_callbacks); 269 route_response_callbacks);
270 ProcessEventLoop(); 270 ProcessEventLoop();
271 } 271 }
272 272
273 TEST_F(MediaRouterMojoImplTest, CloseRoute) { 273 TEST_F(MediaRouterMojoImplTest, CloseRoute) {
274 EXPECT_CALL(mock_media_route_provider_, CloseRoute(mojo::String(kRouteId))); 274 EXPECT_CALL(mock_media_route_provider_, CloseRoute(mojo::String(kRouteId)));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 453
454 SendMessageCallbackHandler handler; 454 SendMessageCallbackHandler handler;
455 EXPECT_CALL(handler, Invoke(true)); 455 EXPECT_CALL(handler, Invoke(true));
456 router()->SendRouteBinaryMessage( 456 router()->SendRouteBinaryMessage(
457 kRouteId, expected_binary_data.Pass(), 457 kRouteId, expected_binary_data.Pass(),
458 base::Bind(&SendMessageCallbackHandler::Invoke, 458 base::Bind(&SendMessageCallbackHandler::Invoke,
459 base::Unretained(&handler))); 459 base::Unretained(&handler)));
460 ProcessEventLoop(); 460 ProcessEventLoop();
461 } 461 }
462 462
463 TEST_F(MediaRouterMojoImplTest, ListenForRouteMessages) { 463 TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesObserver) {
464 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); 464 mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2);
465 mojo_messages[0] = interfaces::RouteMessage::New(); 465 mojo_messages[0] = interfaces::RouteMessage::New();
466 mojo_messages[0]->route_id = "r1";
467 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; 466 mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT;
468 mojo_messages[0]->message = "text"; 467 mojo_messages[0]->message = "text";
469 mojo_messages[1] = interfaces::RouteMessage::New(); 468 mojo_messages[1] = interfaces::RouteMessage::New();
470 mojo_messages[1]->route_id = "r2";
471 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; 469 mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY;
472 mojo_messages[1]->data.push_back(1); 470 mojo_messages[1]->data.push_back(1);
473 471
474 scoped_ptr<ScopedVector<content::PresentationSessionMessage>> 472 ScopedVector<content::PresentationSessionMessage> expected_messages;
475 expected_messages( 473 scoped_ptr<content::PresentationSessionMessage> message;
476 new ScopedVector<content::PresentationSessionMessage>()); 474 message.reset(new content::PresentationSessionMessage(
477 expected_messages->push_back( 475 content::PresentationMessageType::TEXT));
478 content::PresentationSessionMessage::CreateStringMessage( 476 message->message = "text";
479 "", "", make_scoped_ptr(new std::string("text")))); 477 expected_messages.push_back(message.Pass());
480 scoped_ptr<std::vector<uint8_t>> expected_binary_data(
481 new std::vector<uint8_t>(1, 1));
482 expected_messages->push_back(
483 content::PresentationSessionMessage::CreateArrayBufferMessage(
484 "", "", expected_binary_data.Pass()));
485 478
486 EXPECT_CALL(mock_media_route_provider_, ListenForRouteMessagesInteral(_, _)) 479 message.reset(new content::PresentationSessionMessage(
487 .WillOnce(Invoke([&mojo_messages]( 480 content::PresentationMessageType::ARRAY_BUFFER));
488 const std::vector<mojo::String>& route_ids, 481 message->data.reset(new std::vector<uint8_t>(1, 1));
489 const interfaces::MediaRouteProvider::ListenForRouteMessagesCallback& 482 expected_messages.push_back(message.Pass());
490 cb) { cb.Run(mojo_messages.Pass()); })); 483
484 MediaRoute::Id expected_route_id("foo");
485 interfaces::MediaRouteProvider::ListenForRouteMessagesCallback mojo_callback;
486 EXPECT_CALL(mock_media_route_provider_,
487 ListenForRouteMessages(Eq(expected_route_id), _))
488 .WillOnce(SaveArg<1>(&mojo_callback));
491 489
492 ListenForMessagesCallbackHandler handler(expected_messages.Pass()); 490 ListenForMessagesCallbackHandler handler(expected_messages.Pass());
493 EXPECT_CALL(handler, InvokeObserver()); 491 EXPECT_CALL(handler, InvokeObserver());
494 std::vector<MediaRoute::Id> route_ids; 492 // Creating PresentationSessionMessagesObserver will register itself to the
495 router()->ListenForRouteMessages( 493 // MediaRouter, which in turn will start listening for route messages.
496 route_ids, base::Bind(&ListenForMessagesCallbackHandler::Invoke, 494 scoped_ptr<PresentationSessionMessagesObserver> observer(
497 base::Unretained(&handler))); 495 new PresentationSessionMessagesObserver(
496 base::Bind(&ListenForMessagesCallbackHandler::Invoke,
497 base::Unretained(&handler)),
498 expected_route_id, router()));
499 ProcessEventLoop();
500
501 // Simulate messages by invoking the saved mojo callback.
502 // We expect one more ListenForRouteMessages call since |observer| was
503 // still registered when the first set of messages arrived.
504 mojo_callback.Run(mojo_messages.Pass());
505 interfaces::MediaRouteProvider::ListenForRouteMessagesCallback
506 mojo_callback_2;
507 EXPECT_CALL(mock_media_route_provider_, ListenForRouteMessages(_, _))
508 .WillOnce(SaveArg<1>(&mojo_callback_2));
509 ProcessEventLoop();
510
511 // Stop listening for messages. In particular, MediaRouterMojoImpl will not
512 // call ListenForRouteMessages again when it sees there are no more observers.
513 mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1);
514 mojo_messages_2[0] = interfaces::RouteMessage::New();
515 mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT;
516 mojo_messages_2[0]->message = "foo";
517 observer.reset();
518 mojo_callback_2.Run(mojo_messages_2.Pass());
498 ProcessEventLoop(); 519 ProcessEventLoop();
499 } 520 }
500 521
501 TEST_F(MediaRouterMojoImplTest, QueuedWhileAsleep) { 522 TEST_F(MediaRouterMojoImplTest, QueuedWhileAsleep) {
502 EXPECT_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id())) 523 EXPECT_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id()))
503 .Times(2) 524 .Times(2)
504 .WillRepeatedly(Return(true)); 525 .WillRepeatedly(Return(true));
505 EXPECT_CALL(mock_event_page_tracker_, WakeEventPage(extension_id(), _)) 526 EXPECT_CALL(mock_event_page_tracker_, WakeEventPage(extension_id(), _))
506 .Times(2) 527 .Times(2)
507 .WillRepeatedly(Return(true)); 528 .WillRepeatedly(Return(true));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>( 608 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>(
588 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy))); 609 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy)));
589 media_router_proxy->RegisterMediaRouteProvider( 610 media_router_proxy->RegisterMediaRouteProvider(
590 media_route_provider_proxy.Pass(), 611 media_route_provider_proxy.Pass(),
591 base::Bind(&RegisterMediaRouteProviderHandler::Invoke, 612 base::Bind(&RegisterMediaRouteProviderHandler::Invoke,
592 base::Unretained(&provide_handler))); 613 base::Unretained(&provide_handler)));
593 message_loop.RunUntilIdle(); 614 message_loop.RunUntilIdle();
594 } 615 }
595 616
596 } // namespace media_router 617 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698