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

Unified Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2811593007: [devtools] Add test for transparent background color override. (Closed)
Patch Set: fix comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
index af97bb3c75e00d064005508201d3274fb4279ac7..5173237a7d787c9818869c7d8e57ca444a6adfdc 100644
--- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
+++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -785,6 +785,39 @@ IN_PROC_BROWSER_TEST_F(CaptureScreenshotTest,
PlaceAndCaptureBox(kFrameSize, gfx::Size(10, 10000), 1.0);
}
+// Verifies that setDefaultBackgroundColor and captureScreenshot support a
+// transparent background.
+IN_PROC_BROWSER_TEST_F(CaptureScreenshotTest, TransparentScreenshots) {
+ if (base::SysInfo::IsLowEndDevice())
+ return;
+
+ shell()->LoadURL(
+ GURL("data:text/html,<body style='background:transparent'></body>"));
+ WaitForLoadStop(shell()->web_contents());
+ Attach();
+
+ // Override background to transparent.
+ std::unique_ptr<base::DictionaryValue> color(new base::DictionaryValue());
+ color->SetInteger("r", 0);
+ color->SetInteger("g", 0);
+ color->SetInteger("b", 0);
+ color->SetDouble("a", 0);
+ std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
+ params->Set("color", std::move(color));
+ SendCommand("Emulation.setDefaultBackgroundColorOverride", std::move(params));
+
+ SkBitmap expected_bitmap;
+ // We compare against the actual physical backing size rather than the
+ // view size, because the view size is stored adjusted for DPI and only in
+ // integer precision.
+ gfx::Size view_size = static_cast<RenderWidgetHostViewBase*>(
+ shell()->web_contents()->GetRenderWidgetHostView())
+ ->GetPhysicalBackingSize();
+ expected_bitmap.allocN32Pixels(view_size.width(), view_size.height());
+ expected_bitmap.eraseColor(SK_ColorTRANSPARENT);
+ CaptureScreenshotAndCompareTo(expected_bitmap, ENCODING_PNG, true);
+}
+
#if defined(OS_ANDROID)
// Disabled, see http://crbug.com/469947.
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DISABLED_SynthesizePinchGesture) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698