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

Side by Side Diff: headless/lib/headless_web_contents_browsertest.cc

Issue 2732923002: Add fromSurface optional parameter to devtools Page.CaptureScreenshot (Closed)
Patch Set: nits Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "content/public/test/browser_test.h" 10 #include "content/public/test/browser_test.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 .SetExpression("document.body.style.background = '#0000ff'") 129 .SetExpression("document.body.style.background = '#0000ff'")
130 .Build(); 130 .Build();
131 devtools_client_->GetRuntime()->Evaluate( 131 devtools_client_->GetRuntime()->Evaluate(
132 std::move(params), 132 std::move(params),
133 base::Bind(&HeadlessWebContentsScreenshotTest::OnPageSetupCompleted, 133 base::Bind(&HeadlessWebContentsScreenshotTest::OnPageSetupCompleted,
134 base::Unretained(this))); 134 base::Unretained(this)));
135 } 135 }
136 136
137 void OnPageSetupCompleted(std::unique_ptr<runtime::EvaluateResult> result) { 137 void OnPageSetupCompleted(std::unique_ptr<runtime::EvaluateResult> result) {
138 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( 138 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot(
139 page::CaptureScreenshotParams::Builder().Build(), 139 page::CaptureScreenshotParams::Builder().SetFromSurface(true).Build(),
140 base::Bind(&HeadlessWebContentsScreenshotTest::OnScreenshotCaptured, 140 base::Bind(&HeadlessWebContentsScreenshotTest::OnScreenshotCaptured,
141 base::Unretained(this))); 141 base::Unretained(this)));
142 } 142 }
143 143
144 void OnScreenshotCaptured( 144 void OnScreenshotCaptured(
145 std::unique_ptr<page::CaptureScreenshotResult> result) { 145 std::unique_ptr<page::CaptureScreenshotResult> result) {
146 std::string base64 = result->GetData(); 146 std::string base64 = result->GetData();
147 EXPECT_LT(0U, base64.length()); 147 EXPECT_LT(0U, base64.length());
148 SkBitmap result_bitmap; 148 SkBitmap result_bitmap;
149 EXPECT_TRUE(DecodePNG(base64, &result_bitmap)); 149 EXPECT_TRUE(DecodePNG(base64, &result_bitmap));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 devtools_client_->GetSecurity()->GetExperimental()->Disable( 181 devtools_client_->GetSecurity()->GetExperimental()->Disable(
182 security::DisableParams::Builder().Build()); 182 security::DisableParams::Builder().Build());
183 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); 183 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this);
184 FinishAsynchronousTest(); 184 FinishAsynchronousTest();
185 } 185 }
186 }; 186 };
187 187
188 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); 188 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest);
189 189
190 } // namespace headless 190 } // namespace headless
OLDNEW
« no previous file with comments | « headless/app/headless_shell.cc ('k') | third_party/WebKit/Source/core/inspector/browser_protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698