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

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

Issue 2597853002: Unit test for PresentationDispatcher (Closed)
Patch Set: Address Mark's comments 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);
mark a. foltz 2017/01/03 18:39:19 Do these test cases actually use private members o
takumif 2017/01/03 23:29:50 Yes, PresentationDispatcher implements the methods
54 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError);
55 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession);
56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError);
57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString);
58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer);
59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData);
60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession);
61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession);
62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
63 TestListenForScreenAvailability);
64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
65 TestSetDefaultPresentationUrls);
66
50 struct SendMessageRequest { 67 struct SendMessageRequest {
51 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, 68 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info,
52 blink::mojom::ConnectionMessagePtr message); 69 blink::mojom::ConnectionMessagePtr message);
53 ~SendMessageRequest(); 70 ~SendMessageRequest();
54 71
55 blink::mojom::PresentationSessionInfoPtr session_info; 72 blink::mojom::PresentationSessionInfoPtr session_info;
56 blink::mojom::ConnectionMessagePtr message; 73 blink::mojom::ConnectionMessagePtr message;
57 }; 74 };
58 75
59 static SendMessageRequest* CreateSendTextMessageRequest( 76 static SendMessageRequest* CreateSendTextMessageRequest(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 blink::mojom::PresentationErrorPtr error); 147 blink::mojom::PresentationErrorPtr error);
131 void OnReceiverConnectionAvailable( 148 void OnReceiverConnectionAvailable(
132 blink::mojom::PresentationSessionInfoPtr) override; 149 blink::mojom::PresentationSessionInfoPtr) override;
133 150
134 // Call to PresentationService to send the message in |request|. 151 // Call to PresentationService to send the message in |request|.
135 // |session_info| and |message| of |reuqest| will be consumed. 152 // |session_info| and |message| of |reuqest| will be consumed.
136 // |HandleSendMessageRequests| will be invoked after the send is attempted. 153 // |HandleSendMessageRequests| will be invoked after the send is attempted.
137 void DoSendMessage(SendMessageRequest* request); 154 void DoSendMessage(SendMessageRequest* request);
138 void HandleSendMessageRequests(bool success); 155 void HandleSendMessageRequests(bool success);
139 156
140 void ConnectToPresentationServiceIfNeeded(); 157 virtual void ConnectToPresentationServiceIfNeeded();
141 158
142 void UpdateListeningState(); 159 void UpdateListeningState();
143 160
144 // 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.
145 blink::WebPresentationController* controller_; 162 blink::WebPresentationController* controller_;
146 blink::WebPresentationReceiver* receiver_; 163 blink::WebPresentationReceiver* receiver_;
147 blink::mojom::PresentationServicePtr presentation_service_; 164 blink::mojom::PresentationServicePtr presentation_service_;
148 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; 165 mojo::Binding<blink::mojom::PresentationServiceClient> binding_;
149 166
150 // 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
182 // Updates the listening state of availability for |status| and notifies the 199 // Updates the listening state of availability for |status| and notifies the
183 // client. 200 // client.
184 void UpdateListeningState(AvailabilityStatus* status); 201 void UpdateListeningState(AvailabilityStatus* status);
185 202
186 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 203 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
187 }; 204 };
188 205
189 } // namespace content 206 } // namespace content
190 207
191 #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