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