Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 const SendMessageCallback& send_message_cb) override { | 139 const SendMessageCallback& send_message_cb) override { |
| 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 MOCK_METHOD1(RegisterReceiverAvailableCallback, | |
|
mark a. foltz
2016/10/08 00:33:42
Please add unit tests for the new APIs added in Pr
zhaobin
2016/10/12 02:27:33
Done.
| |
| 150 void(const content::ReceiverConnectionAvailableCallback&)); | |
| 151 void RegisterOffscreenPresentationConnection( | |
| 152 int render_process_id, | |
| 153 int render_frame_id, | |
| 154 const PresentationSessionInfo& session, | |
| 155 PresentationConnectionPtr connection) override { | |
| 156 RegisterOffscreenPresentationConnectionRaw( | |
| 157 render_process_id, render_frame_id, session, connection.get()); | |
| 158 } | |
| 159 | |
| 160 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, | |
| 161 void(int render_process_id, | |
| 162 int render_frame_id, | |
| 163 const PresentationSessionInfo& session, | |
| 164 blink::mojom::PresentationConnection* connection)); | |
| 149 | 165 |
| 150 void set_screen_availability_listening_supported(bool value) { | 166 void set_screen_availability_listening_supported(bool value) { |
| 151 screen_availability_listening_supported_ = value; | 167 screen_availability_listening_supported_ = value; |
| 152 } | 168 } |
| 153 | 169 |
| 154 private: | 170 private: |
| 155 bool screen_availability_listening_supported_ = true; | 171 bool screen_availability_listening_supported_ = true; |
| 156 }; | 172 }; |
| 157 | 173 |
| 158 class MockPresentationServiceClient | 174 class MockPresentationServiceClient |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 MOCK_METHOD0(MessagesReceived, void()); | 207 MOCK_METHOD0(MessagesReceived, void()); |
| 192 | 208 |
| 193 void OnDefaultSessionStarted( | 209 void OnDefaultSessionStarted( |
| 194 blink::mojom::PresentationSessionInfoPtr session_info) override { | 210 blink::mojom::PresentationSessionInfoPtr session_info) override { |
| 195 OnDefaultSessionStarted(*session_info); | 211 OnDefaultSessionStarted(*session_info); |
| 196 } | 212 } |
| 197 MOCK_METHOD1(OnDefaultSessionStarted, | 213 MOCK_METHOD1(OnDefaultSessionStarted, |
| 198 void(const blink::mojom::PresentationSessionInfo& session_info)); | 214 void(const blink::mojom::PresentationSessionInfo& session_info)); |
| 199 | 215 |
| 200 void OnReceiverConnectionAvailable( | 216 void OnReceiverConnectionAvailable( |
| 201 blink::mojom::PresentationSessionInfoPtr session_info) override { | 217 blink::mojom::PresentationSessionInfoPtr session_info, |
| 218 blink::mojom::PresentationConnectionPtr connection) override { | |
| 202 OnReceiverConnectionAvailable(*session_info); | 219 OnReceiverConnectionAvailable(*session_info); |
| 203 } | 220 } |
| 204 MOCK_METHOD1(OnReceiverConnectionAvailable, | 221 MOCK_METHOD1(OnReceiverConnectionAvailable, |
| 205 void(const blink::mojom::PresentationSessionInfo& session_info)); | 222 void(const blink::mojom::PresentationSessionInfo& session_info)); |
| 206 | 223 |
| 207 std::vector<blink::mojom::SessionMessagePtr> messages_received_; | 224 std::vector<blink::mojom::SessionMessagePtr> messages_received_; |
| 208 }; | 225 }; |
| 209 | 226 |
| 210 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { | 227 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { |
| 211 public: | 228 public: |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 mock_delegate_.set_screen_availability_listening_supported(false); | 874 mock_delegate_.set_screen_availability_listening_supported(false); |
| 858 GURL url(kPresentationUrl1); | 875 GURL url(kPresentationUrl1); |
| 859 base::RunLoop run_loop; | 876 base::RunLoop run_loop; |
| 860 EXPECT_CALL(mock_client_, OnScreenAvailabilityNotSupported(url)) | 877 EXPECT_CALL(mock_client_, OnScreenAvailabilityNotSupported(url)) |
| 861 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 878 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 862 ListenForScreenAvailabilityAndWait(kPresentationUrl1, false); | 879 ListenForScreenAvailabilityAndWait(kPresentationUrl1, false); |
| 863 run_loop.Run(); | 880 run_loop.Run(); |
| 864 } | 881 } |
| 865 | 882 |
| 866 } // namespace content | 883 } // namespace content |
| OLD | NEW |