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

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

Issue 2196143002: Revert of [Presentation API] Convert presentation.mojom to new wrapper types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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(
50 const blink::mojom::SessionMessage* expected,
51 const blink::mojom::SessionMessage* actual) {
52 return expected->type == actual->type &&
53 expected->message == actual->message &&
54 expected->data.Equals(actual->data);
55 }
56
49 void DoNothing(blink::mojom::PresentationSessionInfoPtr info, 57 void DoNothing(blink::mojom::PresentationSessionInfoPtr info,
50 blink::mojom::PresentationErrorPtr error) {} 58 blink::mojom::PresentationErrorPtr error) {}
51 59
52 } // namespace 60 } // namespace
53 61
54 class MockPresentationServiceDelegate : public PresentationServiceDelegate { 62 class MockPresentationServiceDelegate : public PresentationServiceDelegate {
55 public: 63 public:
56 MOCK_METHOD3(AddObserver, 64 MOCK_METHOD3(AddObserver,
57 void(int render_process_id, 65 void(int render_process_id,
58 int render_frame_id, 66 int render_frame_id,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 145 }
138 146
139 private: 147 private:
140 bool screen_availability_listening_supported_ = true; 148 bool screen_availability_listening_supported_ = true;
141 }; 149 };
142 150
143 class MockPresentationServiceClient 151 class MockPresentationServiceClient
144 : public blink::mojom::PresentationServiceClient { 152 : public blink::mojom::PresentationServiceClient {
145 public: 153 public:
146 MOCK_METHOD2(OnScreenAvailabilityUpdated, 154 MOCK_METHOD2(OnScreenAvailabilityUpdated,
147 void(const std::string& url, bool available)); 155 void(const mojo::String& url, bool available));
148 void OnConnectionStateChanged( 156 void OnConnectionStateChanged(
149 blink::mojom::PresentationSessionInfoPtr connection, 157 blink::mojom::PresentationSessionInfoPtr connection,
150 blink::mojom::PresentationConnectionState new_state) override { 158 blink::mojom::PresentationConnectionState new_state) override {
151 OnConnectionStateChanged(*connection, new_state); 159 OnConnectionStateChanged(*connection, new_state);
152 } 160 }
153 MOCK_METHOD2(OnConnectionStateChanged, 161 MOCK_METHOD2(OnConnectionStateChanged,
154 void(const blink::mojom::PresentationSessionInfo& connection, 162 void(const blink::mojom::PresentationSessionInfo& connection,
155 blink::mojom::PresentationConnectionState new_state)); 163 blink::mojom::PresentationConnectionState new_state));
156 164
157 void OnConnectionClosed( 165 void OnConnectionClosed(
158 blink::mojom::PresentationSessionInfoPtr connection, 166 blink::mojom::PresentationSessionInfoPtr connection,
159 blink::mojom::PresentationConnectionCloseReason reason, 167 blink::mojom::PresentationConnectionCloseReason reason,
160 const std::string& message) override { 168 const mojo::String& message) override {
161 OnConnectionClosed(*connection, reason, message); 169 OnConnectionClosed(*connection, reason, message);
162 } 170 }
163 MOCK_METHOD3(OnConnectionClosed, 171 MOCK_METHOD3(OnConnectionClosed,
164 void(const blink::mojom::PresentationSessionInfo& connection, 172 void(const blink::mojom::PresentationSessionInfo& connection,
165 blink::mojom::PresentationConnectionCloseReason reason, 173 blink::mojom::PresentationConnectionCloseReason reason,
166 const std::string& message)); 174 const mojo::String& message));
167 175
168 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const std::string& url)); 176 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const mojo::String& url));
169 177
170 void OnSessionMessagesReceived( 178 void OnSessionMessagesReceived(
171 blink::mojom::PresentationSessionInfoPtr session_info, 179 blink::mojom::PresentationSessionInfoPtr session_info,
172 std::vector<blink::mojom::SessionMessagePtr> messages) override { 180 mojo::Array<blink::mojom::SessionMessagePtr> messages) override {
173 messages_received_ = std::move(messages); 181 messages_received_ = std::move(messages);
174 MessagesReceived(); 182 MessagesReceived();
175 } 183 }
176 MOCK_METHOD0(MessagesReceived, void()); 184 MOCK_METHOD0(MessagesReceived, void());
177 185
178 void OnDefaultSessionStarted( 186 void OnDefaultSessionStarted(
179 blink::mojom::PresentationSessionInfoPtr session_info) override { 187 blink::mojom::PresentationSessionInfoPtr session_info) override {
180 OnDefaultSessionStarted(*session_info); 188 OnDefaultSessionStarted(*session_info);
181 } 189 }
182 MOCK_METHOD1(OnDefaultSessionStarted, 190 MOCK_METHOD1(OnDefaultSessionStarted,
183 void(const blink::mojom::PresentationSessionInfo& session_info)); 191 void(const blink::mojom::PresentationSessionInfo& session_info));
184 192
185 std::vector<blink::mojom::SessionMessagePtr> messages_received_; 193 mojo::Array<blink::mojom::SessionMessagePtr> messages_received_;
186 }; 194 };
187 195
188 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { 196 class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
189 public: 197 public:
190 PresentationServiceImplTest() {} 198 PresentationServiceImplTest() {}
191 199
192 void SetUp() override { 200 void SetUp() override {
193 RenderViewHostImplTestHarness::SetUp(); 201 RenderViewHostImplTestHarness::SetUp();
194 202
195 auto request = mojo::GetProxy(&service_ptr_); 203 auto request = mojo::GetProxy(&service_ptr_);
(...skipping 13 matching lines...) Expand all
209 217
210 void TearDown() override { 218 void TearDown() override {
211 service_ptr_.reset(); 219 service_ptr_.reset();
212 if (service_impl_.get()) { 220 if (service_impl_.get()) {
213 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1); 221 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
214 service_impl_.reset(); 222 service_impl_.reset();
215 } 223 }
216 RenderViewHostImplTestHarness::TearDown(); 224 RenderViewHostImplTestHarness::TearDown();
217 } 225 }
218 226
219 void ListenForScreenAvailabilityAndWait(const std::string& url, 227 void ListenForScreenAvailabilityAndWait(
220 bool delegate_success) { 228 const mojo::String& url, bool delegate_success) {
221 base::RunLoop run_loop; 229 base::RunLoop run_loop;
222 // This will call to |service_impl_| via mojo. Process the message 230 // This will call to |service_impl_| via mojo. Process the message
223 // using RunLoop. 231 // using RunLoop.
224 // The callback shouldn't be invoked since there is no availability 232 // The callback shouldn't be invoked since there is no availability
225 // result yet. 233 // result yet.
226 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener()) 234 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener())
227 .WillOnce(DoAll( 235 .WillOnce(DoAll(
228 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 236 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
229 Return(delegate_success))); 237 Return(delegate_success)));
230 service_ptr_->ListenForScreenAvailability(url); 238 service_ptr_->ListenForScreenAvailability(url);
(...skipping 15 matching lines...) Expand all
246 run_loop.Run(); 254 run_loop.Run();
247 run_loop_quit_closure_.Reset(); 255 run_loop_quit_closure_.Reset();
248 } 256 }
249 257
250 void SimulateScreenAvailabilityChangeAndWait( 258 void SimulateScreenAvailabilityChangeAndWait(
251 const std::string& url, bool available) { 259 const std::string& url, bool available) {
252 auto listener_it = service_impl_->screen_availability_listeners_.find(url); 260 auto listener_it = service_impl_->screen_availability_listeners_.find(url);
253 ASSERT_TRUE(listener_it->second); 261 ASSERT_TRUE(listener_it->second);
254 262
255 base::RunLoop run_loop; 263 base::RunLoop run_loop;
256 EXPECT_CALL(mock_client_, OnScreenAvailabilityUpdated(url, available)) 264 EXPECT_CALL(mock_client_,
257 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 265 OnScreenAvailabilityUpdated(mojo::String(url), available))
266 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
258 listener_it->second->OnScreenAvailabilityChanged(available); 267 listener_it->second->OnScreenAvailabilityChanged(available);
259 run_loop.Run(); 268 run_loop.Run();
260 } 269 }
261 270
262 void ExpectReset() { 271 void ExpectReset() {
263 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1); 272 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1);
264 } 273 }
265 274
266 void ExpectCleanState() { 275 void ExpectCleanState() {
267 EXPECT_TRUE(service_impl_->default_presentation_url_.empty()); 276 EXPECT_TRUE(service_impl_->default_presentation_url_.empty());
(...skipping 15 matching lines...) Expand all
283 void ExpectNewSessionCallbackError( 292 void ExpectNewSessionCallbackError(
284 blink::mojom::PresentationSessionInfoPtr info, 293 blink::mojom::PresentationSessionInfoPtr info,
285 blink::mojom::PresentationErrorPtr error) { 294 blink::mojom::PresentationErrorPtr error) {
286 EXPECT_TRUE(info.is_null()); 295 EXPECT_TRUE(info.is_null());
287 EXPECT_FALSE(error.is_null()); 296 EXPECT_FALSE(error.is_null());
288 if (!run_loop_quit_closure_.is_null()) 297 if (!run_loop_quit_closure_.is_null())
289 run_loop_quit_closure_.Run(); 298 run_loop_quit_closure_.Run();
290 } 299 }
291 300
292 void ExpectSessionMessages( 301 void ExpectSessionMessages(
293 const std::vector<blink::mojom::SessionMessagePtr>& expected_msgs, 302 const mojo::Array<blink::mojom::SessionMessagePtr>& expected_msgs,
294 const std::vector<blink::mojom::SessionMessagePtr>& actual_msgs) { 303 const mojo::Array<blink::mojom::SessionMessagePtr>& actual_msgs) {
295 EXPECT_EQ(expected_msgs.size(), actual_msgs.size()); 304 EXPECT_EQ(expected_msgs.size(), actual_msgs.size());
296 for (size_t i = 0; i < actual_msgs.size(); ++i) 305 for (size_t i = 0; i < actual_msgs.size(); ++i) {
297 EXPECT_TRUE(expected_msgs[i].Equals(actual_msgs[i])); 306 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_msgs[i].get(),
307 actual_msgs[i].get()));
308 }
298 } 309 }
299 310
300 void ExpectSendSessionMessageCallback(bool success) { 311 void ExpectSendSessionMessageCallback(bool success) {
301 EXPECT_TRUE(success); 312 EXPECT_TRUE(success);
302 EXPECT_FALSE(service_impl_->send_message_callback_); 313 EXPECT_FALSE(service_impl_->send_message_callback_);
303 if (!run_loop_quit_closure_.is_null()) 314 if (!run_loop_quit_closure_.is_null())
304 run_loop_quit_closure_.Run(); 315 run_loop_quit_closure_.Run();
305 } 316 }
306 317
307 void RunListenForSessionMessages(const std::string& text_msg, 318 void RunListenForSessionMessages(const std::string& text_msg,
308 const std::vector<uint8_t>& binary_data, 319 const std::vector<uint8_t>& binary_data,
309 bool pass_ownership) { 320 bool pass_ownership) {
310 std::vector<blink::mojom::SessionMessagePtr> expected_msgs(2); 321 mojo::Array<blink::mojom::SessionMessagePtr> expected_msgs(2);
311 expected_msgs[0] = blink::mojom::SessionMessage::New(); 322 expected_msgs[0] = blink::mojom::SessionMessage::New();
312 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT; 323 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT;
313 expected_msgs[0]->message = text_msg; 324 expected_msgs[0]->message = text_msg;
314 expected_msgs[1] = blink::mojom::SessionMessage::New(); 325 expected_msgs[1] = blink::mojom::SessionMessage::New();
315 expected_msgs[1]->type = 326 expected_msgs[1]->type =
316 blink::mojom::PresentationMessageType::ARRAY_BUFFER; 327 blink::mojom::PresentationMessageType::ARRAY_BUFFER;
317 expected_msgs[1]->data = binary_data; 328 expected_msgs[1]->data = mojo::Array<uint8_t>::From(binary_data);
318 329
319 blink::mojom::PresentationSessionInfoPtr session( 330 blink::mojom::PresentationSessionInfoPtr session(
320 blink::mojom::PresentationSessionInfo::New()); 331 blink::mojom::PresentationSessionInfo::New());
321 session->url = kPresentationUrl; 332 session->url = kPresentationUrl;
322 session->id = kPresentationId; 333 session->id = kPresentationId;
323 334
324 PresentationSessionMessageCallback message_cb; 335 PresentationSessionMessageCallback message_cb;
325 { 336 {
326 base::RunLoop run_loop; 337 base::RunLoop run_loop;
327 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _)) 338 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _))
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 blink::mojom::PresentationSessionInfo presentation_connection; 509 blink::mojom::PresentationSessionInfo presentation_connection;
499 presentation_connection.url = kPresentationUrl; 510 presentation_connection.url = kPresentationUrl;
500 presentation_connection.id = kPresentationId; 511 presentation_connection.id = kPresentationId;
501 { 512 {
502 base::RunLoop run_loop; 513 base::RunLoop run_loop;
503 PresentationConnectionStateChangeInfo closed_info( 514 PresentationConnectionStateChangeInfo closed_info(
504 PRESENTATION_CONNECTION_STATE_CLOSED); 515 PRESENTATION_CONNECTION_STATE_CLOSED);
505 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; 516 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY;
506 closed_info.message = "Foo"; 517 closed_info.message = "Foo";
507 518
508 EXPECT_CALL( 519 EXPECT_CALL(mock_client_,
509 mock_client_, 520 OnConnectionClosed(
510 OnConnectionClosed( 521 Equals(presentation_connection),
511 Equals(presentation_connection), 522 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY,
512 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY, "Foo")) 523 mojo::String("Foo")))
513 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 524 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
514 state_changed_cb.Run(closed_info); 525 state_changed_cb.Run(closed_info);
515 run_loop.Run(); 526 run_loop.Run();
516 } 527 }
517 } 528 }
518 529
519 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) { 530 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) {
520 EXPECT_CALL(mock_delegate_, 531 EXPECT_CALL(mock_delegate_,
521 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _)) 532 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _))
522 .Times(1); 533 .Times(1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 .WillOnce(DoAll( 573 .WillOnce(DoAll(
563 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 574 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
564 SaveArg<4>(&error_cb))); 575 SaveArg<4>(&error_cb)));
565 run_loop.Run(); 576 run_loop.Run();
566 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); 577 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
567 SaveQuitClosureAndRunLoop(); 578 SaveQuitClosureAndRunLoop();
568 } 579 }
569 580
570 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) { 581 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) {
571 service_ptr_->JoinSession( 582 service_ptr_->JoinSession(
572 kPresentationUrl, base::Optional<std::string>(kPresentationId), 583 kPresentationUrl,
573 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackSuccess, 584 kPresentationId,
574 base::Unretained(this))); 585 base::Bind(
586 &PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
587 base::Unretained(this)));
575 base::RunLoop run_loop; 588 base::RunLoop run_loop;
576 base::Callback<void(const PresentationSessionInfo&)> success_cb; 589 base::Callback<void(const PresentationSessionInfo&)> success_cb;
577 EXPECT_CALL(mock_delegate_, JoinSession( 590 EXPECT_CALL(mock_delegate_, JoinSession(
578 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) 591 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
579 .WillOnce(DoAll( 592 .WillOnce(DoAll(
580 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 593 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
581 SaveArg<4>(&success_cb))); 594 SaveArg<4>(&success_cb)));
582 run_loop.Run(); 595 run_loop.Run();
583 596
584 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) 597 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
585 .Times(1); 598 .Times(1);
586 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId)); 599 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId));
587 SaveQuitClosureAndRunLoop(); 600 SaveQuitClosureAndRunLoop();
588 } 601 }
589 602
590 TEST_F(PresentationServiceImplTest, JoinSessionError) { 603 TEST_F(PresentationServiceImplTest, JoinSessionError) {
591 service_ptr_->JoinSession( 604 service_ptr_->JoinSession(
592 kPresentationUrl, base::Optional<std::string>(kPresentationId), 605 kPresentationUrl,
593 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError, 606 kPresentationId,
594 base::Unretained(this))); 607 base::Bind(
608 &PresentationServiceImplTest::ExpectNewSessionCallbackError,
609 base::Unretained(this)));
595 base::RunLoop run_loop; 610 base::RunLoop run_loop;
596 base::Callback<void(const PresentationError&)> error_cb; 611 base::Callback<void(const PresentationError&)> error_cb;
597 EXPECT_CALL(mock_delegate_, JoinSession( 612 EXPECT_CALL(mock_delegate_, JoinSession(
598 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) 613 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
599 .WillOnce(DoAll( 614 .WillOnce(DoAll(
600 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 615 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
601 SaveArg<5>(&error_cb))); 616 SaveArg<5>(&error_cb)));
602 run_loop.Run(); 617 run_loop.Run();
603 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); 618 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
604 SaveQuitClosureAndRunLoop(); 619 SaveQuitClosureAndRunLoop();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 std::vector<uint8_t> data; 712 std::vector<uint8_t> data;
698 data.assign(buffer, buffer + sizeof(buffer)); 713 data.assign(buffer, buffer + sizeof(buffer));
699 714
700 blink::mojom::PresentationSessionInfoPtr session( 715 blink::mojom::PresentationSessionInfoPtr session(
701 blink::mojom::PresentationSessionInfo::New()); 716 blink::mojom::PresentationSessionInfo::New());
702 session->url = kPresentationUrl; 717 session->url = kPresentationUrl;
703 session->id = kPresentationId; 718 session->id = kPresentationId;
704 blink::mojom::SessionMessagePtr message_request( 719 blink::mojom::SessionMessagePtr message_request(
705 blink::mojom::SessionMessage::New()); 720 blink::mojom::SessionMessage::New());
706 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; 721 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
707 message_request->data = data; 722 message_request->data = mojo::Array<uint8_t>::From(data);
708 service_ptr_->SendSessionMessage( 723 service_ptr_->SendSessionMessage(
709 std::move(session), std::move(message_request), 724 std::move(session), std::move(message_request),
710 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 725 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
711 base::Unretained(this))); 726 base::Unretained(this)));
712 727
713 base::RunLoop run_loop; 728 base::RunLoop run_loop;
714 base::Callback<void(bool)> send_message_cb; 729 base::Callback<void(bool)> send_message_cb;
715 PresentationSessionMessage* test_message = nullptr; 730 PresentationSessionMessage* test_message = nullptr;
716 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 731 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
717 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 732 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 23 matching lines...) Expand all
741 std::vector<uint8_t> data; 756 std::vector<uint8_t> data;
742 data.assign(buffer, buffer + sizeof(buffer)); 757 data.assign(buffer, buffer + sizeof(buffer));
743 758
744 blink::mojom::PresentationSessionInfoPtr session( 759 blink::mojom::PresentationSessionInfoPtr session(
745 blink::mojom::PresentationSessionInfo::New()); 760 blink::mojom::PresentationSessionInfo::New());
746 session->url = kPresentationUrl; 761 session->url = kPresentationUrl;
747 session->id = kPresentationId; 762 session->id = kPresentationId;
748 blink::mojom::SessionMessagePtr message_request( 763 blink::mojom::SessionMessagePtr message_request(
749 blink::mojom::SessionMessage::New()); 764 blink::mojom::SessionMessage::New());
750 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; 765 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
751 message_request->data = data; 766 message_request->data = mojo::Array<uint8_t>::From(data);
752 service_ptr_->SendSessionMessage( 767 service_ptr_->SendSessionMessage(
753 std::move(session), std::move(message_request), 768 std::move(session), std::move(message_request),
754 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 769 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
755 base::Unretained(this))); 770 base::Unretained(this)));
756 771
757 base::RunLoop run_loop; 772 base::RunLoop run_loop;
758 base::Callback<void(bool)> send_message_cb; 773 base::Callback<void(bool)> send_message_cb;
759 PresentationSessionMessage* test_message = nullptr; 774 PresentationSessionMessage* test_message = nullptr;
760 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 775 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
761 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 776 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 10 matching lines...) Expand all
772 std::vector<uint8_t> data; 787 std::vector<uint8_t> data;
773 data.assign(buffer, buffer + sizeof(buffer)); 788 data.assign(buffer, buffer + sizeof(buffer));
774 789
775 blink::mojom::PresentationSessionInfoPtr session( 790 blink::mojom::PresentationSessionInfoPtr session(
776 blink::mojom::PresentationSessionInfo::New()); 791 blink::mojom::PresentationSessionInfo::New());
777 session->url = kPresentationUrl; 792 session->url = kPresentationUrl;
778 session->id = kPresentationId; 793 session->id = kPresentationId;
779 blink::mojom::SessionMessagePtr message_request( 794 blink::mojom::SessionMessagePtr message_request(
780 blink::mojom::SessionMessage::New()); 795 blink::mojom::SessionMessage::New());
781 message_request->type = blink::mojom::PresentationMessageType::BLOB; 796 message_request->type = blink::mojom::PresentationMessageType::BLOB;
782 message_request->data = data; 797 message_request->data = mojo::Array<uint8_t>::From(data);
783 service_ptr_->SendSessionMessage( 798 service_ptr_->SendSessionMessage(
784 std::move(session), std::move(message_request), 799 std::move(session), std::move(message_request),
785 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, 800 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback,
786 base::Unretained(this))); 801 base::Unretained(this)));
787 802
788 base::RunLoop run_loop; 803 base::RunLoop run_loop;
789 base::Callback<void(bool)> send_message_cb; 804 base::Callback<void(bool)> send_message_cb;
790 PresentationSessionMessage* test_message = nullptr; 805 PresentationSessionMessage* test_message = nullptr;
791 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 806 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
792 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 807 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 mock_delegate_.set_screen_availability_listening_supported(false); 850 mock_delegate_.set_screen_availability_listening_supported(false);
836 base::RunLoop run_loop; 851 base::RunLoop run_loop;
837 EXPECT_CALL(mock_client_, 852 EXPECT_CALL(mock_client_,
838 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) 853 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl)))
839 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 854 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
840 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); 855 ListenForScreenAvailabilityAndWait(kPresentationUrl, false);
841 run_loop.Run(); 856 run_loop.Run();
842 } 857 }
843 858
844 } // namespace content 859 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_service_impl.cc ('k') | content/renderer/presentation/presentation_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698