Commit 256762a4 authored by danakj's avatar danakj Committed by Commit Bot

Split web_test_support into browser-side and renderer-side components

In order to incrementally split content/shell/renderer/web_test out of
content_shell_lib, into web_test_renderer, we must split apart
web_test_support.

content_shell_lib must depend on the browser-side code in
web_test_support, so we move that to web_test_support_browser. Then
the dependency on web_test_support_renderer needs only be in
the web_test_renderer target.

Without this change, any dependency on content_shell_lib would also
include web_test_support_renderer, but not web_test_renderer, which
causes a build failure due to:
1) Circular includes between web_test_support_renderer and
   web_test_renderer
2) So web_test_renderer -> web_test_support_renderer
3) But web_test_support_renderer -/-> web_test_renderer
4) This means depending on web_test_support_renderer without going
   through web_test_renderer does not link.

R=avi@chromium.org

Bug: 866140
Change-Id: If3ae301f44bd2057fb196f39e7947607bb3da60f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134858
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756341}
parent 365be7a3
......@@ -731,6 +731,7 @@ mojom("mojo_bindings") {
"//services/network/public/cpp",
"//third_party/blink/public/common",
"//ui/accessibility",
"//ui/base/cursor",
"//ui/base/ime:text_input_types",
"//ui/events/blink",
"//ui/gfx/ipc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_BROWSER_H_
#define CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_BROWSER_H_
namespace content {
// Turn the browser process into web test mode.
void EnableBrowserWebTestMode();
// Sets the scan duration to reflect the given setting.
enum class BluetoothTestScanDurationSetting {
kImmediateTimeout, // Set the scan duration to 0 seconds.
kNeverTimeout, // Set the scan duration to base::TimeDelta::Max() seconds.
};
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting);
} // namespace content
#endif // CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_BROWSER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_H_
#define CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_H_
#ifndef CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_RENDERER_H_
#define CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_RENDERER_H_
#include <stddef.h>
......@@ -36,12 +36,6 @@ namespace content {
class RenderFrame;
class RenderView;
// Turn the browser process into web test mode.
void EnableBrowserWebTestMode();
///////////////////////////////////////////////////////////////////////////////
// The following methods are meant to be used from a renderer.
// Turn a renderer into web test mode.
void EnableRendererWebTestMode();
......@@ -91,13 +85,6 @@ gfx::ColorSpace GetTestingColorSpace(const std::string& name);
void SetDeviceColorSpace(RenderView* render_view,
const gfx::ColorSpace& color_space);
// Sets the scan duration to reflect the given setting.
enum class BluetoothTestScanDurationSetting {
kImmediateTimeout, // Set the scan duration to 0 seconds.
kNeverTimeout, // Set the scan duration to base::TimeDelta::Max() seconds.
};
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting);
// Enables or disables synchronous resize mode. When enabled, all window-sizing
// machinery is short-circuited inside the renderer. This mode is necessary for
// some tests that were written before browsers had multi-process architecture
......@@ -127,4 +114,4 @@ void SetWorkerRewriteURLFunction(RewriteURLFunction rewrite_url_function);
} // namespace content
#endif // CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_H_
#endif // CONTENT_PUBLIC_TEST_WEB_TEST_SUPPORT_RENDERER_H_
......@@ -327,7 +327,8 @@ static_library("content_shell_lib") {
"//content/test:content_test_mojo_bindings",
"//content/test:mojo_web_test_bindings",
"//content/test:test_support",
"//content/test:web_test_support",
"//content/test:web_test_support_browser",
"//content/test:web_test_support_renderer",
"//device/bluetooth",
"//device/bluetooth:fake_bluetooth",
"//device/bluetooth:mocks",
......@@ -388,7 +389,7 @@ static_library("content_shell_lib") {
}
# Annoyingly, this target and web_test_support have circular includes.
allow_circular_includes_from = [ "//content/test:web_test_support" ]
allow_circular_includes_from = [ "//content/test:web_test_support_renderer" ]
if (enable_plugins) {
deps += [
......
......@@ -58,7 +58,6 @@
#include "content/public/common/page_state.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/blink_test_browser_support.h"
#include "content/public/test/web_test_support.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_content_browser_client.h"
......
......@@ -8,7 +8,7 @@
#include <utility>
#include "content/public/browser/bluetooth_chooser.h"
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_browser.h"
#include "content/shell/common/web_test/fake_bluetooth_chooser.mojom.h"
namespace content {
......
......@@ -8,7 +8,7 @@
#include <string>
#include <utility>
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_browser.h"
#include "content/shell/browser/web_test/web_test_bluetooth_adapter_provider.h"
#include "content/shell/common/web_test/web_test_bluetooth_fake_adapter_setter.mojom.h"
#include "device/bluetooth/bluetooth_adapter_factory_wrapper.h"
......@@ -17,11 +17,11 @@
namespace content {
WebTestBluetoothFakeAdapterSetterImpl::WebTestBluetoothFakeAdapterSetterImpl() {
}
WebTestBluetoothFakeAdapterSetterImpl::WebTestBluetoothFakeAdapterSetterImpl() =
default;
WebTestBluetoothFakeAdapterSetterImpl::
~WebTestBluetoothFakeAdapterSetterImpl() {}
~WebTestBluetoothFakeAdapterSetterImpl() = default;
// static
void WebTestBluetoothFakeAdapterSetterImpl::Create(
......
......@@ -28,7 +28,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/ppapi_test_utils.h"
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_browser.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/test_info_extractor.h"
......
......@@ -40,7 +40,7 @@
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_visitor.h"
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_renderer.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/web_test/blink_test_helpers.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
......
......@@ -17,7 +17,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_renderer.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "content/shell/renderer/shell_render_view_observer.h"
......
......@@ -6,7 +6,7 @@
#include "content/public/common/content_client.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_renderer.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/test_runner.h"
......
......@@ -737,7 +737,7 @@ if (is_android) {
}
}
static_library("web_test_support") {
static_library("web_test_support_browser") {
testonly = true
# See comment at the top of //content/BUILD.gn for why this is disabled in
......@@ -747,28 +747,39 @@ static_library("web_test_support") {
}
sources = [
"../public/test/web_test_support.h",
"web_test_support.cc",
"../public/test/web_test_support_browser.h",
"web_test_support_browser.cc",
]
deps = [
"//content/browser:for_content_tests", # For non-component builds.
"//content/public/browser", # For component builds.
"//net:test_support",
]
}
static_library("web_test_support_renderer") {
testonly = true
# See comment at the top of //content/BUILD.gn for why this is disabled in
# component builds.
if (is_component_build) {
check_includes = false
}
sources = [
"../public/test/web_test_support_renderer.h",
"web_test_support_renderer.cc",
]
deps = [
":test_support",
"//content/browser:for_content_tests",
"//content/child:for_content_tests",
"//content/public/common",
"//content/public/renderer",
"//content/renderer:for_content_tests",
"//content/shell/test_runner:test_runner",
"//device/bluetooth",
"//device/gamepad/public/cpp:shared_with_blink",
"//net:test_support",
"//services/device/public/cpp/generic_sensor",
"//skia",
"//ui/accessibility:ax_enums_mojo",
"//ui/events/blink",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
"//v8",
# This is required to ensure
# content/shell/common/web_test/blink_test.mojom.h
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/test/web_test_support_browser.h"
#include "build/build_config.h"
#include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#if defined(OS_MACOSX)
#include "content/browser/frame_host/popup_menu_helper_mac.h"
#include "content/browser/sandbox_parameters_mac.h"
#include "net/test/test_data_directory.h"
#endif
namespace content {
void EnableBrowserWebTestMode() {
#if defined(OS_MACOSX)
PopupMenuHelper::DontShowPopupMenuForTesting();
// Expand the network service sandbox to allow reading the test TLS
// certificates.
SetNetworkTestCertsDirectoryForTesting(net::GetTestCertsDirectory());
#endif
RenderWidgetHostImpl::DisableResizeAckCheckForTesting();
}
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) {
switch (setting) {
case BluetoothTestScanDurationSetting::kImmediateTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
IMMEDIATE_TIMEOUT);
break;
case BluetoothTestScanDurationSetting::kNeverTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
NEVER_TIMEOUT);
break;
}
}
} // namespace content
......@@ -2,19 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/test/web_test_support.h"
#include "content/public/test/web_test_support_renderer.h"
#include <memory>
#include <string>
#include <utility>
#include "base/callback.h"
#include "build/build_config.h"
#include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/renderer.mojom.h"
#include "content/common/unique_name_helper.h"
#include "content/public/browser/storage_partition.h"
#include "content/renderer/input/render_widget_input_handler_delegate.h"
#include "content/renderer/loader/request_extra_data.h"
#include "content/renderer/loader/web_worker_fetch_context_impl.h"
......@@ -41,15 +37,6 @@
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/test/icc_profiles.h"
#if defined(OS_MACOSX)
#include "content/browser/frame_host/popup_menu_helper_mac.h"
#include "content/browser/sandbox_parameters_mac.h"
#include "net/test/test_data_directory.h"
#endif
using blink::WebRect;
using blink::WebSize;
namespace content {
namespace {
......@@ -131,17 +118,6 @@ void EnableRendererWebTestMode() {
UniqueNameHelper::PreserveStableUniqueNameForTesting();
}
void EnableBrowserWebTestMode() {
#if defined(OS_MACOSX)
PopupMenuHelper::DontShowPopupMenuForTesting();
// Expand the network service sandbox to allow reading the test TLS
// certificates.
SetNetworkTestCertsDirectoryForTesting(net::GetTestCertsDirectory());
#endif
RenderWidgetHostImpl::DisableResizeAckCheckForTesting();
}
int GetLocalSessionHistoryLength(RenderView* render_view) {
return static_cast<RenderViewImpl*>(render_view)
->GetLocalSessionHistoryLengthForTesting();
......@@ -152,7 +128,8 @@ void SetFocusAndActivate(RenderView* render_view, bool enable) {
->SetFocusAndActivateForTesting(enable);
}
void ForceResizeRenderView(RenderView* render_view, const WebSize& new_size) {
void ForceResizeRenderView(RenderView* render_view,
const blink::WebSize& new_size) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
RenderFrameImpl* main_frame = render_view_impl->GetMainRenderFrame();
if (!main_frame)
......@@ -233,21 +210,6 @@ void SetDeviceColorSpace(RenderView* render_view,
render_widget->SetDeviceColorSpaceForTesting(color_space);
}
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) {
switch (setting) {
case BluetoothTestScanDurationSetting::kImmediateTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
IMMEDIATE_TIMEOUT);
break;
case BluetoothTestScanDurationSetting::kNeverTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
NEVER_TIMEOUT);
break;
}
}
void UseSynchronousResizeMode(RenderView* render_view, bool enable) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
RenderFrameImpl* main_frame = render_view_impl->GetMainRenderFrame();
......@@ -258,8 +220,8 @@ void UseSynchronousResizeMode(RenderView* render_view, bool enable) {
}
void EnableAutoResizeMode(RenderView* render_view,
const WebSize& min_size,
const WebSize& max_size) {
const blink::WebSize& min_size,
const blink::WebSize& max_size) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
RenderFrameImpl* main_frame = render_view_impl->GetMainRenderFrame();
if (!main_frame)
......@@ -268,7 +230,8 @@ void EnableAutoResizeMode(RenderView* render_view,
render_widget->EnableAutoResizeForTesting(min_size, max_size);
}
void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) {
void DisableAutoResizeMode(RenderView* render_view,
const blink::WebSize& new_size) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
RenderFrameImpl* main_frame = render_view_impl->GetMainRenderFrame();
if (!main_frame)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment