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

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

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: merge and refactor Created 3 years, 11 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 SendMessageRawPtr(render_process_id, render_frame_id, session, 140 SendMessageRawPtr(render_process_id, render_frame_id, session,
141 message_request.release(), send_message_cb); 141 message_request.release(), send_message_cb);
142 } 142 }
143 MOCK_METHOD4(ListenForConnectionStateChange, 143 MOCK_METHOD4(ListenForConnectionStateChange,
144 void(int render_process_id, 144 void(int render_process_id,
145 int render_frame_id, 145 int render_frame_id,
146 const content::PresentationSessionInfo& connection, 146 const content::PresentationSessionInfo& connection,
147 const content::PresentationConnectionStateChangedCallback& 147 const content::PresentationConnectionStateChangedCallback&
148 state_changed_cb)); 148 state_changed_cb));
149 149
150 void ConnectToOffscreenPresentation( 150 void ConnectToPresentation(
151 int render_process_id, 151 int render_process_id,
152 int render_frame_id, 152 int render_frame_id,
153 const content::PresentationSessionInfo& session, 153 const content::PresentationSessionInfo& session,
154 PresentationConnectionPtr controller_conn_ptr, 154 PresentationConnectionPtr controller_conn_ptr,
155 PresentationConnectionRequest receiver_conn_request) override { 155 PresentationConnectionRequest receiver_conn_request) override {
156 RegisterOffscreenPresentationConnectionRaw( 156 RegisterOffscreenPresentationConnectionRaw(
157 render_process_id, render_frame_id, session, controller_conn_ptr.get()); 157 render_process_id, render_frame_id, session, controller_conn_ptr.get());
158 } 158 }
159 159
160 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, 160 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 base::RunLoop run_loop; 536 base::RunLoop run_loop;
537 EXPECT_CALL(mock_client_, 537 EXPECT_CALL(mock_client_,
538 OnDefaultSessionStarted(SessionInfoEquals(ByRef(session_info)))) 538 OnDefaultSessionStarted(SessionInfoEquals(ByRef(session_info))))
539 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 539 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
540 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)); 540 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _));
541 callback.Run( 541 callback.Run(
542 content::PresentationSessionInfo(presentation_url2_, kPresentationId)); 542 content::PresentationSessionInfo(presentation_url2_, kPresentationId));
543 run_loop.Run(); 543 run_loop.Run();
544 } 544 }
545 545
546 TEST_F(PresentationServiceImplTest, 546 TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
547 ListenForConnectionStateChangeAndChangeState) {
548 content::PresentationSessionInfo connection(presentation_url1_, 547 content::PresentationSessionInfo connection(presentation_url1_,
549 kPresentationId); 548 kPresentationId);
550 content::PresentationConnectionStateChangedCallback state_changed_cb; 549 content::PresentationConnectionStateChangedCallback state_changed_cb;
551 // Trigger state change. It should be propagated back up to |mock_client_|. 550 // Trigger state change. It should be propagated back up to |mock_client_|.
552 blink::mojom::PresentationSessionInfo presentation_connection; 551 blink::mojom::PresentationSessionInfo presentation_connection;
553 presentation_connection.url = presentation_url1_; 552 presentation_connection.url = presentation_url1_;
554 presentation_connection.id = kPresentationId; 553 presentation_connection.id = kPresentationId;
555 554
556 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) 555 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
557 .WillOnce(SaveArg<3>(&state_changed_cb)); 556 .WillOnce(SaveArg<3>(&state_changed_cb));
558 EXPECT_CALL(mock_client_, 557 service_impl_->ListenForConnectionStateChange(connection);
559 OnConnectionStateChanged(
560 SessionInfoEquals(ByRef(presentation_connection)),
561 blink::mojom::PresentationConnectionState::CONNECTED));
562 service_impl_->ListenForConnectionStateChangeAndChangeState(connection);
563 558
564 { 559 {
565 base::RunLoop run_loop; 560 base::RunLoop run_loop;
566 EXPECT_CALL(mock_client_, 561 EXPECT_CALL(mock_client_,
567 OnConnectionStateChanged( 562 OnConnectionStateChanged(
568 SessionInfoEquals(ByRef(presentation_connection)), 563 SessionInfoEquals(ByRef(presentation_connection)),
569 blink::mojom::PresentationConnectionState::TERMINATED)) 564 blink::mojom::PresentationConnectionState::TERMINATED))
570 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 565 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
571 state_changed_cb.Run(PresentationConnectionStateChangeInfo( 566 state_changed_cb.Run(PresentationConnectionStateChangeInfo(
572 PRESENTATION_CONNECTION_STATE_TERMINATED)); 567 PRESENTATION_CONNECTION_STATE_TERMINATED));
573 run_loop.Run(); 568 run_loop.Run();
574 } 569 }
575 } 570 }
576 571
577 TEST_F(PresentationServiceImplTest, ListenForConnectionClose) { 572 TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
578 content::PresentationSessionInfo connection(presentation_url1_, 573 content::PresentationSessionInfo connection(presentation_url1_,
579 kPresentationId); 574 kPresentationId);
580 content::PresentationConnectionStateChangedCallback state_changed_cb; 575 content::PresentationConnectionStateChangedCallback state_changed_cb;
581 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) 576 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
582 .WillOnce(SaveArg<3>(&state_changed_cb)); 577 .WillOnce(SaveArg<3>(&state_changed_cb));
583 service_impl_->ListenForConnectionStateChangeAndChangeState(connection); 578 service_impl_->ListenForConnectionStateChange(connection);
584 579
585 // Trigger connection close. It should be propagated back up to 580 // Trigger connection close. It should be propagated back up to
586 // |mock_client_|. 581 // |mock_client_|.
587 blink::mojom::PresentationSessionInfo presentation_connection; 582 blink::mojom::PresentationSessionInfo presentation_connection;
588 presentation_connection.url = presentation_url1_; 583 presentation_connection.url = presentation_url1_;
589 presentation_connection.id = kPresentationId; 584 presentation_connection.id = kPresentationId;
590 { 585 {
591 base::RunLoop run_loop; 586 base::RunLoop run_loop;
592 PresentationConnectionStateChangeInfo closed_info( 587 PresentationConnectionStateChangeInfo closed_info(
593 PRESENTATION_CONNECTION_STATE_CLOSED); 588 PRESENTATION_CONNECTION_STATE_CLOSED);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 mock_delegate_.set_screen_availability_listening_supported(false); 967 mock_delegate_.set_screen_availability_listening_supported(false);
973 base::RunLoop run_loop; 968 base::RunLoop run_loop;
974 EXPECT_CALL(mock_client_, 969 EXPECT_CALL(mock_client_,
975 OnScreenAvailabilityNotSupported(presentation_url1_)) 970 OnScreenAvailabilityNotSupported(presentation_url1_))
976 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 971 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
977 ListenForScreenAvailabilityAndWait(presentation_url1_, false); 972 ListenForScreenAvailabilityAndWait(presentation_url1_, false);
978 run_loop.Run(); 973 run_loop.Run();
979 } 974 }
980 975
981 } // namespace content 976 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698