Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 462173002: Fix set_area sizes for RequestCopyOfOutput, and related tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed RWHVBrowserTests, fixed snapshot_android, clarifying header comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/browser/gpu/compositor_util.h" 9 #include "content/browser/gpu/compositor_util.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 const SkBitmap& expected_bitmap = 429 const SkBitmap& expected_bitmap =
430 expected_copy_from_compositing_surface_bitmap_; 430 expected_copy_from_compositing_surface_bitmap_;
431 EXPECT_EQ(expected_bitmap.width(), bitmap.width()); 431 EXPECT_EQ(expected_bitmap.width(), bitmap.width());
432 EXPECT_EQ(expected_bitmap.height(), bitmap.height()); 432 EXPECT_EQ(expected_bitmap.height(), bitmap.height());
433 EXPECT_EQ(expected_bitmap.colorType(), bitmap.colorType()); 433 EXPECT_EQ(expected_bitmap.colorType(), bitmap.colorType());
434 SkAutoLockPixels expected_bitmap_lock(expected_bitmap); 434 SkAutoLockPixels expected_bitmap_lock(expected_bitmap);
435 SkAutoLockPixels bitmap_lock(bitmap); 435 SkAutoLockPixels bitmap_lock(bitmap);
436 int fails = 0; 436 int fails = 0;
437 for (int i = 0; i < bitmap.width() && fails < 10; ++i) { 437 for (int i = 0; i < bitmap.width() && fails < 10; ++i) {
438 // Exclude the middle 3 columns of pixels from testing since scaling could
sky 2014/08/13 22:49:28 Do we really run tests at different scales? If so,
miu 2014/08/14 00:18:33 Removed. Just checked this again, and it looks li
439 // cause these pixels to be a mix of the two colors.
440 if (i >= (bitmap.width() / 2 - 1) && i <= (bitmap.width() / 2 + 1))
441 continue;
442
438 for (int j = 0; j < bitmap.height() && fails < 10; ++j) { 443 for (int j = 0; j < bitmap.height() && fails < 10; ++j) {
439 if (!exclude_rect_.IsEmpty() && exclude_rect_.Contains(i, j)) 444 if (!exclude_rect_.IsEmpty() && exclude_rect_.Contains(i, j))
440 continue; 445 continue;
441 446
442 SkColor expected_color = expected_bitmap.getColor(i, j); 447 SkColor expected_color = expected_bitmap.getColor(i, j);
443 SkColor color = bitmap.getColor(i, j); 448 SkColor color = bitmap.getColor(i, j);
444 int expected_alpha = SkColorGetA(expected_color); 449 int expected_alpha = SkColorGetA(expected_color);
445 int alpha = SkColorGetA(color); 450 int alpha = SkColorGetA(color);
446 int expected_red = SkColorGetR(expected_color); 451 int expected_red = SkColorGetR(expected_color);
447 int red = SkColorGetR(color); 452 int red = SkColorGetR(color);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 521
517 virtual GURL TestUrl() OVERRIDE { 522 virtual GURL TestUrl() OVERRIDE {
518 return GURL(test_url_); 523 return GURL(test_url_);
519 } 524 }
520 525
521 void SetTestUrl(std::string url) { test_url_ = url; } 526 void SetTestUrl(std::string url) { test_url_ = url; }
522 527
523 // Loads a page two boxes side-by-side, each half the width of 528 // Loads a page two boxes side-by-side, each half the width of
524 // |html_rect_size|, and with different background colors. The test then 529 // |html_rect_size|, and with different background colors. The test then
525 // copies from |copy_rect| region of the page into a bitmap of size 530 // copies from |copy_rect| region of the page into a bitmap of size
526 // |output_size|, and compares that with a bitmap of size 531 // |output_size|, and examines the resulting bitmap/VideoFrame.
527 // |expected_bitmap_size|.
528 // Note that |output_size| may not have the same size as |copy_rect| (e.g. 532 // Note that |output_size| may not have the same size as |copy_rect| (e.g.
529 // when the output is scaled). Also note that |expected_bitmap_size| may not 533 // when the output is scaled).
530 // be the same as |output_size| (e.g. when the device scale factor is not 1).
531 void PerformTestWithLeftRightRects(const gfx::Size& html_rect_size, 534 void PerformTestWithLeftRightRects(const gfx::Size& html_rect_size,
532 const gfx::Rect& copy_rect, 535 const gfx::Rect& copy_rect,
533 const gfx::Size& output_size, 536 const gfx::Size& output_size,
534 const gfx::Size& expected_bitmap_size,
535 bool video_frame) { 537 bool video_frame) {
536 const gfx::Size box_size(html_rect_size.width() / 2, 538 const gfx::Size box_size(html_rect_size.width() / 2,
537 html_rect_size.height()); 539 html_rect_size.height());
538 SetTestUrl(base::StringPrintf( 540 SetTestUrl(base::StringPrintf(
539 "data:text/html,<!doctype html>" 541 "data:text/html,<!doctype html>"
540 "<div class='left'>" 542 "<div class='left'>"
541 " <div class='right'></div>" 543 " <div class='right'></div>"
542 "</div>" 544 "</div>"
543 "<style>" 545 "<style>"
544 "body { padding: 0; margin: 0; }" 546 "body { padding: 0; margin: 0; }"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 587 }
586 588
587 // The page is loaded in the renderer, wait for a new frame to arrive. 589 // The page is loaded in the renderer, wait for a new frame to arrive.
588 uint32 frame = rwhvp->RendererFrameNumber(); 590 uint32 frame = rwhvp->RendererFrameNumber();
589 while (!GetRenderWidgetHost()->ScheduleComposite()) 591 while (!GetRenderWidgetHost()->ScheduleComposite())
590 GiveItSomeTime(); 592 GiveItSomeTime();
591 while (rwhvp->RendererFrameNumber() == frame) 593 while (rwhvp->RendererFrameNumber() == frame)
592 GiveItSomeTime(); 594 GiveItSomeTime();
593 595
594 SkBitmap expected_bitmap; 596 SkBitmap expected_bitmap;
595 SetupLeftRightBitmap(expected_bitmap_size, &expected_bitmap); 597 SetupLeftRightBitmap(output_size, &expected_bitmap);
596 SetExpectedCopyFromCompositingSurfaceResult(true, expected_bitmap); 598 SetExpectedCopyFromCompositingSurfaceResult(true, expected_bitmap);
597 599
598 base::RunLoop run_loop; 600 base::RunLoop run_loop;
599 if (video_frame) { 601 if (video_frame) {
600 // Allow pixel differences as long as we have the right idea. 602 // Allow pixel differences as long as we have the right idea.
601 SetAllowableError(0x10); 603 SetAllowableError(0x10);
602 // Exclude the middle two columns which are blended between the two sides. 604 // Exclude the middle two columns which are blended between the two sides.
603 SetExcludeRect( 605 SetExcludeRect(
604 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height())); 606 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height()));
605 607
606 scoped_refptr<media::VideoFrame> video_frame = 608 scoped_refptr<media::VideoFrame> video_frame =
607 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, 609 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
608 expected_bitmap_size, 610 output_size,
609 gfx::Rect(expected_bitmap_size), 611 gfx::Rect(output_size),
610 expected_bitmap_size, 612 output_size,
611 base::TimeDelta()); 613 base::TimeDelta());
612 614
613 base::Callback<void(bool success)> callback = 615 base::Callback<void(bool success)> callback =
614 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: 616 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture::
615 CopyFromCompositingSurfaceCallbackForVideo, 617 CopyFromCompositingSurfaceCallbackForVideo,
616 base::Unretained(this), 618 base::Unretained(this),
617 video_frame, 619 video_frame,
618 run_loop.QuitClosure()); 620 run_loop.QuitClosure());
619 rwhvp->CopyFromCompositingSurfaceToVideoFrame(copy_rect, 621 rwhvp->CopyFromCompositingSurfaceToVideoFrame(copy_rect,
620 video_frame, 622 video_frame,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 SkBitmap expected_copy_from_compositing_surface_bitmap_; 674 SkBitmap expected_copy_from_compositing_surface_bitmap_;
673 int allowable_error_; 675 int allowable_error_;
674 gfx::Rect exclude_rect_; 676 gfx::Rect exclude_rect_;
675 std::string test_url_; 677 std::string test_url_;
676 }; 678 };
677 679
678 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 680 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
679 CopyFromCompositingSurface_Origin_Unscaled) { 681 CopyFromCompositingSurface_Origin_Unscaled) {
680 gfx::Rect copy_rect(400, 300); 682 gfx::Rect copy_rect(400, 300);
681 gfx::Size output_size = copy_rect.size(); 683 gfx::Size output_size = copy_rect.size();
682 gfx::Size expected_bitmap_size = output_size;
683 gfx::Size html_rect_size(400, 300); 684 gfx::Size html_rect_size(400, 300);
684 bool video_frame = false; 685 bool video_frame = false;
685 PerformTestWithLeftRightRects(html_rect_size, 686 PerformTestWithLeftRightRects(html_rect_size,
686 copy_rect, 687 copy_rect,
687 output_size, 688 output_size,
688 expected_bitmap_size,
689 video_frame); 689 video_frame);
690 } 690 }
691 691
692 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 692 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
693 CopyFromCompositingSurface_Origin_Scaled) { 693 CopyFromCompositingSurface_Origin_Scaled) {
694 gfx::Rect copy_rect(400, 300); 694 gfx::Rect copy_rect(400, 300);
695 gfx::Size output_size(200, 100); 695 gfx::Size output_size(200, 100);
696 gfx::Size expected_bitmap_size = output_size;
697 gfx::Size html_rect_size(400, 300); 696 gfx::Size html_rect_size(400, 300);
698 bool video_frame = false; 697 bool video_frame = false;
699 PerformTestWithLeftRightRects(html_rect_size, 698 PerformTestWithLeftRightRects(html_rect_size,
700 copy_rect, 699 copy_rect,
701 output_size, 700 output_size,
702 expected_bitmap_size,
703 video_frame); 701 video_frame);
704 } 702 }
705 703
706 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 704 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
707 CopyFromCompositingSurface_Cropped_Unscaled) { 705 CopyFromCompositingSurface_Cropped_Unscaled) {
708 // Grab 60x60 pixels from the center of the tab contents. 706 // Grab 60x60 pixels from the center of the tab contents.
709 gfx::Rect copy_rect(400, 300); 707 gfx::Rect copy_rect(400, 300);
710 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), 708 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30),
711 gfx::Size(60, 60)); 709 gfx::Size(60, 60));
712 gfx::Size output_size = copy_rect.size(); 710 gfx::Size output_size = copy_rect.size();
713 gfx::Size expected_bitmap_size = output_size;
714 gfx::Size html_rect_size(400, 300); 711 gfx::Size html_rect_size(400, 300);
715 bool video_frame = false; 712 bool video_frame = false;
716 PerformTestWithLeftRightRects(html_rect_size, 713 PerformTestWithLeftRightRects(html_rect_size,
717 copy_rect, 714 copy_rect,
718 output_size, 715 output_size,
719 expected_bitmap_size,
720 video_frame); 716 video_frame);
721 } 717 }
722 718
723 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 719 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
724 CopyFromCompositingSurface_Cropped_Scaled) { 720 CopyFromCompositingSurface_Cropped_Scaled) {
725 // Grab 60x60 pixels from the center of the tab contents. 721 // Grab 60x60 pixels from the center of the tab contents.
726 gfx::Rect copy_rect(400, 300); 722 gfx::Rect copy_rect(400, 300);
727 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), 723 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30),
728 gfx::Size(60, 60)); 724 gfx::Size(60, 60));
729 gfx::Size output_size(20, 10); 725 gfx::Size output_size(20, 10);
730 gfx::Size expected_bitmap_size = output_size;
731 gfx::Size html_rect_size(400, 300); 726 gfx::Size html_rect_size(400, 300);
732 bool video_frame = false; 727 bool video_frame = false;
733 PerformTestWithLeftRightRects(html_rect_size, 728 PerformTestWithLeftRightRects(html_rect_size,
734 copy_rect, 729 copy_rect,
735 output_size, 730 output_size,
736 expected_bitmap_size,
737 video_frame); 731 video_frame);
738 } 732 }
739 733
740 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 734 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
741 CopyFromCompositingSurface_ForVideoFrame) { 735 CopyFromCompositingSurface_ForVideoFrame) {
742 // Grab 90x60 pixels from the center of the tab contents. 736 // Grab 90x60 pixels from the center of the tab contents.
743 gfx::Rect copy_rect(400, 300); 737 gfx::Rect copy_rect(400, 300);
744 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), 738 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30),
745 gfx::Size(90, 60)); 739 gfx::Size(90, 60));
746 gfx::Size output_size = copy_rect.size(); 740 gfx::Size output_size = copy_rect.size();
747 gfx::Size expected_bitmap_size = output_size;
748 gfx::Size html_rect_size(400, 300); 741 gfx::Size html_rect_size(400, 300);
749 bool video_frame = true; 742 bool video_frame = true;
750 PerformTestWithLeftRightRects(html_rect_size, 743 PerformTestWithLeftRightRects(html_rect_size,
751 copy_rect, 744 copy_rect,
752 output_size, 745 output_size,
753 expected_bitmap_size,
754 video_frame); 746 video_frame);
755 } 747 }
756 748
757 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, 749 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture,
758 CopyFromCompositingSurface_ForVideoFrame_Scaled) { 750 CopyFromCompositingSurface_ForVideoFrame_Scaled) {
759 // Grab 90x60 pixels from the center of the tab contents. 751 // Grab 90x60 pixels from the center of the tab contents.
760 gfx::Rect copy_rect(400, 300); 752 gfx::Rect copy_rect(400, 300);
761 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), 753 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30),
762 gfx::Size(90, 60)); 754 gfx::Size(90, 60));
763 // Scale to 30 x 20 (preserve aspect ratio). 755 // Scale to 30 x 20 (preserve aspect ratio).
764 gfx::Size output_size(30, 20); 756 gfx::Size output_size(30, 20);
765 gfx::Size expected_bitmap_size = output_size;
766 gfx::Size html_rect_size(400, 300); 757 gfx::Size html_rect_size(400, 300);
767 bool video_frame = true; 758 bool video_frame = true;
768 PerformTestWithLeftRightRects(html_rect_size, 759 PerformTestWithLeftRightRects(html_rect_size,
769 copy_rect, 760 copy_rect,
770 output_size, 761 output_size,
771 expected_bitmap_size,
772 video_frame); 762 video_frame);
773 } 763 }
774 764
775 class CompositingRenderWidgetHostViewTabCaptureHighDPI 765 class CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI
776 : public CompositingRenderWidgetHostViewBrowserTestTabCapture { 766 : public CompositingRenderWidgetHostViewBrowserTestTabCapture {
777 public: 767 public:
778 CompositingRenderWidgetHostViewTabCaptureHighDPI() : kScale(2.f) {} 768 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI() {}
danakj 2014/08/13 14:31:30 can remove this
miu 2014/08/13 18:11:10 Tried that, and clang says: ../../content/browser
danakj 2014/08/13 18:39:31 Oh because of the DISALLOW_COPY_AND_ASSIGN I guess
779 769
780 virtual void SetUpOnMainThread() OVERRIDE { 770 virtual void SetUpCommandLine(base::CommandLine* cmd) OVERRIDE {
781 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 771 CompositingRenderWidgetHostViewBrowserTestTabCapture::SetUpCommandLine(cmd);
782 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor, 772 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
783 base::StringPrintf("%f", scale())); 773 base::StringPrintf("%f", scale()));
784 #if defined(OS_WIN)
785 gfx::ForceHighDPISupportForTesting(scale());
786 gfx::EnableHighDPISupport();
787 #endif
788 } 774 }
789 775
790 float scale() const { return kScale; }
791
792 private: 776 private:
793 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { 777 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE {
794 // Short-circuit a pass for platforms where setting up high-DPI fails. 778 // Short-circuit a pass for platforms where setting up high-DPI fails.
danakj 2014/08/13 14:31:31 Do these platforms still exist? Can you try removi
miu 2014/08/13 18:11:10 Done. Cross your fingers! ;-)
miu 2014/08/13 22:25:45 The bots did not like this, so I put it back.
795 if (ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor( 779 const float actual_scale_factor =
796 GetScaleFactorForView(GetRenderWidgetHostView()))) != scale()) { 780 GetScaleFactorForView(GetRenderWidgetHostView());
797 LOG(WARNING) << "Blindly passing this test: failed to set up " 781 if (actual_scale_factor != scale()) {
798 "scale factor: " << scale(); 782 LOG(WARNING) << "Blindly passing this test; failed to set up "
783 "scale factor: was " << actual_scale_factor
784 << ", expected " << scale();
799 return false; 785 return false;
800 } 786 }
801 return true; 787 return true;
802 } 788 }
803 789
804 const float kScale; 790 static float scale() { return 2.0f; }
805 791
806 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI); 792 DISALLOW_COPY_AND_ASSIGN(
793 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI);
807 }; 794 };
808 795
809 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, 796 IN_PROC_BROWSER_TEST_P(
810 CopyFromCompositingSurface) { 797 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
798 CopyFromCompositingSurfaceToBitmap_EntireRegion) {
799 gfx::Size html_rect_size(200, 150);
811 gfx::Rect copy_rect(200, 150); 800 gfx::Rect copy_rect(200, 150);
812 gfx::Size output_size = copy_rect.size(); 801 gfx::Size output_size = copy_rect.size();
813 gfx::Size expected_bitmap_size =
814 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale()));
815 gfx::Size html_rect_size(200, 150);
816 bool video_frame = false; 802 bool video_frame = false;
817 PerformTestWithLeftRightRects(html_rect_size, 803 PerformTestWithLeftRightRects(html_rect_size,
818 copy_rect, 804 copy_rect,
819 output_size, 805 output_size,
820 expected_bitmap_size,
821 video_frame); 806 video_frame);
822 } 807 }
823 808
824 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, 809 IN_PROC_BROWSER_TEST_P(
825 CopyFromCompositingSurfaceVideoFrame) { 810 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
811 CopyFromCompositingSurfaceToBitmap_CenterRegion) {
826 gfx::Size html_rect_size(200, 150); 812 gfx::Size html_rect_size(200, 150);
827 // Grab 90x60 pixels from the center of the tab contents. 813 // Grab 90x60 pixels from the center of the tab contents.
828 gfx::Rect copy_rect = 814 gfx::Rect copy_rect =
829 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), 815 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30),
830 gfx::Size(90, 60)); 816 gfx::Size(90, 60));
831 gfx::Size output_size = copy_rect.size(); 817 gfx::Size output_size = copy_rect.size();
832 gfx::Size expected_bitmap_size = 818 bool video_frame = false;
833 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); 819 PerformTestWithLeftRightRects(html_rect_size,
820 copy_rect,
821 output_size,
822 video_frame);
823 }
824
825 IN_PROC_BROWSER_TEST_P(
826 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
827 CopyFromCompositingSurfaceToBitmap_ScaledResult) {
828 gfx::Size html_rect_size(200, 100);
829 gfx::Rect copy_rect(200, 100);
830 gfx::Size output_size(100, 50);
831 bool video_frame = false;
832 PerformTestWithLeftRightRects(html_rect_size,
833 copy_rect,
834 output_size,
835 video_frame);
836 }
837
838 IN_PROC_BROWSER_TEST_P(
839 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
840 CopyFromCompositingSurfaceToVideoFrame_EntireRegion) {
841 gfx::Size html_rect_size(200, 150);
842 gfx::Rect copy_rect(200, 150);
843 gfx::Size output_size = copy_rect.size();
834 bool video_frame = true; 844 bool video_frame = true;
835 PerformTestWithLeftRightRects(html_rect_size, 845 PerformTestWithLeftRightRects(html_rect_size,
836 copy_rect, 846 copy_rect,
837 output_size, 847 output_size,
838 expected_bitmap_size,
839 video_frame); 848 video_frame);
840 } 849 }
841 850
842 #if !defined(USE_AURA) && !defined(OS_MACOSX) 851 IN_PROC_BROWSER_TEST_P(
843 // TODO(danakj): Remove this case when GTK linux is no more and move the 852 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
844 // values inline to testing::Values() below. 853 CopyFromCompositingSurfaceToVideoFrame_CenterRegion) {
845 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING}; 854 gfx::Size html_rect_size(200, 150);
846 #else 855 // Grab 90x60 pixels from the center of the tab contents.
847 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING, 856 gfx::Rect copy_rect =
848 SOFTWARE_COMPOSITING}; 857 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30),
849 #endif 858 gfx::Size(90, 60));
859 gfx::Size output_size = copy_rect.size();
danakj 2014/08/13 14:31:30 if you want something not scaled down, shouldn't t
miu 2014/08/13 18:11:10 Done. Good point.
860 bool video_frame = true;
861 PerformTestWithLeftRightRects(html_rect_size,
862 copy_rect,
863 output_size,
864 video_frame);
865 }
866
867 IN_PROC_BROWSER_TEST_P(
868 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
869 CopyFromCompositingSurfaceToVideoFrame_ScaledResult) {
870 gfx::Size html_rect_size(200, 100);
871 gfx::Rect copy_rect(200, 100);
872 gfx::Size output_size(100, 50);
873 bool video_frame = true;
874 PerformTestWithLeftRightRects(html_rect_size,
875 copy_rect,
876 output_size,
877 video_frame);
878 }
850 879
851 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, 880 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing,
852 CompositingRenderWidgetHostViewBrowserTest, 881 CompositingRenderWidgetHostViewBrowserTest,
853 testing::ValuesIn(kAllCompositingModes)); 882 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING));
854 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, 883 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing,
855 CompositingRenderWidgetHostViewBrowserTestTabCapture, 884 CompositingRenderWidgetHostViewBrowserTestTabCapture,
856 testing::ValuesIn(kAllCompositingModes)); 885 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING));
857 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, 886 INSTANTIATE_TEST_CASE_P(
858 CompositingRenderWidgetHostViewTabCaptureHighDPI, 887 GLAndSoftwareCompositing,
859 testing::ValuesIn(kAllCompositingModes)); 888 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
889 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING));
860 890
861 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 891 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
862 892
863 } // namespace 893 } // namespace
864 } // namespace content 894 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_base.h ('k') | ui/base/android/window_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698