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

Unified Diff: headless/lib/headless_web_contents_browsertest.cc

Issue 2035733002: headless: Implement screenshot capturing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses reviewer comments. Created 4 years, 6 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 | « headless/lib/headless_devtools_client_browsertest.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_web_contents_browsertest.cc
diff --git a/headless/lib/headless_web_contents_browsertest.cc b/headless/lib/headless_web_contents_browsertest.cc
index 30faee5e65ef2edf70551c8d55a642af152f4333..5cff88c0441b2529962893f61341be2272bb62e3 100644
--- a/headless/lib/headless_web_contents_browsertest.cc
+++ b/headless/lib/headless_web_contents_browsertest.cc
@@ -3,9 +3,13 @@
// found in the LICENSE file.
#include <memory>
+#include <string>
+#include <vector>
#include "content/public/test/browser_test.h"
+#include "headless/public/domains/page.h"
#include "headless/public/headless_browser.h"
+#include "headless/public/headless_devtools_client.h"
#include "headless/public/headless_web_contents.h"
#include "headless/test/headless_browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -18,6 +22,7 @@ class HeadlessWebContentsTest : public HeadlessBrowserTest {};
IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) {
EXPECT_TRUE(embedded_test_server()->Start());
+
HeadlessWebContents* web_contents = browser()->CreateWebContents(
embedded_test_server()->GetURL("/hello.html"), gfx::Size(800, 600));
EXPECT_TRUE(WaitForLoad(web_contents));
@@ -42,4 +47,23 @@ IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, WindowOpen) {
EXPECT_EQ(static_cast<size_t>(2), all_web_contents.size());
}
+class HeadlessWebContentsScreenshotTest
+ : public HeadlessAsyncDevTooledBrowserTest {
+ public:
+ void RunDevTooledTest() override {
+ devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot(
+ page::CaptureScreenshotParams::Builder().Build(),
+ base::Bind(&HeadlessWebContentsScreenshotTest::OnScreenshotCaptured,
+ base::Unretained(this)));
+ }
+
+ void OnScreenshotCaptured(
+ std::unique_ptr<page::CaptureScreenshotResult> result) {
+ EXPECT_LT(0U, result->GetData().length());
+ FinishAsynchronousTest();
+ }
+};
+
+HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsScreenshotTest);
+
} // namespace headless
« no previous file with comments | « headless/lib/headless_devtools_client_browsertest.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698