| OLD | NEW |
| 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> |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 14 #include "components/test_runner/test_runner_export.h" | 16 #include "components/test_runner/test_runner_export.h" |
| 15 #include "components/test_runner/web_task.h" | 17 #include "components/test_runner/web_task.h" |
| 16 #include "third_party/WebKit/public/platform/WebImage.h" | 18 #include "third_party/WebKit/public/platform/WebImage.h" |
| 17 #include "third_party/WebKit/public/platform/WebRect.h" | 19 #include "third_party/WebKit/public/platform/WebRect.h" |
| 18 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 20 #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" |
| 19 #include "third_party/WebKit/public/platform/WebURLError.h" | 23 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 24 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 25 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 26 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
| 27 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 22 #include "third_party/WebKit/public/web/WebDragOperation.h" | 28 #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" |
| 23 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" | 31 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
| 32 #include "third_party/WebKit/public/web/WebIconURL.h" |
| 24 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 33 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 34 #include "third_party/WebKit/public/web/WebNavigationType.h" |
| 25 #include "third_party/WebKit/public/web/WebTextDirection.h" | 35 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 26 | 36 |
| 27 class SkBitmap; | 37 class SkBitmap; |
| 28 class SkCanvas; | 38 class SkCanvas; |
| 29 | 39 |
| 30 namespace blink { | 40 namespace blink { |
| 41 class WebAXObject; |
| 42 class WebAudioDevice; |
| 43 class WebColorChooser; |
| 44 class WebColorChooserClient; |
| 45 class WebDataSource; |
| 31 class WebDragData; | 46 class WebDragData; |
| 32 class WebFileChooserCompletion; | 47 class WebFileChooserCompletion; |
| 48 class WebFrame; |
| 33 class WebLocalFrame; | 49 class WebLocalFrame; |
| 50 class WebMIDIAccessor; |
| 51 class WebMIDIAccessorClient; |
| 52 class WebNode; |
| 53 class WebPlugin; |
| 54 class WebRange; |
| 55 class WebSerializedScriptValue; |
| 34 class WebSpeechRecognizer; | 56 class WebSpeechRecognizer; |
| 35 class WebSpellCheckClient; | 57 class WebSpellCheckClient; |
| 36 class WebString; | 58 class WebString; |
| 59 class WebURL; |
| 60 class WebURLResponse; |
| 61 class WebUserMediaClient; |
| 37 class WebView; | 62 class WebView; |
| 38 class WebWidget; | 63 class WebWidget; |
| 64 struct WebColorSuggestion; |
| 65 struct WebConsoleMessage; |
| 66 struct WebContextMenuData; |
| 39 struct WebFileChooserParams; | 67 struct WebFileChooserParams; |
| 68 struct WebPluginParams; |
| 40 struct WebPoint; | 69 struct WebPoint; |
| 70 struct WebSize; |
| 41 struct WebWindowFeatures; | 71 struct WebWindowFeatures; |
| 72 typedef unsigned WebColor; |
| 42 } | 73 } |
| 43 | 74 |
| 44 namespace test_runner { | 75 namespace test_runner { |
| 45 | 76 |
| 46 class MockCredentialManagerClient; | 77 class MockCredentialManagerClient; |
| 78 class MockScreenOrientationClient; |
| 47 class MockWebSpeechRecognizer; | 79 class MockWebSpeechRecognizer; |
| 80 class MockWebUserMediaClient; |
| 81 class RenderFrame; |
| 48 class SpellCheckClient; | 82 class SpellCheckClient; |
| 49 class TestInterfaces; | 83 class TestInterfaces; |
| 50 class WebTestDelegate; | 84 class WebTestDelegate; |
| 51 class WebTestInterfaces; | 85 class WebTestInterfaces; |
| 52 | 86 |
| 53 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that | 87 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that |
| 54 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and | 88 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and |
| 55 // when it requires a behavior to be different from the usual, it will call | 89 // when it requires a behavior to be different from the usual, it will call |
| 56 // WebTestProxyBase that implements the expected behavior. | 90 // WebTestProxyBase that implements the expected behavior. |
| 57 // See WebTestProxy class comments for more information. | 91 // See WebTestProxy class comments for more information. |
| 58 class TEST_RUNNER_EXPORT WebTestProxyBase { | 92 class TEST_RUNNER_EXPORT WebTestProxyBase { |
| 59 public: | 93 public: |
| 60 void SetInterfaces(WebTestInterfaces* interfaces); | 94 void SetInterfaces(WebTestInterfaces* interfaces); |
| 61 void SetDelegate(WebTestDelegate* delegate); | 95 void SetDelegate(WebTestDelegate* delegate); |
| 62 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; } | 96 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; } |
| 63 | 97 |
| 64 void Reset(); | 98 void Reset(); |
| 65 | 99 |
| 66 blink::WebSpellCheckClient* GetSpellCheckClient() const; | 100 blink::WebSpellCheckClient* GetSpellCheckClient() const; |
| 101 blink::WebColorChooser* CreateColorChooser( |
| 102 blink::WebColorChooserClient* client, |
| 103 const blink::WebColor& color, |
| 104 const blink::WebVector<blink::WebColorSuggestion>& suggestions); |
| 67 bool RunFileChooser(const blink::WebFileChooserParams& params, | 105 bool RunFileChooser(const blink::WebFileChooserParams& params, |
| 68 blink::WebFileChooserCompletion* completion); | 106 blink::WebFileChooserCompletion* completion); |
| 69 void ShowValidationMessage(const blink::WebString& main_message, | 107 void ShowValidationMessage(const blink::WebString& main_message, |
| 70 blink::WebTextDirection main_message_hint, | 108 blink::WebTextDirection main_message_hint, |
| 71 const blink::WebString& sub_message, | 109 const blink::WebString& sub_message, |
| 72 blink::WebTextDirection sub_message_hint); | 110 blink::WebTextDirection sub_message_hint); |
| 73 | 111 |
| 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 |
| 74 std::string DumpBackForwardLists(); | 119 std::string DumpBackForwardLists(); |
| 75 void CapturePixelsForPrinting( | 120 void CapturePixelsForPrinting( |
| 76 const base::Callback<void(const SkBitmap&)>& callback); | 121 const base::Callback<void(const SkBitmap&)>& callback); |
| 77 void CopyImageAtAndCapturePixels( | 122 void CopyImageAtAndCapturePixels( |
| 78 int x, int y, const base::Callback<void(const SkBitmap&)>& callback); | 123 int x, int y, const base::Callback<void(const SkBitmap&)>& callback); |
| 79 void CapturePixelsAsync( | 124 void CapturePixelsAsync( |
| 80 const base::Callback<void(const SkBitmap&)>& callback); | 125 const base::Callback<void(const SkBitmap&)>& callback); |
| 81 | 126 |
| 127 void SetLogConsoleOutput(bool enabled); |
| 128 |
| 129 void DidOpenChooser(); |
| 130 void DidCloseChooser(); |
| 131 bool IsChooserShown(); |
| 132 |
| 82 void LayoutAndPaintAsyncThen(const base::Closure& callback); | 133 void LayoutAndPaintAsyncThen(const base::Closure& callback); |
| 83 | 134 |
| 84 void GetScreenOrientationForTesting(blink::WebScreenInfo&); | 135 void GetScreenOrientationForTesting(blink::WebScreenInfo&); |
| 136 MockScreenOrientationClient* GetScreenOrientationClientMock(); |
| 85 MockWebSpeechRecognizer* GetSpeechRecognizerMock(); | 137 MockWebSpeechRecognizer* GetSpeechRecognizerMock(); |
| 86 MockCredentialManagerClient* GetCredentialManagerClientMock(); | 138 MockCredentialManagerClient* GetCredentialManagerClientMock(); |
| 87 | 139 |
| 88 WebTaskList* mutable_task_list() { return &task_list_; } | 140 WebTaskList* mutable_task_list() { return &task_list_; } |
| 89 | 141 |
| 90 blink::WebView* GetWebView() const; | 142 blink::WebView* GetWebView() const; |
| 91 | 143 |
| 92 void PostSpellCheckEvent(const blink::WebString& event_name); | 144 void PostSpellCheckEvent(const blink::WebString& event_name); |
| 93 | 145 |
| 94 void SetAcceptLanguages(const std::string& accept_languages); | 146 void SetAcceptLanguages(const std::string& accept_languages); |
| 95 | 147 |
| 148 void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent); |
| 149 |
| 96 bool AnimationScheduled() { return animate_scheduled_; } | 150 bool AnimationScheduled() { return animate_scheduled_; } |
| 97 | 151 |
| 98 protected: | 152 protected: |
| 99 WebTestProxyBase(); | 153 WebTestProxyBase(); |
| 100 ~WebTestProxyBase(); | 154 ~WebTestProxyBase(); |
| 101 | 155 |
| 102 void ScheduleAnimation(); | 156 void ScheduleAnimation(); |
| 103 void StartDragging(blink::WebLocalFrame* frame, | 157 void StartDragging(blink::WebLocalFrame* frame, |
| 104 const blink::WebDragData& data, | 158 const blink::WebDragData& data, |
| 105 blink::WebDragOperationsMask mask, | 159 blink::WebDragOperationsMask mask, |
| 106 const blink::WebImage& image, | 160 const blink::WebImage& image, |
| 107 const blink::WebPoint& point); | 161 const blink::WebPoint& point); |
| 162 void DidChangeSelection(bool isEmptySelection); |
| 108 void DidChangeContents(); | 163 void DidChangeContents(); |
| 109 void DidEndEditing(); | 164 void DidEndEditing(); |
| 110 bool CreateView(blink::WebLocalFrame* creator, | 165 bool CreateView(blink::WebLocalFrame* creator, |
| 111 const blink::WebURLRequest& request, | 166 const blink::WebURLRequest& request, |
| 112 const blink::WebWindowFeatures& features, | 167 const blink::WebWindowFeatures& features, |
| 113 const blink::WebString& frame_name, | 168 const blink::WebString& frame_name, |
| 114 blink::WebNavigationPolicy policy, | 169 blink::WebNavigationPolicy policy, |
| 115 bool suppress_opener); | 170 bool suppress_opener); |
| 171 blink::WebPlugin* CreatePlugin(blink::WebLocalFrame* frame, |
| 172 const blink::WebPluginParams& params); |
| 116 void SetStatusText(const blink::WebString& text); | 173 void SetStatusText(const blink::WebString& text); |
| 174 void ShowContextMenu(const blink::WebContextMenuData& data); |
| 175 blink::WebUserMediaClient* GetUserMediaClient(); |
| 117 void PrintPage(blink::WebLocalFrame* frame); | 176 void PrintPage(blink::WebLocalFrame* frame); |
| 118 blink::WebSpeechRecognizer* GetSpeechRecognizer(); | 177 blink::WebSpeechRecognizer* GetSpeechRecognizer(); |
| 119 bool RequestPointerLock(); | 178 bool RequestPointerLock(); |
| 120 void RequestPointerUnlock(); | 179 void RequestPointerUnlock(); |
| 121 bool IsPointerLocked(); | 180 bool IsPointerLocked(); |
| 122 void DidFocus(); | 181 void DidFocus(); |
| 123 void SetToolTipText(const blink::WebString& text, | 182 void SetToolTipText(const blink::WebString& text, |
| 124 blink::WebTextDirection direction); | 183 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); |
| 125 void DidChangeLocationWithinPage(blink::WebLocalFrame* frame); | 210 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); |
| 126 void ResetInputMethod(); | 230 void ResetInputMethod(); |
| 231 void CheckIfAudioSinkExistsAndIsAuthorized( |
| 232 const blink::WebString& sink_id, |
| 233 const blink::WebSecurityOrigin& security_origin, |
| 234 blink::WebSetSinkIdCallbacks* web_callbacks); |
| 127 | 235 |
| 128 blink::WebString acceptLanguages(); | 236 blink::WebString acceptLanguages(); |
| 129 | 237 |
| 130 private: | 238 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); |
| 131 void AnimateNow(); | 248 void AnimateNow(); |
| 132 void DrawSelectionRect(SkCanvas* canvas); | 249 void DrawSelectionRect(SkCanvas* canvas); |
| 133 void DidCapturePixelsAsync( | 250 void DidCapturePixelsAsync( |
| 134 const base::Callback<void(const SkBitmap&)>& callback, | 251 const base::Callback<void(const SkBitmap&)>& callback, |
| 135 const SkBitmap& bitmap); | 252 const SkBitmap& bitmap); |
| 136 | 253 |
| 137 TestInterfaces* test_interfaces_; | 254 TestInterfaces* test_interfaces_; |
| 138 WebTestDelegate* delegate_; | 255 WebTestDelegate* delegate_; |
| 139 blink::WebWidget* web_widget_; | 256 blink::WebWidget* web_widget_; |
| 140 | 257 |
| 141 WebTaskList task_list_; | 258 WebTaskList task_list_; |
| 142 | 259 |
| 143 blink::WebImage drag_image_; | 260 blink::WebImage drag_image_; |
| 144 | 261 |
| 145 scoped_ptr<SpellCheckClient> spellcheck_; | 262 scoped_ptr<SpellCheckClient> spellcheck_; |
| 263 scoped_ptr<MockWebUserMediaClient> user_media_client_; |
| 146 | 264 |
| 147 bool animate_scheduled_; | 265 bool animate_scheduled_; |
| 266 std::map<unsigned, std::string> resource_identifier_map_; |
| 267 |
| 268 bool log_console_output_; |
| 269 int chooser_count_; |
| 148 | 270 |
| 149 scoped_ptr<MockCredentialManagerClient> credential_manager_client_; | 271 scoped_ptr<MockCredentialManagerClient> credential_manager_client_; |
| 150 scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_; | 272 scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_; |
| 151 | 273 |
| 152 std::string accept_languages_; | 274 std::string accept_languages_; |
| 153 | 275 |
| 154 private: | 276 private: |
| 155 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); | 277 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); |
| 156 }; | 278 }; |
| 157 | 279 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 386 |
| 265 private: | 387 private: |
| 266 virtual ~WebTestProxy() {} | 388 virtual ~WebTestProxy() {} |
| 267 | 389 |
| 268 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); | 390 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); |
| 269 }; | 391 }; |
| 270 | 392 |
| 271 } // namespace test_runner | 393 } // namespace test_runner |
| 272 | 394 |
| 273 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ | 395 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ |
| OLD | NEW |