| 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 #include "components/test_runner/web_test_proxy.h" | 5 #include "components/test_runner/web_test_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cctype> | 10 #include <cctype> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 blink::WebView* WebTestProxyBase::GetWebView() const { | 147 blink::WebView* WebTestProxyBase::GetWebView() const { |
| 148 DCHECK(web_widget_); | 148 DCHECK(web_widget_); |
| 149 // TestRunner does not support popup widgets. So |web_widget|_ is always a | 149 // TestRunner does not support popup widgets. So |web_widget|_ is always a |
| 150 // WebView. | 150 // WebView. |
| 151 return static_cast<blink::WebView*>(web_widget_); | 151 return static_cast<blink::WebView*>(web_widget_); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void WebTestProxyBase::Reset() { | 154 void WebTestProxyBase::Reset() { |
| 155 drag_image_.reset(); | 155 drag_image_.reset(); |
| 156 animate_scheduled_ = false; | 156 animate_scheduled_ = false; |
| 157 accept_languages_ = ""; |
| 157 } | 158 } |
| 158 | 159 |
| 159 blink::WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { | 160 blink::WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { |
| 160 return spellcheck_.get(); | 161 return spellcheck_.get(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 bool WebTestProxyBase::RunFileChooser( | 164 bool WebTestProxyBase::RunFileChooser( |
| 164 const blink::WebFileChooserParams& params, | 165 const blink::WebFileChooserParams& params, |
| 165 blink::WebFileChooserCompletion* completion) { | 166 blink::WebFileChooserCompletion* completion) { |
| 166 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); | 167 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 SkPaint paint; | 217 SkPaint paint; |
| 217 paint.setColor(0xFFFF0000); // Fully opaque red | 218 paint.setColor(0xFFFF0000); // Fully opaque red |
| 218 paint.setStyle(SkPaint::kStroke_Style); | 219 paint.setStyle(SkPaint::kStroke_Style); |
| 219 paint.setFlags(SkPaint::kAntiAlias_Flag); | 220 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 220 paint.setStrokeWidth(1.0f); | 221 paint.setStrokeWidth(1.0f); |
| 221 SkIRect rect; // Bounding rect | 222 SkIRect rect; // Bounding rect |
| 222 rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height); | 223 rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height); |
| 223 canvas->drawIRect(rect, paint); | 224 canvas->drawIRect(rect, paint); |
| 224 } | 225 } |
| 225 | 226 |
| 227 void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) { |
| 228 bool notify = accept_languages_ != accept_languages; |
| 229 accept_languages_ = accept_languages; |
| 230 |
| 231 if (notify) |
| 232 GetWebView()->acceptLanguagesChanged(); |
| 233 } |
| 234 |
| 226 void WebTestProxyBase::CopyImageAtAndCapturePixels( | 235 void WebTestProxyBase::CopyImageAtAndCapturePixels( |
| 227 int x, int y, const base::Callback<void(const SkBitmap&)>& callback) { | 236 int x, int y, const base::Callback<void(const SkBitmap&)>& callback) { |
| 228 DCHECK(!callback.is_null()); | 237 DCHECK(!callback.is_null()); |
| 229 uint64_t sequence_number = blink::Platform::current()->clipboard()-> | 238 uint64_t sequence_number = blink::Platform::current()->clipboard()-> |
| 230 sequenceNumber(blink::WebClipboard::Buffer()); | 239 sequenceNumber(blink::WebClipboard::Buffer()); |
| 231 GetWebView()->copyImageAt(blink::WebPoint(x, y)); | 240 GetWebView()->copyImageAt(blink::WebPoint(x, y)); |
| 232 if (sequence_number == blink::Platform::current()->clipboard()-> | 241 if (sequence_number == blink::Platform::current()->clipboard()-> |
| 233 sequenceNumber(blink::WebClipboard::Buffer())) { | 242 sequenceNumber(blink::WebClipboard::Buffer())) { |
| 234 SkBitmap emptyBitmap; | 243 SkBitmap emptyBitmap; |
| 235 callback.Run(emptyBitmap); | 244 callback.Run(emptyBitmap); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 527 } |
| 519 | 528 |
| 520 void WebTestProxyBase::ResetInputMethod() { | 529 void WebTestProxyBase::ResetInputMethod() { |
| 521 // If a composition text exists, then we need to let the browser process | 530 // If a composition text exists, then we need to let the browser process |
| 522 // to cancel the input method's ongoing composition session. | 531 // to cancel the input method's ongoing composition session. |
| 523 if (web_widget_) | 532 if (web_widget_) |
| 524 web_widget_->confirmComposition(); | 533 web_widget_->confirmComposition(); |
| 525 } | 534 } |
| 526 | 535 |
| 527 blink::WebString WebTestProxyBase::acceptLanguages() { | 536 blink::WebString WebTestProxyBase::acceptLanguages() { |
| 528 return blink::WebString::fromUTF8( | 537 return blink::WebString::fromUTF8(accept_languages_); |
| 529 test_interfaces_->GetTestRunner()->GetAcceptLanguages()); | |
| 530 } | 538 } |
| 531 | 539 |
| 532 } // namespace test_runner | 540 } // namespace test_runner |
| OLD | NEW |