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 "content/shell/renderer/test_runner/web_test_proxy.h" | 5 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) { | 475 void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) { |
476 bool notify = accept_languages_ != accept_languages; | 476 bool notify = accept_languages_ != accept_languages; |
477 accept_languages_ = accept_languages; | 477 accept_languages_ = accept_languages; |
478 | 478 |
479 if (notify) | 479 if (notify) |
480 GetWebView()->acceptLanguagesChanged(); | 480 GetWebView()->acceptLanguagesChanged(); |
481 } | 481 } |
482 | 482 |
483 void WebTestProxyBase::CopyImageAtAndCapturePixels( | 483 void WebTestProxyBase::CopyImageAtAndCapturePixels( |
484 int x, int y, const base::Callback<void(const SkBitmap&)>& callback) { | 484 int x, int y, const base::Callback<void(const SkBitmap&)>& callback) { |
485 // It may happen that there is a scheduled animation and | |
486 // no rootGraphicsLayer yet. If so we would run it right now. Otherwise | |
487 // isAcceleratedCompositingActive will return false; | |
488 AnimateNow(); | |
danakj
2014/09/18 15:33:41
I think we need to fix WebViewImpl/blink, not just
| |
489 | |
485 DCHECK(web_widget_->isAcceleratedCompositingActive()); | 490 DCHECK(web_widget_->isAcceleratedCompositingActive()); |
486 DCHECK(!callback.is_null()); | 491 DCHECK(!callback.is_null()); |
487 uint64_t sequence_number = blink::Platform::current()->clipboard()-> | 492 uint64_t sequence_number = blink::Platform::current()->clipboard()-> |
488 sequenceNumber(blink::WebClipboard::Buffer()); | 493 sequenceNumber(blink::WebClipboard::Buffer()); |
489 GetWebView()->copyImageAt(blink::WebPoint(x, y)); | 494 GetWebView()->copyImageAt(blink::WebPoint(x, y)); |
490 if (sequence_number == blink::Platform::current()->clipboard()-> | 495 if (sequence_number == blink::Platform::current()->clipboard()-> |
491 sequenceNumber(blink::WebClipboard::Buffer())) { | 496 sequenceNumber(blink::WebClipboard::Buffer())) { |
492 SkBitmap emptyBitmap; | 497 SkBitmap emptyBitmap; |
493 callback.Run(emptyBitmap); | 498 callback.Run(emptyBitmap); |
494 return; | 499 return; |
(...skipping 30 matching lines...) Expand all Loading... | |
525 DrawSelectionRect(canvas.get()); | 530 DrawSelectionRect(canvas.get()); |
526 SkBaseDevice* device = skia::GetTopDevice(*canvas); | 531 SkBaseDevice* device = skia::GetTopDevice(*canvas); |
527 const SkBitmap& bitmap = device->accessBitmap(false); | 532 const SkBitmap& bitmap = device->accessBitmap(false); |
528 callback.Run(bitmap); | 533 callback.Run(bitmap); |
529 } | 534 } |
530 | 535 |
531 void WebTestProxyBase::CapturePixelsAsync( | 536 void WebTestProxyBase::CapturePixelsAsync( |
532 const base::Callback<void(const SkBitmap&)>& callback) { | 537 const base::Callback<void(const SkBitmap&)>& callback) { |
533 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); | 538 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); |
534 | 539 |
540 // It may happen that there is a scheduled animation and | |
541 // no rootGraphicsLayer yet. If so we would run it right now. Otherwise | |
542 // isAcceleratedCompositingActive will return false; | |
543 AnimateNow(); | |
544 | |
535 DCHECK(web_widget_->isAcceleratedCompositingActive()); | 545 DCHECK(web_widget_->isAcceleratedCompositingActive()); |
536 DCHECK(!callback.is_null()); | 546 DCHECK(!callback.is_null()); |
537 | 547 |
538 if (test_interfaces_->GetTestRunner()->isPrinting()) { | 548 if (test_interfaces_->GetTestRunner()->isPrinting()) { |
539 base::MessageLoopProxy::current()->PostTask( | 549 base::MessageLoopProxy::current()->PostTask( |
540 FROM_HERE, | 550 FROM_HERE, |
541 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, | 551 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, |
542 base::Unretained(this), | 552 base::Unretained(this), |
543 callback)); | 553 callback)); |
544 return; | 554 return; |
(...skipping 12 matching lines...) Expand all Loading... | |
557 // Verify we actually composited. | 567 // Verify we actually composited. |
558 CHECK_NE(0, bitmap.info().fWidth); | 568 CHECK_NE(0, bitmap.info().fWidth); |
559 CHECK_NE(0, bitmap.info().fHeight); | 569 CHECK_NE(0, bitmap.info().fHeight); |
560 if (!callback.is_null()) | 570 if (!callback.is_null()) |
561 callback.Run(); | 571 callback.Run(); |
562 } | 572 } |
563 | 573 |
564 void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) { | 574 void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) { |
565 TRACE_EVENT0("shell", "WebTestProxyBase::DisplayAsyncThen"); | 575 TRACE_EVENT0("shell", "WebTestProxyBase::DisplayAsyncThen"); |
566 | 576 |
577 // It may happen that there is a scheduled animation and | |
578 // no rootGraphicsLayer yet. If so we would run it right now. Otherwise | |
579 // isAcceleratedCompositingActive will return false; | |
580 AnimateNow(); | |
581 | |
567 CHECK(web_widget_->isAcceleratedCompositingActive()); | 582 CHECK(web_widget_->isAcceleratedCompositingActive()); |
568 CapturePixelsAsync(base::Bind( | 583 CapturePixelsAsync(base::Bind( |
569 &WebTestProxyBase::DidDisplayAsync, base::Unretained(this), callback)); | 584 &WebTestProxyBase::DidDisplayAsync, base::Unretained(this), callback)); |
570 } | 585 } |
571 | 586 |
572 void WebTestProxyBase::GetScreenOrientationForTesting( | 587 void WebTestProxyBase::GetScreenOrientationForTesting( |
573 blink::WebScreenInfo& screen_info) { | 588 blink::WebScreenInfo& screen_info) { |
574 if (!screen_orientation_client_) | 589 if (!screen_orientation_client_) |
575 return; | 590 return; |
576 // Override screen orientation information with mock data. | 591 // Override screen orientation information with mock data. |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1288 if (!push_client_.get()) | 1303 if (!push_client_.get()) |
1289 push_client_.reset(new MockWebPushClient); | 1304 push_client_.reset(new MockWebPushClient); |
1290 return push_client_.get(); | 1305 return push_client_.get(); |
1291 } | 1306 } |
1292 | 1307 |
1293 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { | 1308 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { |
1294 return GetPushClientMock(); | 1309 return GetPushClientMock(); |
1295 } | 1310 } |
1296 | 1311 |
1297 } // namespace content | 1312 } // namespace content |
OLD | NEW |