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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.h

Issue 2597853002: Unit test for PresentationDispatcher (Closed)
Patch Set: Created 3 years, 12 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 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 18 matching lines...) Expand all
29 class WebPresentationAvailabilityObserver; 29 class WebPresentationAvailabilityObserver;
30 class WebPresentationReceiver; 30 class WebPresentationReceiver;
31 class WebString; 31 class WebString;
32 class WebURL; 32 class WebURL;
33 template <typename T> 33 template <typename T>
34 class WebVector; 34 class WebVector;
35 } // namespace blink 35 } // namespace blink
36 36
37 namespace content { 37 namespace content {
38 38
39 class TestPresentationDispatcher;
40
39 // PresentationDispatcher is a delegate for Presentation API messages used by 41 // PresentationDispatcher is a delegate for Presentation API messages used by
40 // Blink. It forwards the calls to the Mojo PresentationService. 42 // Blink. It forwards the calls to the Mojo PresentationService.
41 class CONTENT_EXPORT PresentationDispatcher 43 class CONTENT_EXPORT PresentationDispatcher
42 : public RenderFrameObserver, 44 : public RenderFrameObserver,
43 public NON_EXPORTED_BASE(blink::WebPresentationClient), 45 public NON_EXPORTED_BASE(blink::WebPresentationClient),
44 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { 46 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) {
45 public: 47 public:
46 explicit PresentationDispatcher(RenderFrame* render_frame); 48 explicit PresentationDispatcher(RenderFrame* render_frame);
47 ~PresentationDispatcher() override; 49 ~PresentationDispatcher() override;
48 50
49 private: 51 private:
52 friend class TestPresentationDispatcher;
53 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession);
54 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession);
55 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString);
56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer);
57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData);
58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession);
59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession);
60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
61 TestListenForScreenAvailability);
62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
63 TestSetDefaultPresentationUrls);
64
50 struct SendMessageRequest { 65 struct SendMessageRequest {
51 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, 66 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info,
52 blink::mojom::ConnectionMessagePtr message); 67 blink::mojom::ConnectionMessagePtr message);
53 ~SendMessageRequest(); 68 ~SendMessageRequest();
54 69
55 blink::mojom::PresentationSessionInfoPtr session_info; 70 blink::mojom::PresentationSessionInfoPtr session_info;
56 blink::mojom::ConnectionMessagePtr message; 71 blink::mojom::ConnectionMessagePtr message;
57 }; 72 };
58 73
59 static SendMessageRequest* CreateSendTextMessageRequest( 74 static SendMessageRequest* CreateSendTextMessageRequest(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 blink::mojom::PresentationErrorPtr error); 147 blink::mojom::PresentationErrorPtr error);
133 void OnReceiverConnectionAvailable( 148 void OnReceiverConnectionAvailable(
134 blink::mojom::PresentationSessionInfoPtr) override; 149 blink::mojom::PresentationSessionInfoPtr) override;
135 150
136 // Call to PresentationService to send the message in |request|. 151 // Call to PresentationService to send the message in |request|.
137 // |session_info| and |message| of |reuqest| will be consumed. 152 // |session_info| and |message| of |reuqest| will be consumed.
138 // |HandleSendMessageRequests| will be invoked after the send is attempted. 153 // |HandleSendMessageRequests| will be invoked after the send is attempted.
139 void DoSendMessage(SendMessageRequest* request); 154 void DoSendMessage(SendMessageRequest* request);
140 void HandleSendMessageRequests(bool success); 155 void HandleSendMessageRequests(bool success);
141 156
142 void ConnectToPresentationServiceIfNeeded(); 157 virtual void ConnectToPresentationServiceIfNeeded();
143 158
144 void UpdateListeningState(); 159 void UpdateListeningState();
145 160
146 // Used as a weak reference. Can be null since lifetime is bound to the frame. 161 // Used as a weak reference. Can be null since lifetime is bound to the frame.
147 blink::WebPresentationController* controller_; 162 blink::WebPresentationController* controller_;
148 blink::WebPresentationReceiver* receiver_; 163 blink::WebPresentationReceiver* receiver_;
149 blink::mojom::PresentationServicePtr presentation_service_; 164 blink::mojom::PresentationServicePtr presentation_service_;
150 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; 165 mojo::Binding<blink::mojom::PresentationServiceClient> binding_;
151 166
152 // Message requests are queued here and only one message at a time is sent 167 // Message requests are queued here and only one message at a time is sent
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Updates the listening state of availability for |status| and notifies the 199 // Updates the listening state of availability for |status| and notifies the
185 // client. 200 // client.
186 void UpdateListeningState(AvailabilityStatus* status); 201 void UpdateListeningState(AvailabilityStatus* status);
187 202
188 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 203 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
189 }; 204 };
190 205
191 } // namespace content 206 } // namespace content
192 207
193 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 208 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698