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

Side by Side Diff: content/browser/presentation/presentation_service_impl_unittest.cc

Issue 2181163003: [Presentation API] Convert presentation.mojom to new wrapper types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to dcheng@ comments Created 4 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 "content/browser/presentation/presentation_service_impl.h" 5 #include "content/browser/presentation/presentation_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 28 matching lines...) Expand all
39 namespace { 39 namespace {
40 40
41 // Matches mojo structs. 41 // Matches mojo structs.
42 MATCHER_P(Equals, expected, "") { 42 MATCHER_P(Equals, expected, "") {
43 return expected.Equals(arg); 43 return expected.Equals(arg);
44 } 44 }
45 45
46 const char *const kPresentationId = "presentationId"; 46 const char *const kPresentationId = "presentationId";
47 const char *const kPresentationUrl = "http://foo.com/index.html"; 47 const char *const kPresentationUrl = "http://foo.com/index.html";
48 48
49 bool ArePresentationSessionMessagesEqual( 49 bool ArePresentationSessionMessagesEqual(
imcheng 2016/07/27 20:59:38 Do we still need this or can we use operator== dir
50 const blink::mojom::SessionMessage* expected, 50 const blink::mojom::SessionMessage* expected,
51 const blink::mojom::SessionMessage* actual) { 51 const blink::mojom::SessionMessage* actual) {
52 return expected->type == actual->type && 52 return expected->type == actual->type &&
53 expected->message == actual->message && 53 expected->message == actual->message && expected->data == actual->data;
54 expected->data.Equals(actual->data);
55 } 54 }
56 55
57 void DoNothing(blink::mojom::PresentationSessionInfoPtr info, 56 void DoNothing(blink::mojom::PresentationSessionInfoPtr info,
58 blink::mojom::PresentationErrorPtr error) {} 57 blink::mojom::PresentationErrorPtr error) {}
59 58
60 } // namespace 59 } // namespace
61 60
62 class MockPresentationServiceDelegate : public PresentationServiceDelegate { 61 class MockPresentationServiceDelegate : public PresentationServiceDelegate {
63 public: 62 public:
64 MOCK_METHOD3(AddObserver, 63 MOCK_METHOD3(AddObserver,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 144 }
146 145
147 private: 146 private:
148 bool screen_availability_listening_supported_ = true; 147 bool screen_availability_listening_supported_ = true;
149 }; 148 };
150 149
151 class MockPresentationServiceClient 150 class MockPresentationServiceClient
152 : public blink::mojom::PresentationServiceClient { 151 : public blink::mojom::PresentationServiceClient {
153 public: 152 public:
154 MOCK_METHOD2(OnScreenAvailabilityUpdated, 153 MOCK_METHOD2(OnScreenAvailabilityUpdated,
155 void(const mojo::String& url, bool available)); 154 void(const std::string& url, bool available));
156 void OnConnectionStateChanged( 155 void OnConnectionStateChanged(
157 blink::mojom::PresentationSessionInfoPtr connection, 156 blink::mojom::PresentationSessionInfoPtr connection,
158 blink::mojom::PresentationConnectionState new_state) override { 157 blink::mojom::PresentationConnectionState new_state) override {
159 OnConnectionStateChanged(*connection, new_state); 158 OnConnectionStateChanged(*connection, new_state);
160 } 159 }
161 MOCK_METHOD2(OnConnectionStateChanged, 160 MOCK_METHOD2(OnConnectionStateChanged,
162 void(const blink::mojom::PresentationSessionInfo& connection, 161 void(const blink::mojom::PresentationSessionInfo& connection,
163 blink::mojom::PresentationConnectionState new_state)); 162 blink::mojom::PresentationConnectionState new_state));
164 163
165 void OnConnectionClosed( 164 void OnConnectionClosed(
166 blink::mojom::PresentationSessionInfoPtr connection, 165 blink::mojom::PresentationSessionInfoPtr connection,
167 blink::mojom::PresentationConnectionCloseReason reason, 166 blink::mojom::PresentationConnectionCloseReason reason,
168 const mojo::String& message) override { 167 const std::string& message) override {
169 OnConnectionClosed(*connection, reason, message); 168 OnConnectionClosed(*connection, reason, message);
170 } 169 }
171 MOCK_METHOD3(OnConnectionClosed, 170 MOCK_METHOD3(OnConnectionClosed,
172 void(const blink::mojom::PresentationSessionInfo& connection, 171 void(const blink::mojom::PresentationSessionInfo& connection,
173 blink::mojom::PresentationConnectionCloseReason reason, 172 blink::mojom::PresentationConnectionCloseReason reason,
174 const mojo::String& message)); 173 const std::string& message));
175 174
176 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const mojo::String& url)); 175 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const std::string& url));
177 176
178 void OnSessionMessagesReceived( 177 void OnSessionMessagesReceived(
179 blink::mojom::PresentationSessionInfoPtr session_info, 178 blink::mojom::PresentationSessionInfoPtr session_info,
180 mojo::Array<blink::mojom::SessionMessagePtr> messages) override { 179 std::vector<blink::mojom::SessionMessagePtr> messages) override {
181 messages_received_ = std::move(messages); 180 messages_received_ = std::move(messages);
182 MessagesReceived(); 181 MessagesReceived();
183 } 182 }
184 MOCK_METHOD0(MessagesReceived, void()); 183 MOCK_METHOD0(MessagesReceived, void());
185 184
186 void OnDefaultSessionStarted( 185 void OnDefaultSessionStarted(
187 blink::mojom::PresentationSessionInfoPtr session_info) override { 186 blink::mojom::PresentationSessionInfoPtr session_info) override {
188 OnDefaultSessionStarted(*session_info); 187 OnDefaultSessionStarted(*session_info);
189 } 188 }
190 MOCK_METHOD1(OnDefaultSessionStarted, 189 MOCK_METHOD1(OnDefaultSessionStarted,
191 void(const blink::mojom::PresentationSessionInfo& session_info)); 190 void(const blink::mojom::PresentationSessionInfo& session_info));
192 191
193 mojo::Array<blink::mojom::SessionMessagePtr> messages_received_; 192 std::vector<blink::mojom::SessionMessagePtr> messages_received_;
194 }; 193 };
195 194
196 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { 195 class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
197 public: 196 public:
198 PresentationServiceImplTest() {} 197 PresentationServiceImplTest() {}
199 198
200 void SetUp() override { 199 void SetUp() override {
201 RenderViewHostImplTestHarness::SetUp(); 200 RenderViewHostImplTestHarness::SetUp();
202 201
203 auto request = mojo::GetProxy(&service_ptr_); 202 auto request = mojo::GetProxy(&service_ptr_);
(...skipping 13 matching lines...) Expand all
217 216
218 void TearDown() override { 217 void TearDown() override {
219 service_ptr_.reset(); 218 service_ptr_.reset();
220 if (service_impl_.get()) { 219 if (service_impl_.get()) {
221 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1); 220 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
222 service_impl_.reset(); 221 service_impl_.reset();
223 } 222 }
224 RenderViewHostImplTestHarness::TearDown(); 223 RenderViewHostImplTestHarness::TearDown();
225 } 224 }
226 225
227 void ListenForScreenAvailabilityAndWait( 226 void ListenForScreenAvailabilityAndWait(const std::string& url,
228 const mojo::String& url, bool delegate_success) { 227 bool delegate_success) {
229 base::RunLoop run_loop; 228 base::RunLoop run_loop;
230 // This will call to |service_impl_| via mojo. Process the message 229 // This will call to |service_impl_| via mojo. Process the message
231 // using RunLoop. 230 // using RunLoop.
232 // The callback shouldn't be invoked since there is no availability 231 // The callback shouldn't be invoked since there is no availability
233 // result yet. 232 // result yet.
234 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener()) 233 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener())
235 .WillOnce(DoAll( 234 .WillOnce(DoAll(
236 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 235 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
237 Return(delegate_success))); 236 Return(delegate_success)));
238 service_ptr_->ListenForScreenAvailability(url); 237 service_ptr_->ListenForScreenAvailability(url);
(...skipping 16 matching lines...) Expand all
255 run_loop_quit_closure_.Reset(); 254 run_loop_quit_closure_.Reset();
256 } 255 }
257 256
258 void SimulateScreenAvailabilityChangeAndWait( 257 void SimulateScreenAvailabilityChangeAndWait(
259 const std::string& url, bool available) { 258 const std::string& url, bool available) {
260 auto listener_it = service_impl_->screen_availability_listeners_.find(url); 259 auto listener_it = service_impl_->screen_availability_listeners_.find(url);
261 ASSERT_TRUE(listener_it->second); 260 ASSERT_TRUE(listener_it->second);
262 261
263 base::RunLoop run_loop; 262 base::RunLoop run_loop;
264 EXPECT_CALL(mock_client_, 263 EXPECT_CALL(mock_client_,
265 OnScreenAvailabilityUpdated(mojo::String(url), available)) 264 OnScreenAvailabilityUpdated(url, available))
266 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 265 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
267 listener_it->second->OnScreenAvailabilityChanged(available); 266 listener_it->second->OnScreenAvailabilityChanged(available);
268 run_loop.Run(); 267 run_loop.Run();
269 } 268 }
270 269
271 void ExpectReset() { 270 void ExpectReset() {
272 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1); 271 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1);
273 } 272 }
274 273
275 void ExpectCleanState() { 274 void ExpectCleanState() {
276 EXPECT_TRUE(service_impl_->default_presentation_url_.empty()); 275 EXPECT_TRUE(service_impl_->default_presentation_url_.empty());
(...skipping 15 matching lines...) Expand all
292 void ExpectNewSessionCallbackError( 291 void ExpectNewSessionCallbackError(
293 blink::mojom::PresentationSessionInfoPtr info, 292 blink::mojom::PresentationSessionInfoPtr info,
294 blink::mojom::PresentationErrorPtr error) { 293 blink::mojom::PresentationErrorPtr error) {
295 EXPECT_TRUE(info.is_null()); 294 EXPECT_TRUE(info.is_null());
296 EXPECT_FALSE(error.is_null()); 295 EXPECT_FALSE(error.is_null());
297 if (!run_loop_quit_closure_.is_null()) 296 if (!run_loop_quit_closure_.is_null())
298 run_loop_quit_closure_.Run(); 297 run_loop_quit_closure_.Run();
299 } 298 }
300 299
301 void ExpectSessionMessages( 300 void ExpectSessionMessages(
302 const mojo::Array<blink::mojom::SessionMessagePtr>& expected_msgs, 301 const std::vector<blink::mojom::SessionMessagePtr>& expected_msgs,
303 const mojo::Array<blink::mojom::SessionMessagePtr>& actual_msgs) { 302 const std::vector<blink::mojom::SessionMessagePtr>& actual_msgs) {
304 EXPECT_EQ(expected_msgs.size(), actual_msgs.size()); 303 EXPECT_EQ(expected_msgs.size(), actual_msgs.size());
305 for (size_t i = 0; i < actual_msgs.size(); ++i) { 304 for (size_t i = 0; i < actual_msgs.size(); ++i) {
306 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_msgs[i].get(), 305 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_msgs[i].get(),
307 actual_msgs[i].get())); 306 actual_msgs[i].get()));
308 } 307 }
309 } 308 }
310 309
311 void ExpectSendSessionMessageCallback(bool success) { 310 void ExpectSendSessionMessageCallback(bool success) {
312 EXPECT_TRUE(success); 311 EXPECT_TRUE(success);
313 EXPECT_FALSE(service_impl_->send_message_callback_); 312 EXPECT_FALSE(service_impl_->send_message_callback_);
314 if (!run_loop_quit_closure_.is_null()) 313 if (!run_loop_quit_closure_.is_null())
315 run_loop_quit_closure_.Run(); 314 run_loop_quit_closure_.Run();
316 } 315 }
317 316
318 void RunListenForSessionMessages(const std::string& text_msg, 317 void RunListenForSessionMessages(const std::string& text_msg,
319 const std::vector<uint8_t>& binary_data, 318 const std::vector<uint8_t>& binary_data,
320 bool pass_ownership) { 319 bool pass_ownership) {
321 mojo::Array<blink::mojom::SessionMessagePtr> expected_msgs(2); 320 std::vector<blink::mojom::SessionMessagePtr> expected_msgs(2);
322 expected_msgs[0] = blink::mojom::SessionMessage::New(); 321 expected_msgs[0] = blink::mojom::SessionMessage::New();
323 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT; 322 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT;
324 expected_msgs[0]->message = text_msg; 323 expected_msgs[0]->message = text_msg;
325 expected_msgs[1] = blink::mojom::SessionMessage::New(); 324 expected_msgs[1] = blink::mojom::SessionMessage::New();
326 expected_msgs[1]->type = 325 expected_msgs[1]->type =
327 blink::mojom::PresentationMessageType::ARRAY_BUFFER; 326 blink::mojom::PresentationMessageType::ARRAY_BUFFER;
328 expected_msgs[1]->data = mojo::Array<uint8_t>::From(binary_data); 327 expected_msgs[1]->data = std::vector<uint8_t>(binary_data);
329 328
330 blink::mojom::PresentationSessionInfoPtr session( 329 blink::mojom::PresentationSessionInfoPtr session(
331 blink::mojom::PresentationSessionInfo::New()); 330 blink::mojom::PresentationSessionInfo::New());
332 session->url = kPresentationUrl; 331 session->url = kPresentationUrl;
333 session->id = kPresentationId; 332 session->id = kPresentationId;
334 333
335 PresentationSessionMessageCallback message_cb; 334 PresentationSessionMessageCallback message_cb;
336 { 335 {
337 base::RunLoop run_loop; 336 base::RunLoop run_loop;
338 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _)) 337 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _))
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 base::RunLoop run_loop; 512 base::RunLoop run_loop;
514 PresentationConnectionStateChangeInfo closed_info( 513 PresentationConnectionStateChangeInfo closed_info(
515 PRESENTATION_CONNECTION_STATE_CLOSED); 514 PRESENTATION_CONNECTION_STATE_CLOSED);
516 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; 515 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY;
517 closed_info.message = "Foo"; 516 closed_info.message = "Foo";
518 517
519 EXPECT_CALL(mock_client_, 518 EXPECT_CALL(mock_client_,
520 OnConnectionClosed( 519 OnConnectionClosed(
521 Equals(presentation_connection), 520 Equals(presentation_connection),
522 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY, 521 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY,
523 mojo::String("Foo"))) 522 "Foo"))
524 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 523 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
525 state_changed_cb.Run(closed_info); 524 state_changed_cb.Run(closed_info);
526 run_loop.Run(); 525 run_loop.Run();
527 } 526 }
528 } 527 }
529 528
530 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) { 529 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) {
531 EXPECT_CALL(mock_delegate_, 530 EXPECT_CALL(mock_delegate_,
532 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _)) 531 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _))
533 .Times(1); 532 .Times(1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 .WillOnce(DoAll( 572 .WillOnce(DoAll(
574 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 573 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
575 SaveArg<4>(&error_cb))); 574 SaveArg<4>(&error_cb)));
576 run_loop.Run(); 575 run_loop.Run();
577 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); 576 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
578 SaveQuitClosureAndRunLoop(); 577 SaveQuitClosureAndRunLoop();
579 } 578 }
580 579
581 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) { 580 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) {
582 service_ptr_->JoinSession( 581 service_ptr_->JoinSession(
583 kPresentationUrl, 582 kPresentationUrl, base::Optional<std::string>(kPresentationId),
584 kPresentationId, 583 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
585 base::Bind( 584 base::Unretained(this)));
586 &PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
587 base::Unretained(this)));
588 base::RunLoop run_loop; 585 base::RunLoop run_loop;
589 base::Callback<void(const PresentationSessionInfo&)> success_cb; 586 base::Callback<void(const PresentationSessionInfo&)> success_cb;
590 EXPECT_CALL(mock_delegate_, JoinSession( 587 EXPECT_CALL(mock_delegate_, JoinSession(
591 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) 588 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
592 .WillOnce(DoAll( 589 .WillOnce(DoAll(
593 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 590 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
594 SaveArg<4>(&success_cb))); 591 SaveArg<4>(&success_cb)));
595 run_loop.Run(); 592 run_loop.Run();
596 593
597 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) 594 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
598 .Times(1); 595 .Times(1);
599 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId)); 596 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId));
600 SaveQuitClosureAndRunLoop(); 597 SaveQuitClosureAndRunLoop();
601 } 598 }
602 599
603 TEST_F(PresentationServiceImplTest, JoinSessionError) { 600 TEST_F(PresentationServiceImplTest, JoinSessionError) {
604 service_ptr_->JoinSession( 601 service_ptr_->JoinSession(
605 kPresentationUrl, 602 kPresentationUrl, base::Optional<std::string>(kPresentationId),
606 kPresentationId, 603 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError,
607 base::Bind( 604 base::Unretained(this)));
608 &PresentationServiceImplTest::ExpectNewSessionCallbackError,
609 base::Unretained(this)));
610 base::RunLoop run_loop; 605 base::RunLoop run_loop;
611 base::Callback<void(const PresentationError&)> error_cb; 606 base::Callback<void(const PresentationError&)> error_cb;
612 EXPECT_CALL(mock_delegate_, JoinSession( 607 EXPECT_CALL(mock_delegate_, JoinSession(
613 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) 608 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
614 .WillOnce(DoAll( 609 .WillOnce(DoAll(
615 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 610 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
616 SaveArg<5>(&error_cb))); 611 SaveArg<5>(&error_cb)));
617 run_loop.Run(); 612 run_loop.Run();
618 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); 613 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
619 SaveQuitClosureAndRunLoop(); 614 SaveQuitClosureAndRunLoop();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 std::vector<uint8_t> data; 707 std::vector<uint8_t> data;
713 data.assign(buffer, buffer + sizeof(buffer)); 708 data.assign(buffer, buffer + sizeof(buffer));
714 709
715 blink::mojom::PresentationSessionInfoPtr session( 710 blink::mojom::PresentationSessionInfoPtr session(
716 blink::mojom::PresentationSessionInfo::New()); 711 blink::mojom::PresentationSessionInfo::New());
717 session->url = kPresentationUrl; 712 session->url = kPresentationUrl;
718 session->id = kPresentationId; 713 session->id = kPresentationId;
719 blink::mojom::SessionMessagePtr message_request( 714 blink::mojom::SessionMessagePtr message_request(
720 blink::mojom::SessionMessage::New()); 715 blink::mojom::SessionMessage::New());
721 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; 716 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
722 message_request->data = mojo::Array<uint8_t>::From(data); 717 message_request->data = data;
723 service_ptr_->SendSessionMessage( 718 service_ptr_->SendSessionMessage(
724 std::move(session), std::move(message_request), 719 std::move(session), std::move(message_request),
725 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 720 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
726 base::Unretained(this))); 721 base::Unretained(this)));
727 722
728 base::RunLoop run_loop; 723 base::RunLoop run_loop;
729 base::Callback<void(bool)> send_message_cb; 724 base::Callback<void(bool)> send_message_cb;
730 PresentationSessionMessage* test_message = nullptr; 725 PresentationSessionMessage* test_message = nullptr;
731 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 726 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
732 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 727 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 23 matching lines...) Expand all
756 std::vector<uint8_t> data; 751 std::vector<uint8_t> data;
757 data.assign(buffer, buffer + sizeof(buffer)); 752 data.assign(buffer, buffer + sizeof(buffer));
758 753
759 blink::mojom::PresentationSessionInfoPtr session( 754 blink::mojom::PresentationSessionInfoPtr session(
760 blink::mojom::PresentationSessionInfo::New()); 755 blink::mojom::PresentationSessionInfo::New());
761 session->url = kPresentationUrl; 756 session->url = kPresentationUrl;
762 session->id = kPresentationId; 757 session->id = kPresentationId;
763 blink::mojom::SessionMessagePtr message_request( 758 blink::mojom::SessionMessagePtr message_request(
764 blink::mojom::SessionMessage::New()); 759 blink::mojom::SessionMessage::New());
765 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; 760 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
766 message_request->data = mojo::Array<uint8_t>::From(data); 761 message_request->data = data;
767 service_ptr_->SendSessionMessage( 762 service_ptr_->SendSessionMessage(
768 std::move(session), std::move(message_request), 763 std::move(session), std::move(message_request),
769 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 764 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
770 base::Unretained(this))); 765 base::Unretained(this)));
771 766
772 base::RunLoop run_loop; 767 base::RunLoop run_loop;
773 base::Callback<void(bool)> send_message_cb; 768 base::Callback<void(bool)> send_message_cb;
774 PresentationSessionMessage* test_message = nullptr; 769 PresentationSessionMessage* test_message = nullptr;
775 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 770 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
776 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 771 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 10 matching lines...) Expand all
787 std::vector<uint8_t> data; 782 std::vector<uint8_t> data;
788 data.assign(buffer, buffer + sizeof(buffer)); 783 data.assign(buffer, buffer + sizeof(buffer));
789 784
790 blink::mojom::PresentationSessionInfoPtr session( 785 blink::mojom::PresentationSessionInfoPtr session(
791 blink::mojom::PresentationSessionInfo::New()); 786 blink::mojom::PresentationSessionInfo::New());
792 session->url = kPresentationUrl; 787 session->url = kPresentationUrl;
793 session->id = kPresentationId; 788 session->id = kPresentationId;
794 blink::mojom::SessionMessagePtr message_request( 789 blink::mojom::SessionMessagePtr message_request(
795 blink::mojom::SessionMessage::New()); 790 blink::mojom::SessionMessage::New());
796 message_request->type = blink::mojom::PresentationMessageType::BLOB; 791 message_request->type = blink::mojom::PresentationMessageType::BLOB;
797 message_request->data = mojo::Array<uint8_t>::From(data); 792 message_request->data = data;
798 service_ptr_->SendSessionMessage( 793 service_ptr_->SendSessionMessage(
799 std::move(session), std::move(message_request), 794 std::move(session), std::move(message_request),
800 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 795 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
801 base::Unretained(this))); 796 base::Unretained(this)));
802 797
803 base::RunLoop run_loop; 798 base::RunLoop run_loop;
804 base::Callback<void(bool)> send_message_cb; 799 base::Callback<void(bool)> send_message_cb;
805 PresentationSessionMessage* test_message = nullptr; 800 PresentationSessionMessage* test_message = nullptr;
806 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 801 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
807 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 802 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 mock_delegate_.set_screen_availability_listening_supported(false); 845 mock_delegate_.set_screen_availability_listening_supported(false);
851 base::RunLoop run_loop; 846 base::RunLoop run_loop;
852 EXPECT_CALL(mock_client_, 847 EXPECT_CALL(mock_client_,
853 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) 848 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl)))
854 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 849 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
855 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); 850 ListenForScreenAvailabilityAndWait(kPresentationUrl, false);
856 run_loop.Run(); 851 run_loop.Run();
857 } 852 }
858 853
859 } // namespace content 854 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698