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

Side by Side Diff: components/test_runner/web_test_proxy.h

Issue 1821923003: Extract WebFrameClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 5 #ifndef COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
6 #define COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 6 #define COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
7 7
8 #include <deque>
9 #include <map>
10 #include <string> 8 #include <string>
11 9
12 #include "base/callback.h" 10 #include "base/callback.h"
13 #include "base/macros.h" 11 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
15 #include "build/build_config.h" 13 #include "build/build_config.h"
16 #include "components/test_runner/test_runner_export.h" 14 #include "components/test_runner/test_runner_export.h"
17 #include "components/test_runner/web_task.h" 15 #include "components/test_runner/web_task.h"
18 #include "third_party/WebKit/public/platform/WebImage.h" 16 #include "third_party/WebKit/public/platform/WebImage.h"
19 #include "third_party/WebKit/public/platform/WebRect.h" 17 #include "third_party/WebKit/public/platform/WebRect.h"
20 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 18 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
22 #include "third_party/WebKit/public/platform/WebSetSinkIdCallbacks.h"
23 #include "third_party/WebKit/public/platform/WebURLError.h" 19 #include "third_party/WebKit/public/platform/WebURLError.h"
24 #include "third_party/WebKit/public/platform/WebURLRequest.h" 20 #include "third_party/WebKit/public/platform/WebURLRequest.h"
25 #include "third_party/WebKit/public/web/WebAXEnums.h"
26 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" 21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h"
27 #include "third_party/WebKit/public/web/WebDataSource.h"
28 #include "third_party/WebKit/public/web/WebDragOperation.h" 22 #include "third_party/WebKit/public/web/WebDragOperation.h"
29 #include "third_party/WebKit/public/web/WebFrame.h"
30 #include "third_party/WebKit/public/web/WebFrameClient.h"
31 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" 23 #include "third_party/WebKit/public/web/WebHistoryCommitType.h"
32 #include "third_party/WebKit/public/web/WebIconURL.h"
33 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" 24 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
34 #include "third_party/WebKit/public/web/WebNavigationType.h"
35 #include "third_party/WebKit/public/web/WebTextDirection.h" 25 #include "third_party/WebKit/public/web/WebTextDirection.h"
36 26
37 class SkBitmap; 27 class SkBitmap;
38 class SkCanvas; 28 class SkCanvas;
39 29
40 namespace blink { 30 namespace blink {
41 class WebAXObject;
42 class WebAudioDevice;
43 class WebColorChooser;
44 class WebColorChooserClient;
45 class WebDataSource;
46 class WebDragData; 31 class WebDragData;
47 class WebFileChooserCompletion; 32 class WebFileChooserCompletion;
48 class WebFrame;
49 class WebLocalFrame; 33 class WebLocalFrame;
50 class WebMIDIAccessor;
51 class WebMIDIAccessorClient;
52 class WebNode;
53 class WebPlugin;
54 class WebRange;
55 class WebSerializedScriptValue;
56 class WebSpeechRecognizer; 34 class WebSpeechRecognizer;
57 class WebSpellCheckClient; 35 class WebSpellCheckClient;
58 class WebString; 36 class WebString;
59 class WebURL;
60 class WebURLResponse;
61 class WebUserMediaClient;
62 class WebView; 37 class WebView;
63 class WebWidget; 38 class WebWidget;
64 struct WebColorSuggestion;
65 struct WebConsoleMessage;
66 struct WebContextMenuData;
67 struct WebFileChooserParams; 39 struct WebFileChooserParams;
68 struct WebPluginParams;
69 struct WebPoint; 40 struct WebPoint;
70 struct WebSize;
71 struct WebWindowFeatures; 41 struct WebWindowFeatures;
72 typedef unsigned WebColor;
73 } 42 }
74 43
75 namespace test_runner { 44 namespace test_runner {
76 45
77 class MockCredentialManagerClient; 46 class MockCredentialManagerClient;
78 class MockScreenOrientationClient;
79 class MockWebSpeechRecognizer; 47 class MockWebSpeechRecognizer;
80 class MockWebUserMediaClient;
81 class RenderFrame;
82 class SpellCheckClient; 48 class SpellCheckClient;
83 class TestInterfaces; 49 class TestInterfaces;
84 class WebTestDelegate; 50 class WebTestDelegate;
85 class WebTestInterfaces; 51 class WebTestInterfaces;
86 52
87 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that 53 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that
88 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and 54 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and
89 // when it requires a behavior to be different from the usual, it will call 55 // when it requires a behavior to be different from the usual, it will call
90 // WebTestProxyBase that implements the expected behavior. 56 // WebTestProxyBase that implements the expected behavior.
91 // See WebTestProxy class comments for more information. 57 // See WebTestProxy class comments for more information.
92 class TEST_RUNNER_EXPORT WebTestProxyBase { 58 class TEST_RUNNER_EXPORT WebTestProxyBase {
93 public: 59 public:
94 void SetInterfaces(WebTestInterfaces* interfaces); 60 void SetInterfaces(WebTestInterfaces* interfaces);
95 void SetDelegate(WebTestDelegate* delegate); 61 void SetDelegate(WebTestDelegate* delegate);
96 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; } 62 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; }
97 63
98 void Reset(); 64 void Reset();
99 65
100 blink::WebSpellCheckClient* GetSpellCheckClient() const; 66 blink::WebSpellCheckClient* GetSpellCheckClient() const;
101 blink::WebColorChooser* CreateColorChooser(
102 blink::WebColorChooserClient* client,
103 const blink::WebColor& color,
104 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
105 bool RunFileChooser(const blink::WebFileChooserParams& params, 67 bool RunFileChooser(const blink::WebFileChooserParams& params,
106 blink::WebFileChooserCompletion* completion); 68 blink::WebFileChooserCompletion* completion);
107 void ShowValidationMessage(const blink::WebString& main_message, 69 void ShowValidationMessage(const blink::WebString& main_message,
108 blink::WebTextDirection main_message_hint, 70 blink::WebTextDirection main_message_hint,
109 const blink::WebString& sub_message, 71 const blink::WebString& sub_message,
110 blink::WebTextDirection sub_message_hint); 72 blink::WebTextDirection sub_message_hint);
111 73
112 void RunModalAlertDialog(const blink::WebString& message);
113 bool RunModalConfirmDialog(const blink::WebString& message);
114 bool RunModalPromptDialog(const blink::WebString& message,
115 const blink::WebString& default_value,
116 blink::WebString* actual_value);
117 bool RunModalBeforeUnloadDialog(bool is_reload);
118
119 std::string DumpBackForwardLists(); 74 std::string DumpBackForwardLists();
120 void CapturePixelsForPrinting( 75 void CapturePixelsForPrinting(
121 const base::Callback<void(const SkBitmap&)>& callback); 76 const base::Callback<void(const SkBitmap&)>& callback);
122 void CopyImageAtAndCapturePixels( 77 void CopyImageAtAndCapturePixels(
123 int x, int y, const base::Callback<void(const SkBitmap&)>& callback); 78 int x, int y, const base::Callback<void(const SkBitmap&)>& callback);
124 void CapturePixelsAsync( 79 void CapturePixelsAsync(
125 const base::Callback<void(const SkBitmap&)>& callback); 80 const base::Callback<void(const SkBitmap&)>& callback);
126 81
127 void SetLogConsoleOutput(bool enabled);
128
129 void DidOpenChooser();
130 void DidCloseChooser();
131 bool IsChooserShown();
132
133 void LayoutAndPaintAsyncThen(const base::Closure& callback); 82 void LayoutAndPaintAsyncThen(const base::Closure& callback);
134 83
135 void GetScreenOrientationForTesting(blink::WebScreenInfo&); 84 void GetScreenOrientationForTesting(blink::WebScreenInfo&);
136 MockScreenOrientationClient* GetScreenOrientationClientMock();
137 MockWebSpeechRecognizer* GetSpeechRecognizerMock(); 85 MockWebSpeechRecognizer* GetSpeechRecognizerMock();
138 MockCredentialManagerClient* GetCredentialManagerClientMock(); 86 MockCredentialManagerClient* GetCredentialManagerClientMock();
139 87
140 WebTaskList* mutable_task_list() { return &task_list_; } 88 WebTaskList* mutable_task_list() { return &task_list_; }
141 89
142 blink::WebView* GetWebView() const; 90 blink::WebView* GetWebView() const;
143 91
144 void PostSpellCheckEvent(const blink::WebString& event_name); 92 void PostSpellCheckEvent(const blink::WebString& event_name);
145 93
146 void SetAcceptLanguages(const std::string& accept_languages); 94 void SetAcceptLanguages(const std::string& accept_languages);
147 95
148 void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent);
149
150 bool AnimationScheduled() { return animate_scheduled_; } 96 bool AnimationScheduled() { return animate_scheduled_; }
151 97
152 protected: 98 protected:
153 WebTestProxyBase(); 99 WebTestProxyBase();
154 ~WebTestProxyBase(); 100 ~WebTestProxyBase();
155 101
156 void ScheduleAnimation(); 102 void ScheduleAnimation();
157 void StartDragging(blink::WebLocalFrame* frame, 103 void StartDragging(blink::WebLocalFrame* frame,
158 const blink::WebDragData& data, 104 const blink::WebDragData& data,
159 blink::WebDragOperationsMask mask, 105 blink::WebDragOperationsMask mask,
160 const blink::WebImage& image, 106 const blink::WebImage& image,
161 const blink::WebPoint& point); 107 const blink::WebPoint& point);
162 void DidChangeSelection(bool isEmptySelection);
163 void DidChangeContents(); 108 void DidChangeContents();
164 void DidEndEditing(); 109 void DidEndEditing();
165 bool CreateView(blink::WebLocalFrame* creator, 110 bool CreateView(blink::WebLocalFrame* creator,
166 const blink::WebURLRequest& request, 111 const blink::WebURLRequest& request,
167 const blink::WebWindowFeatures& features, 112 const blink::WebWindowFeatures& features,
168 const blink::WebString& frame_name, 113 const blink::WebString& frame_name,
169 blink::WebNavigationPolicy policy, 114 blink::WebNavigationPolicy policy,
170 bool suppress_opener); 115 bool suppress_opener);
171 blink::WebPlugin* CreatePlugin(blink::WebLocalFrame* frame,
172 const blink::WebPluginParams& params);
173 void SetStatusText(const blink::WebString& text); 116 void SetStatusText(const blink::WebString& text);
174 void ShowContextMenu(const blink::WebContextMenuData& data);
175 blink::WebUserMediaClient* GetUserMediaClient();
176 void PrintPage(blink::WebLocalFrame* frame); 117 void PrintPage(blink::WebLocalFrame* frame);
177 blink::WebSpeechRecognizer* GetSpeechRecognizer(); 118 blink::WebSpeechRecognizer* GetSpeechRecognizer();
178 bool RequestPointerLock(); 119 bool RequestPointerLock();
179 void RequestPointerUnlock(); 120 void RequestPointerUnlock();
180 bool IsPointerLocked(); 121 bool IsPointerLocked();
181 void DidFocus(); 122 void DidFocus();
182 void SetToolTipText(const blink::WebString& text, 123 void SetToolTipText(const blink::WebString& text,
183 blink::WebTextDirection direction); 124 blink::WebTextDirection direction);
184 void DidAddMessageToConsole(const blink::WebConsoleMessage& text,
185 const blink::WebString& source_name,
186 unsigned source_line);
187 void LoadURLExternally(const blink::WebURLRequest& request,
188 blink::WebNavigationPolicy policy,
189 const blink::WebString& suggested_name,
190 bool replaces_current_history_item);
191 void DidStartProvisionalLoad(blink::WebLocalFrame*);
192 void DidReceiveServerRedirectForProvisionalLoad(blink::WebLocalFrame* frame);
193 bool DidFailProvisionalLoad(blink::WebLocalFrame* frame,
194 const blink::WebURLError& error,
195 blink::WebHistoryCommitType commit_type);
196 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
197 const blink::WebHistoryItem& history_item,
198 blink::WebHistoryCommitType history_type);
199 void DidReceiveTitle(blink::WebLocalFrame* frame,
200 const blink::WebString& title,
201 blink::WebTextDirection text_direction);
202 void DidChangeIcon(blink::WebLocalFrame* frame,
203 blink::WebIconURL::Type icon_type);
204 void DidFinishDocumentLoad(blink::WebLocalFrame* frame);
205 void DidHandleOnloadEvents(blink::WebLocalFrame* frame);
206 void DidFailLoad(blink::WebLocalFrame* frame,
207 const blink::WebURLError& error,
208 blink::WebHistoryCommitType commit_type);
209 void DidFinishLoad(blink::WebLocalFrame* frame);
210 void DidChangeLocationWithinPage(blink::WebLocalFrame* frame); 125 void DidChangeLocationWithinPage(blink::WebLocalFrame* frame);
211 void DidDetectXSS(const blink::WebURL& insecure_url,
212 bool did_block_entire_page);
213 void DidDispatchPingLoader(const blink::WebURL& url);
214 void WillSendRequest(blink::WebLocalFrame* frame,
215 unsigned identifier,
216 blink::WebURLRequest& request,
217 const blink::WebURLResponse& redirect_response);
218 void DidReceiveResponse(unsigned identifier,
219 const blink::WebURLResponse& response);
220 void DidChangeResourcePriority(unsigned identifier,
221 const blink::WebURLRequest::Priority& priority,
222 int intra_priority_value);
223 void DidFinishResourceLoad(blink::WebLocalFrame* frame, unsigned identifier);
224 blink::WebNavigationPolicy DecidePolicyForNavigation(
225 const blink::WebFrameClient::NavigationPolicyInfo& info);
226 bool WillCheckAndDispatchMessageEvent(blink::WebLocalFrame* source_frame,
227 blink::WebFrame* target_frame,
228 blink::WebSecurityOrigin target,
229 blink::WebDOMMessageEvent event);
230 void ResetInputMethod(); 126 void ResetInputMethod();
231 void CheckIfAudioSinkExistsAndIsAuthorized(
232 const blink::WebString& sink_id,
233 const blink::WebSecurityOrigin& security_origin,
234 blink::WebSetSinkIdCallbacks* web_callbacks);
235 127
236 blink::WebString acceptLanguages(); 128 blink::WebString acceptLanguages();
237 129
238 private: 130 private:
239 template <class, typename>
240 friend class WebFrameTestProxy;
241
242 enum CheckDoneReason {
243 LoadFinished,
244 MainResourceLoadFailed,
245 ResourceLoadCompleted
246 };
247 void CheckDone(blink::WebLocalFrame* frame, CheckDoneReason reason);
248 void AnimateNow(); 131 void AnimateNow();
249 void DrawSelectionRect(SkCanvas* canvas); 132 void DrawSelectionRect(SkCanvas* canvas);
250 void DidCapturePixelsAsync( 133 void DidCapturePixelsAsync(
251 const base::Callback<void(const SkBitmap&)>& callback, 134 const base::Callback<void(const SkBitmap&)>& callback,
252 const SkBitmap& bitmap); 135 const SkBitmap& bitmap);
253 136
254 TestInterfaces* test_interfaces_; 137 TestInterfaces* test_interfaces_;
255 WebTestDelegate* delegate_; 138 WebTestDelegate* delegate_;
256 blink::WebWidget* web_widget_; 139 blink::WebWidget* web_widget_;
257 140
258 WebTaskList task_list_; 141 WebTaskList task_list_;
259 142
260 blink::WebImage drag_image_; 143 blink::WebImage drag_image_;
261 144
262 scoped_ptr<SpellCheckClient> spellcheck_; 145 scoped_ptr<SpellCheckClient> spellcheck_;
263 scoped_ptr<MockWebUserMediaClient> user_media_client_;
264 146
265 bool animate_scheduled_; 147 bool animate_scheduled_;
266 std::map<unsigned, std::string> resource_identifier_map_;
267
268 bool log_console_output_;
269 int chooser_count_;
270 148
271 scoped_ptr<MockCredentialManagerClient> credential_manager_client_; 149 scoped_ptr<MockCredentialManagerClient> credential_manager_client_;
272 scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_; 150 scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_;
273 151
274 std::string accept_languages_; 152 std::string accept_languages_;
275 153
276 private: 154 private:
277 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); 155 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase);
278 }; 156 };
279 157
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 264
387 private: 265 private:
388 virtual ~WebTestProxy() {} 266 virtual ~WebTestProxy() {}
389 267
390 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); 268 DISALLOW_COPY_AND_ASSIGN(WebTestProxy);
391 }; 269 };
392 270
393 } // namespace test_runner 271 } // namespace test_runner
394 272
395 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 273 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698