| 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 778 |
| 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 |
| 789 // transparent background. |
| 790 IN_PROC_BROWSER_TEST_F(CaptureScreenshotTest, TransparentScreenshots) { |
| 791 if (base::SysInfo::IsLowEndDevice()) |
| 792 return; |
| 793 |
| 794 shell()->LoadURL( |
| 795 GURL("data:text/html,<body style='background:transparent'></body>")); |
| 796 WaitForLoadStop(shell()->web_contents()); |
| 797 Attach(); |
| 798 |
| 799 // Override background to transparent. |
| 800 std::unique_ptr<base::DictionaryValue> color(new base::DictionaryValue()); |
| 801 color->SetInteger("r", 0); |
| 802 color->SetInteger("g", 0); |
| 803 color->SetInteger("b", 0); |
| 804 color->SetDouble("a", 0); |
| 805 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 806 params->Set("color", std::move(color)); |
| 807 SendCommand("Emulation.setDefaultBackgroundColorOverride", std::move(params)); |
| 808 |
| 809 SkBitmap expected_bitmap; |
| 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 |
| 812 // integer precision. |
| 813 gfx::Size view_size = static_cast<RenderWidgetHostViewBase*>( |
| 814 shell()->web_contents()->GetRenderWidgetHostView()) |
| 815 ->GetPhysicalBackingSize(); |
| 816 expected_bitmap.allocN32Pixels(view_size.width(), view_size.height()); |
| 817 expected_bitmap.eraseColor(SK_ColorTRANSPARENT); |
| 818 CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true); |
| 819 } |
| 820 |
| 788 #if defined(OS_ANDROID) | 821 #if defined(OS_ANDROID) |
| 789 // Disabled, see http://crbug.com/469947. | 822 // Disabled, see http://crbug.com/469947. |
| 790 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) { | 823 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) { |
| 791 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html"); | 824 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html"); |
| 792 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 825 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 793 Attach(); | 826 Attach(); |
| 794 | 827 |
| 795 int old_width; | 828 int old_width; |
| 796 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 829 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 797 shell(), "domAutomationController.send(window.innerWidth)", &old_width)); | 830 shell(), "domAutomationController.send(window.innerWidth)", &old_width)); |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 EXPECT_EQ("polyglottal", value); | 1797 EXPECT_EQ("polyglottal", value); |
| 1765 found++; | 1798 found++; |
| 1766 } else { | 1799 } else { |
| 1767 FAIL(); | 1800 FAIL(); |
| 1768 } | 1801 } |
| 1769 } | 1802 } |
| 1770 EXPECT_EQ(2u, found); | 1803 EXPECT_EQ(2u, found); |
| 1771 } | 1804 } |
| 1772 | 1805 |
| 1773 } // namespace content | 1806 } // namespace content |
| OLD | NEW |