| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/test_runner/web_view_test_client.h" | 5 #include "components/test_runner/web_view_test_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "components/test_runner/event_sender.h" | 13 #include "components/test_runner/event_sender.h" |
| 14 #include "components/test_runner/mock_web_speech_recognizer.h" | 14 #include "components/test_runner/mock_web_speech_recognizer.h" |
| 15 #include "components/test_runner/test_common.h" | 15 #include "components/test_runner/test_common.h" |
| 16 #include "components/test_runner/test_runner.h" | 16 #include "components/test_runner/test_runner.h" |
| 17 #include "components/test_runner/test_runner_for_specific_view.h" | 17 #include "components/test_runner/test_runner_for_specific_view.h" |
| 18 #include "components/test_runner/web_task.h" | 18 #include "components/test_runner/web_task.h" |
| 19 #include "components/test_runner/web_test_delegate.h" | 19 #include "components/test_runner/web_test_delegate.h" |
| 20 #include "components/test_runner/web_test_proxy.h" | 20 #include "components/test_runner/web_view_test_proxy.h" |
| 21 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 21 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 22 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 24 #include "third_party/WebKit/public/web/WebPagePopup.h" | 24 #include "third_party/WebKit/public/web/WebPagePopup.h" |
| 25 #include "third_party/WebKit/public/web/WebPrintParams.h" | 25 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 27 #include "third_party/WebKit/public/web/WebWidget.h" | 27 #include "third_party/WebKit/public/web/WebWidget.h" |
| 28 | 28 |
| 29 namespace test_runner { | 29 namespace test_runner { |
| 30 | 30 |
| 31 WebViewTestClient::WebViewTestClient(TestRunner* test_runner, | 31 WebViewTestClient::WebViewTestClient( |
| 32 WebTestProxyBase* web_test_proxy_base) | 32 TestRunner* test_runner, |
| 33 WebViewTestProxyBase* web_view_test_proxy_base) |
| 33 : test_runner_(test_runner), | 34 : test_runner_(test_runner), |
| 34 web_test_proxy_base_(web_test_proxy_base) { | 35 web_view_test_proxy_base_(web_view_test_proxy_base) { |
| 35 DCHECK(test_runner); | 36 DCHECK(test_runner); |
| 36 DCHECK(web_test_proxy_base); | 37 DCHECK(web_view_test_proxy_base); |
| 37 } | 38 } |
| 38 | 39 |
| 39 WebViewTestClient::~WebViewTestClient() {} | 40 WebViewTestClient::~WebViewTestClient() {} |
| 40 | 41 |
| 41 void WebViewTestClient::startDragging(blink::WebLocalFrame* frame, | 42 void WebViewTestClient::startDragging(blink::WebLocalFrame* frame, |
| 42 const blink::WebDragData& data, | 43 const blink::WebDragData& data, |
| 43 blink::WebDragOperationsMask mask, | 44 blink::WebDragOperationsMask mask, |
| 44 const blink::WebImage& image, | 45 const blink::WebImage& image, |
| 45 const blink::WebPoint& point) { | 46 const blink::WebPoint& point) { |
| 46 test_runner_->setDragImage(image); | 47 test_runner_->setDragImage(image); |
| 47 | 48 |
| 48 // When running a test, we need to fake a drag drop operation otherwise | 49 // When running a test, we need to fake a drag drop operation otherwise |
| 49 // Windows waits for real mouse events to know when the drag is over. | 50 // Windows waits for real mouse events to know when the drag is over. |
| 50 web_test_proxy_base_->event_sender()->DoDragDrop(data, mask); | 51 web_view_test_proxy_base_->event_sender()->DoDragDrop(data, mask); |
| 51 } | 52 } |
| 52 | 53 |
| 53 // The output from these methods in layout test mode should match that | 54 // The output from these methods in layout test mode should match that |
| 54 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. | 55 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. |
| 55 | 56 |
| 56 void WebViewTestClient::didChangeContents() { | 57 void WebViewTestClient::didChangeContents() { |
| 57 if (test_runner_->shouldDumpEditingCallbacks()) | 58 if (test_runner_->shouldDumpEditingCallbacks()) |
| 58 delegate()->PrintMessage( | 59 delegate()->PrintMessage( |
| 59 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); | 60 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); |
| 60 } | 61 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 URLDescription(request.url()) + "' is '" + | 72 URLDescription(request.url()) + "' is '" + |
| 72 WebNavigationPolicyToString(policy) + "'\n"); | 73 WebNavigationPolicyToString(policy) + "'\n"); |
| 73 } | 74 } |
| 74 | 75 |
| 75 if (!test_runner_->canOpenWindows()) | 76 if (!test_runner_->canOpenWindows()) |
| 76 return nullptr; | 77 return nullptr; |
| 77 if (test_runner_->shouldDumpCreateView()) | 78 if (test_runner_->shouldDumpCreateView()) |
| 78 delegate()->PrintMessage(std::string("createView(") + | 79 delegate()->PrintMessage(std::string("createView(") + |
| 79 URLDescription(request.url()) + ")\n"); | 80 URLDescription(request.url()) + ")\n"); |
| 80 | 81 |
| 81 // The return value below is used to communicate to WebTestProxy whether it | 82 // The return value below is used to communicate to WebViewTestProxy whether |
| 82 // should forward the createView request to RenderViewImpl or not. The | 83 // it should forward the createView request to RenderViewImpl or not. The |
| 83 // somewhat ugly cast is used to do this while fitting into the existing | 84 // somewhat ugly cast is used to do this while fitting into the existing |
| 84 // WebViewClient interface. | 85 // WebViewClient interface. |
| 85 return reinterpret_cast<blink::WebView*>(0xdeadbeef); | 86 return reinterpret_cast<blink::WebView*>(0xdeadbeef); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void WebViewTestClient::setStatusText(const blink::WebString& text) { | 89 void WebViewTestClient::setStatusText(const blink::WebString& text) { |
| 89 if (!test_runner_->shouldDumpStatusCallbacks()) | 90 if (!test_runner_->shouldDumpStatusCallbacks()) |
| 90 return; | 91 return; |
| 91 delegate()->PrintMessage( | 92 delegate()->PrintMessage( |
| 92 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") + | 93 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") + |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 blink::WebSpeechRecognizer* WebViewTestClient::speechRecognizer() { | 138 blink::WebSpeechRecognizer* WebViewTestClient::speechRecognizer() { |
| 138 return test_runner_->getMockWebSpeechRecognizer(); | 139 return test_runner_->getMockWebSpeechRecognizer(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 blink::WebString WebViewTestClient::acceptLanguages() { | 142 blink::WebString WebViewTestClient::acceptLanguages() { |
| 142 return blink::WebString::fromUTF8(test_runner_->GetAcceptLanguages()); | 143 return blink::WebString::fromUTF8(test_runner_->GetAcceptLanguages()); |
| 143 } | 144 } |
| 144 | 145 |
| 145 WebTestDelegate* WebViewTestClient::delegate() { | 146 WebTestDelegate* WebViewTestClient::delegate() { |
| 146 return web_test_proxy_base_->delegate(); | 147 return web_view_test_proxy_base_->delegate(); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void WebViewTestClient::didFocus() { | 150 void WebViewTestClient::didFocus() { |
| 150 test_runner_->SetFocus(web_test_proxy_base_->web_view(), true); | 151 test_runner_->SetFocus(web_view_test_proxy_base_->web_view(), true); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace test_runner | 154 } // namespace test_runner |
| OLD | NEW |