| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 // Test capturing a subarea inside the emulated frame at different scales. | 779 // Test capturing a subarea inside the emulated frame at different scales. |
| 780 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 1.0); | 780 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 1.0); |
| 781 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 2.0); | 781 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 2.0); |
| 782 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 0.5); | 782 PlaceAndCaptureBox(kFrameSize, gfx::Size(100, 200), 0.5); |
| 783 | 783 |
| 784 // Ensure that content outside the emulated frame is painted, too. | 784 // Ensure that content outside the emulated frame is painted, too. |
| 785 PlaceAndCaptureBox(kFrameSize, gfx::Size(10, 10000), 1.0); | 785 PlaceAndCaptureBox(kFrameSize, gfx::Size(10, 10000), 1.0); |
| 786 } | 786 } |
| 787 | 787 |
| 788 // Verifies that setDefaultBackgroundColor and captureScreenshot support a | 788 // Verifies that setDefaultBackgroundColor and captureScreenshot support a |
| 789 // transparent background. | 789 // transparent background, and that setDeviceMetricsOverride doesn't affect it. |
| 790 IN_PROC_BROWSER_TEST_F(CaptureScreenshotTest, TransparentScreenshots) { | 790 IN_PROC_BROWSER_TEST_F(CaptureScreenshotTest, TransparentScreenshots) { |
| 791 if (base::SysInfo::IsLowEndDevice()) | 791 if (base::SysInfo::IsLowEndDevice()) |
| 792 return; | 792 return; |
| 793 | 793 |
| 794 shell()->LoadURL( | 794 shell()->LoadURL( |
| 795 GURL("data:text/html,<body style='background:transparent'></body>")); | 795 GURL("data:text/html,<body style='background:transparent'></body>")); |
| 796 WaitForLoadStop(shell()->web_contents()); | 796 WaitForLoadStop(shell()->web_contents()); |
| 797 Attach(); | 797 Attach(); |
| 798 | 798 |
| 799 // Override background to transparent. | 799 // Override background to transparent. |
| 800 std::unique_ptr<base::DictionaryValue> color(new base::DictionaryValue()); | 800 std::unique_ptr<base::DictionaryValue> color(new base::DictionaryValue()); |
| 801 color->SetInteger("r", 0); | 801 color->SetInteger("r", 0); |
| 802 color->SetInteger("g", 0); | 802 color->SetInteger("g", 0); |
| 803 color->SetInteger("b", 0); | 803 color->SetInteger("b", 0); |
| 804 color->SetDouble("a", 0); | 804 color->SetDouble("a", 0); |
| 805 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 805 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 806 params->Set("color", std::move(color)); | 806 params->Set("color", std::move(color)); |
| 807 SendCommand("Emulation.setDefaultBackgroundColorOverride", std::move(params)); | 807 SendCommand("Emulation.setDefaultBackgroundColorOverride", std::move(params)); |
| 808 | 808 |
| 809 SkBitmap expected_bitmap; | 809 SkBitmap expected_bitmap; |
| 810 // We compare against the actual physical backing size rather than the | 810 // We compare against the actual physical backing size rather than the |
| 811 // view size, because the view size is stored adjusted for DPI and only in | 811 // view size, because the view size is stored adjusted for DPI and only in |
| 812 // integer precision. | 812 // integer precision. |
| 813 gfx::Size view_size = static_cast<RenderWidgetHostViewBase*>( | 813 gfx::Size view_size = static_cast<RenderWidgetHostViewBase*>( |
| 814 shell()->web_contents()->GetRenderWidgetHostView()) | 814 shell()->web_contents()->GetRenderWidgetHostView()) |
| 815 ->GetPhysicalBackingSize(); | 815 ->GetPhysicalBackingSize(); |
| 816 expected_bitmap.allocN32Pixels(view_size.width(), view_size.height()); | 816 expected_bitmap.allocN32Pixels(view_size.width(), view_size.height()); |
| 817 expected_bitmap.eraseColor(SK_ColorTRANSPARENT); | 817 expected_bitmap.eraseColor(SK_ColorTRANSPARENT); |
| 818 CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true); | 818 CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true); |
| 819 |
| 820 // Check that device emulation does not affect the transparency. |
| 821 params.reset(new base::DictionaryValue()); |
| 822 params->SetInteger("width", view_size.width()); |
| 823 params->SetInteger("height", view_size.height()); |
| 824 params->SetDouble("deviceScaleFactor", 0); |
| 825 params->SetBoolean("mobile", false); |
| 826 params->SetBoolean("fitWindow", false); |
| 827 params->SetBoolean("overrideGutterColor", false); |
| 828 SendCommand("Emulation.setDeviceMetricsOverride", std::move(params)); |
| 829 CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true); |
| 819 } | 830 } |
| 820 | 831 |
| 821 #if defined(OS_ANDROID) | 832 #if defined(OS_ANDROID) |
| 822 // Disabled, see http://crbug.com/469947. | 833 // Disabled, see http://crbug.com/469947. |
| 823 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) { | 834 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) { |
| 824 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html"); | 835 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html"); |
| 825 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 836 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 826 Attach(); | 837 Attach(); |
| 827 | 838 |
| 828 int old_width; | 839 int old_width; |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 EXPECT_EQ("polyglottal", value); | 1808 EXPECT_EQ("polyglottal", value); |
| 1798 found++; | 1809 found++; |
| 1799 } else { | 1810 } else { |
| 1800 FAIL(); | 1811 FAIL(); |
| 1801 } | 1812 } |
| 1802 } | 1813 } |
| 1803 EXPECT_EQ(2u, found); | 1814 EXPECT_EQ(2u, found); |
| 1804 } | 1815 } |
| 1805 | 1816 |
| 1806 } // namespace content | 1817 } // namespace content |
| OLD | NEW |