Skip to content

Commit

Permalink
[headless] Moved headless test utilities to //components/headless
Browse files Browse the repository at this point in the history
These utilities need to be used by tests in //headless and in
//chrome/browser/headless, this CL enables this by relocating
headless test utilities to a shared location.

Bug: 1408839
Change-Id: Iaee7827a137623098b10cc5f6d40126fb4c93514
Cq-Include-Trybots: luci.chromium.try:linux-headless-shell-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4193263
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098083}
  • Loading branch information
Peter Kvitek authored and Chromium LUCI CQ committed Jan 27, 2023
1 parent 2793bad commit 39be2dd
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 27 deletions.
41 changes: 41 additions & 0 deletions components/headless/test/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//pdf/features.gni")
import("//printing/buildflags/buildflags.gni")

source_set("test") {
sources = [
"bitmap_utils.cc",
"bitmap_utils.h",
"capture_std_stream.cc",
"capture_std_stream.h",
]

if (enable_printing && enable_pdf) {
sources += [
"pdf_utils.cc",
"pdf_utils.h",
]
}

deps = [
"//base",
"//pdf:buildflags",
"//printing/buildflags",
]

public_deps = [
"//skia",
"//ui/gfx",
]

if (enable_printing) {
deps += [ "//printing" ]

if (enable_pdf) {
deps += [ "//pdf" ]
}
}
}
6 changes: 6 additions & 0 deletions components/headless/test/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include_rules = [
"+pdf",
"+printing",
"+third_party/skia/include",
"+ui/gfx",
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "headless/test/bitmap_utils.h"
#include "components/headless/test/bitmap_utils.h"

#include "base/logging.h"
#include "ui/gfx/geometry/point.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef HEADLESS_TEST_BITMAP_UTILS_H_
#define HEADLESS_TEST_BITMAP_UTILS_H_
#ifndef COMPONENTS_HEADLESS_TEST_BITMAP_UTILS_H_
#define COMPONENTS_HEADLESS_TEST_BITMAP_UTILS_H_

#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
Expand All @@ -23,4 +23,4 @@ bool CheckColoredRect(const SkBitmap& bitmap,

} // namespace headless

#endif // HEADLESS_TEST_BITMAP_UTILS_H_
#endif // COMPONENTS_HEADLESS_TEST_BITMAP_UTILS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "headless/test/capture_std_stream.h"
#include "components/headless/test/capture_std_stream.h"

#include <fcntl.h>
#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef HEADLESS_TEST_CAPTURE_STD_STREAM_H_
#define HEADLESS_TEST_CAPTURE_STD_STREAM_H_
#ifndef COMPONENTS_HEADLESS_TEST_CAPTURE_STD_STREAM_H_
#define COMPONENTS_HEADLESS_TEST_CAPTURE_STD_STREAM_H_

#include <cstdio>
#include <string>
Expand Down Expand Up @@ -46,4 +46,4 @@ class CaptureStdErr : public CaptureStdStream {

} // namespace headless

#endif // HEADLESS_TEST_CAPTURE_STD_STREAM_H_
#endif // COMPONENTS_HEADLESS_TEST_CAPTURE_STD_STREAM_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "headless/test/pdf_utils.h"
#include "components/headless/test/pdf_utils.h"

#include "base/logging.h"
#include "headless/test/bitmap_utils.h"
#include "components/headless/test/bitmap_utils.h"
#include "pdf/pdf.h"
#include "printing/units.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef HEADLESS_TEST_PDF_UTILS_H_
#define HEADLESS_TEST_PDF_UTILS_H_
#ifndef COMPONENTS_HEADLESS_TEST_PDF_UTILS_H_
#define COMPONENTS_HEADLESS_TEST_PDF_UTILS_H_

#include <cstdint>
#include <string>
Expand Down Expand Up @@ -47,4 +47,4 @@ class PDFPageBitmap {

} // namespace headless

#endif // HEADLESS_TEST_PDF_UTILS_H_
#endif // COMPONENTS_HEADLESS_TEST_PDF_UTILS_H_
11 changes: 2 additions & 9 deletions headless/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,6 @@ test("headless_browsertests") {
"//v8:external_startup_data",
]
sources = [
"test/bitmap_utils.cc",
"test/bitmap_utils.h",
"test/capture_std_stream.cc",
"test/capture_std_stream.h",
"test/headless_browser_browsertest.cc",
"test/headless_browser_context_browsertest.cc",
"test/headless_browser_test.cc",
Expand All @@ -714,11 +710,7 @@ test("headless_browsertests") {
]

if (enable_printing && enable_pdf) {
sources += [
"test/headless_printtopdf_browsertest.cc",
"test/pdf_utils.cc",
"test/pdf_utils.h",
]
sources += [ "test/headless_printtopdf_browsertest.cc" ]
}

if (headless_use_policy) {
Expand Down Expand Up @@ -780,6 +772,7 @@ test("headless_browsertests") {
"//base",
"//cc:test_support",
"//components/devtools/simple_devtools_protocol_client",
"//components/headless/test",
"//components/policy/core/browser",
"//components/security_state/content",
"//content/test:browsertest_support",
Expand Down
6 changes: 3 additions & 3 deletions headless/test/headless_command_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#include "build/build_config.h"
#include "components/headless/command_handler/headless_command_handler.h"
#include "components/headless/command_handler/headless_command_switches.h"
#include "components/headless/test/bitmap_utils.h"
#include "components/headless/test/capture_std_stream.h"
#include "content/public/test/browser_test.h"
#include "headless/lib/browser/headless_browser_context_impl.h"
#include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "headless/public/headless_browser.h"
#include "headless/public/headless_browser_context.h"
#include "headless/public/headless_web_contents.h"
#include "headless/test/bitmap_utils.h"
#include "headless/test/capture_std_stream.h"
#include "headless/test/headless_browser_test.h"
#include "headless/test/headless_browser_test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
Expand All @@ -38,7 +38,7 @@
#include "url/gurl.h"

#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PDF)
#include "headless/test/pdf_utils.h"
#include "components/headless/test/pdf_utils.h"
#endif

namespace headless {
Expand Down
2 changes: 1 addition & 1 deletion headless/test/headless_policy_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/headless/test/capture_std_stream.h"
#include "components/policy/core/browser/browser_policy_connector_base.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
Expand All @@ -29,7 +30,6 @@
#include "headless/lib/browser/policy/headless_mode_policy.h"
#include "headless/public/headless_browser.h"
#include "headless/public/switches.h"
#include "headless/test/capture_std_stream.h"
#include "headless/test/headless_browser_test.h"
#include "headless/test/headless_browser_test_utils.h"
#include "net/base/host_port_pair.h"
Expand Down
2 changes: 1 addition & 1 deletion headless/test/headless_printtopdf_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include "base/strings/string_piece.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "components/headless/test/pdf_utils.h"
#include "content/public/test/browser_test.h"
#include "headless/public/switches.h"
#include "headless/test/headless_browser_test.h"
#include "headless/test/headless_browser_test_utils.h"
#include "headless/test/headless_devtooled_browsertest.h"
#include "headless/test/pdf_utils.h"
#include "pdf/pdf.h"
#include "printing/buildflags/buildflags.h"
#include "printing/pdf_render_settings.h"
Expand Down

0 comments on commit 39be2dd

Please sign in to comment.