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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2808123004: [devtools] Remove device emulation background color override. (Closed)
Patch Set: fix android tests Created 3 years, 8 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
OLDNEW
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
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 SendCommand("Emulation.setDeviceMetricsOverride", std::move(params));
828 CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true);
819 } 829 }
820 830
821 #if defined(OS_ANDROID) 831 #if defined(OS_ANDROID)
822 // Disabled, see http://crbug.com/469947. 832 // Disabled, see http://crbug.com/469947.
823 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) { 833 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) {
824 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html"); 834 GURL test_url = GetTestUrl("devtools", "synthetic_gesture_tests.html");
825 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); 835 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1);
826 Attach(); 836 Attach();
827 837
828 int old_width; 838 int old_width;
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 EXPECT_EQ("polyglottal", value); 1803 EXPECT_EQ("polyglottal", value);
1794 found++; 1804 found++;
1795 } else { 1805 } else {
1796 FAIL(); 1806 FAIL();
1797 } 1807 }
1798 } 1808 }
1799 EXPECT_EQ(2u, found); 1809 EXPECT_EQ(2u, found);
1800 } 1810 }
1801 1811
1802 } // namespace content 1812 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698