| OLD | NEW |
| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 .SetExpression("document.body.style.background = '#0000ff'") | 154 .SetExpression("document.body.style.background = '#0000ff'") |
| 155 .Build(); | 155 .Build(); |
| 156 devtools_client_->GetRuntime()->Evaluate( | 156 devtools_client_->GetRuntime()->Evaluate( |
| 157 std::move(params), | 157 std::move(params), |
| 158 base::Bind(&HeadlessWebContentsScreenshotTest::OnPageSetupCompleted, | 158 base::Bind(&HeadlessWebContentsScreenshotTest::OnPageSetupCompleted, |
| 159 base::Unretained(this))); | 159 base::Unretained(this))); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void OnPageSetupCompleted(std::unique_ptr<runtime::EvaluateResult> result) { | 162 void OnPageSetupCompleted(std::unique_ptr<runtime::EvaluateResult> result) { |
| 163 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( | 163 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( |
| 164 page::CaptureScreenshotParams::Builder().SetFromSurface(true).Build(), | 164 page::CaptureScreenshotParams::Builder().Build(), |
| 165 base::Bind(&HeadlessWebContentsScreenshotTest::OnScreenshotCaptured, | 165 base::Bind(&HeadlessWebContentsScreenshotTest::OnScreenshotCaptured, |
| 166 base::Unretained(this))); | 166 base::Unretained(this))); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void OnScreenshotCaptured( | 169 void OnScreenshotCaptured( |
| 170 std::unique_ptr<page::CaptureScreenshotResult> result) { | 170 std::unique_ptr<page::CaptureScreenshotResult> result) { |
| 171 std::string base64 = result->GetData(); | 171 std::string base64 = result->GetData(); |
| 172 EXPECT_GT(base64.length(), 0U); | 172 EXPECT_GT(base64.length(), 0U); |
| 173 SkBitmap result_bitmap; | 173 SkBitmap result_bitmap; |
| 174 EXPECT_TRUE(DecodePNG(base64, &result_bitmap)); | 174 EXPECT_TRUE(DecodePNG(base64, &result_bitmap)); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 EXPECT_EQ("Embedder sent us: Hello", message); | 323 EXPECT_EQ("Embedder sent us: Hello", message); |
| 324 FinishAsynchronousTest(); | 324 FinishAsynchronousTest(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 bool GetCreateTabSocket() override { return true; } | 327 bool GetCreateTabSocket() override { return true; } |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessTabSocketTest); | 330 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessTabSocketTest); |
| 331 | 331 |
| 332 } // namespace headless | 332 } // namespace headless |
| OLD | NEW |