| 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_frame_test_client.h" | 5 #include "components/test_runner/web_frame_test_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "components/test_runner/accessibility_controller.h" | 13 #include "components/test_runner/accessibility_controller.h" |
| 14 #include "components/test_runner/event_sender.h" | 14 #include "components/test_runner/event_sender.h" |
| 15 #include "components/test_runner/mock_color_chooser.h" | 15 #include "components/test_runner/mock_color_chooser.h" |
| 16 #include "components/test_runner/mock_screen_orientation_client.h" | 16 #include "components/test_runner/mock_screen_orientation_client.h" |
| 17 #include "components/test_runner/mock_web_user_media_client.h" | 17 #include "components/test_runner/mock_web_user_media_client.h" |
| 18 #include "components/test_runner/test_common.h" | 18 #include "components/test_runner/test_common.h" |
| 19 #include "components/test_runner/test_interfaces.h" | 19 #include "components/test_runner/test_interfaces.h" |
| 20 #include "components/test_runner/test_plugin.h" | 20 #include "components/test_runner/test_plugin.h" |
| 21 #include "components/test_runner/test_runner.h" | 21 #include "components/test_runner/test_runner.h" |
| 22 #include "components/test_runner/web_frame_test_proxy.h" | 22 #include "components/test_runner/web_frame_test_proxy.h" |
| 23 #include "components/test_runner/web_test_delegate.h" | 23 #include "components/test_runner/web_test_delegate.h" |
| 24 #include "components/test_runner/web_test_proxy.h" | 24 #include "components/test_runner/web_view_test_proxy.h" |
| 25 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 26 #include "third_party/WebKit/public/platform/WebURL.h" | 26 #include "third_party/WebKit/public/platform/WebURL.h" |
| 27 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 27 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 28 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 28 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 29 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 29 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 30 #include "third_party/WebKit/public/web/WebElement.h" | 30 #include "third_party/WebKit/public/web/WebElement.h" |
| 31 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
| 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 33 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 33 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 34 #include "third_party/WebKit/public/web/WebPluginParams.h" | 34 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return kOtherString; | 179 return kOtherString; |
| 180 } | 180 } |
| 181 return kIllegalString; | 181 return kIllegalString; |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace | 184 } // namespace |
| 185 | 185 |
| 186 WebFrameTestClient::WebFrameTestClient( | 186 WebFrameTestClient::WebFrameTestClient( |
| 187 TestRunner* test_runner, | 187 TestRunner* test_runner, |
| 188 WebTestDelegate* delegate, | 188 WebTestDelegate* delegate, |
| 189 WebTestProxyBase* web_test_proxy_base, | 189 WebViewTestProxyBase* web_view_test_proxy_base, |
| 190 WebFrameTestProxyBase* web_frame_test_proxy_base) | 190 WebFrameTestProxyBase* web_frame_test_proxy_base) |
| 191 : test_runner_(test_runner), | 191 : test_runner_(test_runner), |
| 192 delegate_(delegate), | 192 delegate_(delegate), |
| 193 web_test_proxy_base_(web_test_proxy_base), | 193 web_view_test_proxy_base_(web_view_test_proxy_base), |
| 194 web_frame_test_proxy_base_(web_frame_test_proxy_base) { | 194 web_frame_test_proxy_base_(web_frame_test_proxy_base) { |
| 195 DCHECK(test_runner); | 195 DCHECK(test_runner); |
| 196 DCHECK(delegate_); | 196 DCHECK(delegate_); |
| 197 DCHECK(web_test_proxy_base_); | 197 DCHECK(web_view_test_proxy_base_); |
| 198 } | 198 } |
| 199 | 199 |
| 200 WebFrameTestClient::~WebFrameTestClient() {} | 200 WebFrameTestClient::~WebFrameTestClient() {} |
| 201 | 201 |
| 202 blink::WebColorChooser* WebFrameTestClient::createColorChooser( | 202 blink::WebColorChooser* WebFrameTestClient::createColorChooser( |
| 203 blink::WebColorChooserClient* client, | 203 blink::WebColorChooserClient* client, |
| 204 const blink::WebColor& color, | 204 const blink::WebColor& color, |
| 205 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { | 205 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
| 206 // This instance is deleted by WebCore::ColorInputType | 206 // This instance is deleted by WebCore::ColorInputType |
| 207 return new MockColorChooser(client, delegate_, test_runner_); | 207 return new MockColorChooser(client, delegate_, test_runner_); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 break; | 347 break; |
| 348 case blink::WebAXEventValueChanged: | 348 case blink::WebAXEventValueChanged: |
| 349 event_name = "ValueChanged"; | 349 event_name = "ValueChanged"; |
| 350 break; | 350 break; |
| 351 default: | 351 default: |
| 352 event_name = "Unknown"; | 352 event_name = "Unknown"; |
| 353 break; | 353 break; |
| 354 } | 354 } |
| 355 | 355 |
| 356 AccessibilityController* accessibility_controller = | 356 AccessibilityController* accessibility_controller = |
| 357 web_test_proxy_base_->accessibility_controller(); | 357 web_view_test_proxy_base_->accessibility_controller(); |
| 358 accessibility_controller->NotificationReceived(obj, event_name); | 358 accessibility_controller->NotificationReceived(obj, event_name); |
| 359 if (accessibility_controller->ShouldLogAccessibilityEvents()) { | 359 if (accessibility_controller->ShouldLogAccessibilityEvents()) { |
| 360 std::string message("AccessibilityNotification - "); | 360 std::string message("AccessibilityNotification - "); |
| 361 message += event_name; | 361 message += event_name; |
| 362 | 362 |
| 363 blink::WebNode node = obj.node(); | 363 blink::WebNode node = obj.node(); |
| 364 if (!node.isNull() && node.isElementNode()) { | 364 if (!node.isNull() && node.isElementNode()) { |
| 365 blink::WebElement element = node.to<blink::WebElement>(); | 365 blink::WebElement element = node.to<blink::WebElement>(); |
| 366 if (element.hasAttribute("id")) { | 366 if (element.hasAttribute("id")) { |
| 367 message += " - id:"; | 367 message += " - id:"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 383 blink::WebPlugin* WebFrameTestClient::createPlugin( | 383 blink::WebPlugin* WebFrameTestClient::createPlugin( |
| 384 blink::WebLocalFrame* frame, | 384 blink::WebLocalFrame* frame, |
| 385 const blink::WebPluginParams& params) { | 385 const blink::WebPluginParams& params) { |
| 386 if (TestPlugin::IsSupportedMimeType(params.mimeType)) | 386 if (TestPlugin::IsSupportedMimeType(params.mimeType)) |
| 387 return TestPlugin::create(frame, params, delegate_); | 387 return TestPlugin::create(frame, params, delegate_); |
| 388 return delegate_->CreatePluginPlaceholder(frame, params); | 388 return delegate_->CreatePluginPlaceholder(frame, params); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void WebFrameTestClient::showContextMenu( | 391 void WebFrameTestClient::showContextMenu( |
| 392 const blink::WebContextMenuData& context_menu_data) { | 392 const blink::WebContextMenuData& context_menu_data) { |
| 393 web_test_proxy_base_->event_sender()->SetContextMenuData(context_menu_data); | 393 web_view_test_proxy_base_->event_sender()->SetContextMenuData( |
| 394 context_menu_data); |
| 394 } | 395 } |
| 395 | 396 |
| 396 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() { | 397 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() { |
| 397 return test_runner_->getMockWebUserMediaClient(); | 398 return test_runner_->getMockWebUserMediaClient(); |
| 398 } | 399 } |
| 399 | 400 |
| 400 void WebFrameTestClient::loadURLExternally( | 401 void WebFrameTestClient::loadURLExternally( |
| 401 const blink::WebURLRequest& request, | 402 const blink::WebURLRequest& request, |
| 402 blink::WebNavigationPolicy policy, | 403 blink::WebNavigationPolicy policy, |
| 403 const blink::WebString& suggested_name, | 404 const blink::WebString& suggested_name, |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 std::string device_id = sink_id.utf8(); | 742 std::string device_id = sink_id.utf8(); |
| 742 if (device_id == "valid" || device_id.empty()) | 743 if (device_id == "valid" || device_id.empty()) |
| 743 callback->onSuccess(); | 744 callback->onSuccess(); |
| 744 else if (device_id == "unauthorized") | 745 else if (device_id == "unauthorized") |
| 745 callback->onError(blink::WebSetSinkIdError::NotAuthorized); | 746 callback->onError(blink::WebSetSinkIdError::NotAuthorized); |
| 746 else | 747 else |
| 747 callback->onError(blink::WebSetSinkIdError::NotFound); | 748 callback->onError(blink::WebSetSinkIdError::NotFound); |
| 748 } | 749 } |
| 749 | 750 |
| 750 void WebFrameTestClient::didClearWindowObject(blink::WebLocalFrame* frame) { | 751 void WebFrameTestClient::didClearWindowObject(blink::WebLocalFrame* frame) { |
| 751 web_test_proxy_base_->test_interfaces()->BindTo(frame); | 752 web_view_test_proxy_base_->test_interfaces()->BindTo(frame); |
| 752 web_test_proxy_base_->BindTo(frame); | 753 web_view_test_proxy_base_->BindTo(frame); |
| 753 } | 754 } |
| 754 | 755 |
| 755 bool WebFrameTestClient::runFileChooser( | 756 bool WebFrameTestClient::runFileChooser( |
| 756 const blink::WebFileChooserParams& params, | 757 const blink::WebFileChooserParams& params, |
| 757 blink::WebFileChooserCompletion* completion) { | 758 blink::WebFileChooserCompletion* completion) { |
| 758 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); | 759 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); |
| 759 // FIXME: Add ability to set file names to a file upload control. | 760 // FIXME: Add ability to set file names to a file upload control. |
| 760 return false; | 761 return false; |
| 761 } | 762 } |
| 762 | 763 |
| 763 } // namespace test_runner | 764 } // namespace test_runner |
| OLD | NEW |