| Index: content/browser/presentation/presentation_service_impl_unittest.cc
|
| diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| index 0d062ea233141dd3437fc57bd4e030b7603d3d8d..31e3d6456cd8b7f59638431014e46e1d1c243458 100644
|
| --- a/content/browser/presentation/presentation_service_impl_unittest.cc
|
| +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| @@ -46,15 +46,16 @@ MATCHER_P(Equals, expected, "") {
|
| const char *const kPresentationId = "presentationId";
|
| const char *const kPresentationUrl = "http://foo.com/index.html";
|
|
|
| -bool ArePresentationSessionMessagesEqual(const mojom::SessionMessage* expected,
|
| - const mojom::SessionMessage* actual) {
|
| +bool ArePresentationSessionMessagesEqual(
|
| + const blink::mojom::SessionMessage* expected,
|
| + const blink::mojom::SessionMessage* actual) {
|
| return expected->type == actual->type &&
|
| expected->message == actual->message &&
|
| expected->data.Equals(actual->data);
|
| }
|
|
|
| -void DoNothing(mojom::PresentationSessionInfoPtr info,
|
| - mojom::PresentationErrorPtr error) {}
|
| +void DoNothing(blink::mojom::PresentationSessionInfoPtr info,
|
| + blink::mojom::PresentationErrorPtr error) {}
|
|
|
| } // namespace
|
|
|
| @@ -147,47 +148,49 @@ class MockPresentationServiceDelegate : public PresentationServiceDelegate {
|
| bool screen_availability_listening_supported_ = true;
|
| };
|
|
|
| -class MockPresentationServiceClient : public mojom::PresentationServiceClient {
|
| +class MockPresentationServiceClient
|
| + : public blink::mojom::PresentationServiceClient {
|
| public:
|
| MOCK_METHOD2(OnScreenAvailabilityUpdated,
|
| void(const mojo::String& url, bool available));
|
| void OnConnectionStateChanged(
|
| - mojom::PresentationSessionInfoPtr connection,
|
| - mojom::PresentationConnectionState new_state) override {
|
| + blink::mojom::PresentationSessionInfoPtr connection,
|
| + blink::mojom::PresentationConnectionState new_state) override {
|
| OnConnectionStateChanged(*connection, new_state);
|
| }
|
| MOCK_METHOD2(OnConnectionStateChanged,
|
| - void(const mojom::PresentationSessionInfo& connection,
|
| - mojom::PresentationConnectionState new_state));
|
| + void(const blink::mojom::PresentationSessionInfo& connection,
|
| + blink::mojom::PresentationConnectionState new_state));
|
|
|
| - void OnConnectionClosed(mojom::PresentationSessionInfoPtr connection,
|
| - mojom::PresentationConnectionCloseReason reason,
|
| - const mojo::String& message) override {
|
| + void OnConnectionClosed(
|
| + blink::mojom::PresentationSessionInfoPtr connection,
|
| + blink::mojom::PresentationConnectionCloseReason reason,
|
| + const mojo::String& message) override {
|
| OnConnectionClosed(*connection, reason, message);
|
| }
|
| MOCK_METHOD3(OnConnectionClosed,
|
| - void(const mojom::PresentationSessionInfo& connection,
|
| - mojom::PresentationConnectionCloseReason reason,
|
| + void(const blink::mojom::PresentationSessionInfo& connection,
|
| + blink::mojom::PresentationConnectionCloseReason reason,
|
| const mojo::String& message));
|
|
|
| MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const mojo::String& url));
|
|
|
| void OnSessionMessagesReceived(
|
| - mojom::PresentationSessionInfoPtr session_info,
|
| - mojo::Array<mojom::SessionMessagePtr> messages) override {
|
| + blink::mojom::PresentationSessionInfoPtr session_info,
|
| + mojo::Array<blink::mojom::SessionMessagePtr> messages) override {
|
| messages_received_ = std::move(messages);
|
| MessagesReceived();
|
| }
|
| MOCK_METHOD0(MessagesReceived, void());
|
|
|
| void OnDefaultSessionStarted(
|
| - mojom::PresentationSessionInfoPtr session_info) override {
|
| + blink::mojom::PresentationSessionInfoPtr session_info) override {
|
| OnDefaultSessionStarted(*session_info);
|
| }
|
| MOCK_METHOD1(OnDefaultSessionStarted,
|
| - void(const mojom::PresentationSessionInfo& session_info));
|
| + void(const blink::mojom::PresentationSessionInfo& session_info));
|
|
|
| - mojo::Array<mojom::SessionMessagePtr> messages_received_;
|
| + mojo::Array<blink::mojom::SessionMessagePtr> messages_received_;
|
| };
|
|
|
| class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| @@ -205,9 +208,10 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| render_frame_host, contents(), &mock_delegate_));
|
| service_impl_->Bind(std::move(request));
|
|
|
| - mojom::PresentationServiceClientPtr client_ptr;
|
| - client_binding_.reset(new mojo::Binding<mojom::PresentationServiceClient>(
|
| - &mock_client_, mojo::GetProxy(&client_ptr)));
|
| + blink::mojom::PresentationServiceClientPtr client_ptr;
|
| + client_binding_.reset(
|
| + new mojo::Binding<blink::mojom::PresentationServiceClient>(
|
| + &mock_client_, mojo::GetProxy(&client_ptr)));
|
| service_impl_->SetClient(std::move(client_ptr));
|
| }
|
|
|
| @@ -277,16 +281,17 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| }
|
|
|
| void ExpectNewSessionMojoCallbackSuccess(
|
| - mojom::PresentationSessionInfoPtr info,
|
| - mojom::PresentationErrorPtr error) {
|
| + blink::mojom::PresentationSessionInfoPtr info,
|
| + blink::mojom::PresentationErrorPtr error) {
|
| EXPECT_FALSE(info.is_null());
|
| EXPECT_TRUE(error.is_null());
|
| if (!run_loop_quit_closure_.is_null())
|
| run_loop_quit_closure_.Run();
|
| }
|
|
|
| - void ExpectNewSessionMojoCallbackError(mojom::PresentationSessionInfoPtr info,
|
| - mojom::PresentationErrorPtr error) {
|
| + void ExpectNewSessionMojoCallbackError(
|
| + blink::mojom::PresentationSessionInfoPtr info,
|
| + blink::mojom::PresentationErrorPtr error) {
|
| EXPECT_TRUE(info.is_null());
|
| EXPECT_FALSE(error.is_null());
|
| if (!run_loop_quit_closure_.is_null())
|
| @@ -294,8 +299,8 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| }
|
|
|
| void ExpectSessionMessages(
|
| - const mojo::Array<mojom::SessionMessagePtr>& expected_msgs,
|
| - const mojo::Array<mojom::SessionMessagePtr>& actual_msgs) {
|
| + const mojo::Array<blink::mojom::SessionMessagePtr>& expected_msgs,
|
| + const mojo::Array<blink::mojom::SessionMessagePtr>& actual_msgs) {
|
| EXPECT_EQ(expected_msgs.size(), actual_msgs.size());
|
| for (size_t i = 0; i < actual_msgs.size(); ++i) {
|
| EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_msgs[i].get(),
|
| @@ -313,16 +318,17 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| void RunListenForSessionMessages(const std::string& text_msg,
|
| const std::vector<uint8_t>& binary_data,
|
| bool pass_ownership) {
|
| - mojo::Array<mojom::SessionMessagePtr> expected_msgs(2);
|
| - expected_msgs[0] = mojom::SessionMessage::New();
|
| - expected_msgs[0]->type = mojom::PresentationMessageType::TEXT;
|
| + mojo::Array<blink::mojom::SessionMessagePtr> expected_msgs(2);
|
| + expected_msgs[0] = blink::mojom::SessionMessage::New();
|
| + expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT;
|
| expected_msgs[0]->message = text_msg;
|
| - expected_msgs[1] = mojom::SessionMessage::New();
|
| - expected_msgs[1]->type = mojom::PresentationMessageType::ARRAY_BUFFER;
|
| + expected_msgs[1] = blink::mojom::SessionMessage::New();
|
| + expected_msgs[1]->type =
|
| + blink::mojom::PresentationMessageType::ARRAY_BUFFER;
|
| expected_msgs[1]->data = mojo::Array<uint8_t>::From(binary_data);
|
|
|
| - mojom::PresentationSessionInfoPtr session(
|
| - mojom::PresentationSessionInfo::New());
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| session->url = kPresentationUrl;
|
| session->id = kPresentationId;
|
|
|
| @@ -347,7 +353,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| message->data.reset(new std::vector<uint8_t>(binary_data));
|
| messages.push_back(std::move(message));
|
|
|
| - std::vector<mojom::SessionMessagePtr> actual_msgs;
|
| + std::vector<blink::mojom::SessionMessagePtr> actual_msgs;
|
| {
|
| base::RunLoop run_loop;
|
| EXPECT_CALL(mock_client_, MessagesReceived())
|
| @@ -361,10 +367,10 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| MockPresentationServiceDelegate mock_delegate_;
|
|
|
| std::unique_ptr<PresentationServiceImpl> service_impl_;
|
| - mojo::InterfacePtr<mojom::PresentationService> service_ptr_;
|
| + mojo::InterfacePtr<blink::mojom::PresentationService> service_ptr_;
|
|
|
| MockPresentationServiceClient mock_client_;
|
| - std::unique_ptr<mojo::Binding<mojom::PresentationServiceClient>>
|
| + std::unique_ptr<mojo::Binding<blink::mojom::PresentationServiceClient>>
|
| client_binding_;
|
|
|
| base::Closure run_loop_quit_closure_;
|
| @@ -455,7 +461,7 @@ TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrl) {
|
| service_impl_->SetDefaultPresentationURL(url2);
|
| EXPECT_EQ(url2, service_impl_->default_presentation_url_);
|
|
|
| - mojom::PresentationSessionInfo session_info;
|
| + blink::mojom::PresentationSessionInfo session_info;
|
| session_info.url = url2;
|
| session_info.id = kPresentationId;
|
| base::RunLoop run_loop;
|
| @@ -474,7 +480,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
|
| service_impl_->ListenForConnectionStateChange(connection);
|
|
|
| // Trigger state change. It should be propagated back up to |mock_client_|.
|
| - mojom::PresentationSessionInfo presentation_connection;
|
| + blink::mojom::PresentationSessionInfo presentation_connection;
|
| presentation_connection.url = kPresentationUrl;
|
| presentation_connection.id = kPresentationId;
|
| {
|
| @@ -482,7 +488,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
|
| EXPECT_CALL(mock_client_,
|
| OnConnectionStateChanged(
|
| Equals(presentation_connection),
|
| - mojom::PresentationConnectionState::TERMINATED))
|
| + blink::mojom::PresentationConnectionState::TERMINATED))
|
| .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
|
| state_changed_cb.Run(PresentationConnectionStateChangeInfo(
|
| PRESENTATION_CONNECTION_STATE_TERMINATED));
|
| @@ -500,7 +506,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
|
|
|
| // Trigger connection close. It should be propagated back up to
|
| // |mock_client_|.
|
| - mojom::PresentationSessionInfo presentation_connection;
|
| + blink::mojom::PresentationSessionInfo presentation_connection;
|
| presentation_connection.url = kPresentationUrl;
|
| presentation_connection.id = kPresentationId;
|
| {
|
| @@ -510,11 +516,11 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
|
| closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY;
|
| closed_info.message = "Foo";
|
|
|
| - EXPECT_CALL(
|
| - mock_client_,
|
| - OnConnectionClosed(Equals(presentation_connection),
|
| - mojom::PresentationConnectionCloseReason::WENT_AWAY,
|
| - mojo::String("Foo")))
|
| + EXPECT_CALL(mock_client_,
|
| + OnConnectionClosed(
|
| + Equals(presentation_connection),
|
| + blink::mojom::PresentationConnectionCloseReason::WENT_AWAY,
|
| + mojo::String("Foo")))
|
| .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
|
| state_changed_cb.Run(closed_info);
|
| run_loop.Run();
|
| @@ -668,12 +674,13 @@ TEST_F(PresentationServiceImplTest, StartSessionInProgress) {
|
| TEST_F(PresentationServiceImplTest, SendStringMessage) {
|
| std::string message("Test presentation session message");
|
|
|
| - mojom::PresentationSessionInfoPtr session(
|
| - mojom::PresentationSessionInfo::New());
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| session->url = kPresentationUrl;
|
| session->id = kPresentationId;
|
| - mojom::SessionMessagePtr message_request(mojom::SessionMessage::New());
|
| - message_request->type = mojom::PresentationMessageType::TEXT;
|
| + blink::mojom::SessionMessagePtr message_request(
|
| + blink::mojom::SessionMessage::New());
|
| + message_request->type = blink::mojom::PresentationMessageType::TEXT;
|
| message_request->message = message;
|
| service_ptr_->SendSessionMessage(
|
| std::move(session), std::move(message_request),
|
| @@ -705,12 +712,13 @@ TEST_F(PresentationServiceImplTest, SendArrayBuffer) {
|
| std::vector<uint8_t> data;
|
| data.assign(buffer, buffer + sizeof(buffer));
|
|
|
| - mojom::PresentationSessionInfoPtr session(
|
| - mojom::PresentationSessionInfo::New());
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| session->url = kPresentationUrl;
|
| session->id = kPresentationId;
|
| - mojom::SessionMessagePtr message_request(mojom::SessionMessage::New());
|
| - message_request->type = mojom::PresentationMessageType::ARRAY_BUFFER;
|
| + blink::mojom::SessionMessagePtr message_request(
|
| + blink::mojom::SessionMessage::New());
|
| + message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
|
| message_request->data = mojo::Array<uint8_t>::From(data);
|
| service_ptr_->SendSessionMessage(
|
| std::move(session), std::move(message_request),
|
| @@ -748,12 +756,13 @@ TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) {
|
| std::vector<uint8_t> data;
|
| data.assign(buffer, buffer + sizeof(buffer));
|
|
|
| - mojom::PresentationSessionInfoPtr session(
|
| - mojom::PresentationSessionInfo::New());
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| session->url = kPresentationUrl;
|
| session->id = kPresentationId;
|
| - mojom::SessionMessagePtr message_request(mojom::SessionMessage::New());
|
| - message_request->type = mojom::PresentationMessageType::ARRAY_BUFFER;
|
| + blink::mojom::SessionMessagePtr message_request(
|
| + blink::mojom::SessionMessage::New());
|
| + message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER;
|
| message_request->data = mojo::Array<uint8_t>::From(data);
|
| service_ptr_->SendSessionMessage(
|
| std::move(session), std::move(message_request),
|
| @@ -778,12 +787,13 @@ TEST_F(PresentationServiceImplTest, SendBlobData) {
|
| std::vector<uint8_t> data;
|
| data.assign(buffer, buffer + sizeof(buffer));
|
|
|
| - mojom::PresentationSessionInfoPtr session(
|
| - mojom::PresentationSessionInfo::New());
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| session->url = kPresentationUrl;
|
| session->id = kPresentationId;
|
| - mojom::SessionMessagePtr message_request(mojom::SessionMessage::New());
|
| - message_request->type = mojom::PresentationMessageType::BLOB;
|
| + blink::mojom::SessionMessagePtr message_request(
|
| + blink::mojom::SessionMessage::New());
|
| + message_request->type = blink::mojom::PresentationMessageType::BLOB;
|
| message_request->data = mojo::Array<uint8_t>::From(data);
|
| service_ptr_->SendSessionMessage(
|
| std::move(session), std::move(message_request),
|
|
|