Commit 87d14196 authored by danakj's avatar danakj Committed by Commit Bot

Remove WebTestInterfaces

content/shell/renderer/ can see test_runner::WebTestInterfaces, so it
can also see test_runner::TestInterfaces. The former is just a shallow
wrapper around the latter, so it is not needed at all.

R=avi@chromium.org

Bug: 866140
Change-Id: Ic9ad15d27aae6d0293e23cdfb007e9511ff296d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128450Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754918}
parent 3362d485
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
#include "content/shell/test_runner/app_banner_service.h" #include "content/shell/test_runner/app_banner_service.h"
#include "content/shell/test_runner/gamepad_controller.h" #include "content/shell/test_runner/gamepad_controller.h"
#include "content/shell/test_runner/pixel_dump.h" #include "content/shell/test_runner/pixel_dump.h"
#include "content/shell/test_runner/web_test_interfaces.h" #include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/web_test_runner.h" #include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/web_widget_test_proxy.h" #include "content/shell/test_runner/web_widget_test_proxy.h"
#include "ipc/ipc_sync_channel.h" #include "ipc/ipc_sync_channel.h"
#include "media/base/audio_capturer_source.h" #include "media/base/audio_capturer_source.h"
...@@ -407,7 +407,7 @@ void BlinkTestRunner::OnWebTestRuntimeFlagsChanged( ...@@ -407,7 +407,7 @@ void BlinkTestRunner::OnWebTestRuntimeFlagsChanged(
// Ignore changes that happen before we got the initial, accumulated // Ignore changes that happen before we got the initial, accumulated
// web flag changes in either OnReplicateTestConfiguration or // web flag changes in either OnReplicateTestConfiguration or
// OnSetTestConfiguration. // OnSetTestConfiguration.
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
if (!interfaces->TestIsRunning()) if (!interfaces->TestIsRunning())
return; return;
...@@ -416,8 +416,10 @@ void BlinkTestRunner::OnWebTestRuntimeFlagsChanged( ...@@ -416,8 +416,10 @@ void BlinkTestRunner::OnWebTestRuntimeFlagsChanged(
} }
void BlinkTestRunner::TestFinished() { void BlinkTestRunner::TestFinished() {
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
test_runner::TestRunner* test_runner = interfaces->GetTestRunner();
// We might get multiple TestFinished calls, ensure to only process the dump // We might get multiple TestFinished calls, ensure to only process the dump
// once. // once.
if (!interfaces->TestIsRunning()) if (!interfaces->TestIsRunning())
...@@ -443,9 +445,9 @@ void BlinkTestRunner::TestFinished() { ...@@ -443,9 +445,9 @@ void BlinkTestRunner::TestFinished() {
dump_result_ = mojom::BlinkTestDump::New(); dump_result_ = mojom::BlinkTestDump::New();
bool browser_should_dump_back_forward_list = bool browser_should_dump_back_forward_list =
interfaces->TestRunner()->ShouldDumpBackForwardList(); test_runner->ShouldDumpBackForwardList();
if (interfaces->TestRunner()->ShouldDumpAsAudio()) { if (test_runner->ShouldDumpAsAudio()) {
CaptureLocalAudioDump(); CaptureLocalAudioDump();
GetWebTestClientRemote()->InitiateCaptureDump( GetWebTestClientRemote()->InitiateCaptureDump(
...@@ -460,14 +462,14 @@ void BlinkTestRunner::TestFinished() { ...@@ -460,14 +462,14 @@ void BlinkTestRunner::TestFinished() {
// rebaselined. But for now, just capture a local web first. // rebaselined. But for now, just capture a local web first.
CaptureLocalLayoutDump(); CaptureLocalLayoutDump();
if (!interfaces->TestRunner()->ShouldGeneratePixelResults()) { if (!test_runner->ShouldGeneratePixelResults()) {
GetWebTestClientRemote()->InitiateCaptureDump( GetWebTestClientRemote()->InitiateCaptureDump(
browser_should_dump_back_forward_list, browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false); /*browser_should_capture_pixels=*/false);
return; return;
} }
if (interfaces->TestRunner()->CanDumpPixelsFromRenderer()) { if (test_runner->CanDumpPixelsFromRenderer()) {
// This does the capture in the renderer when possible, otherwise // This does the capture in the renderer when possible, otherwise
// we will ask the browser to initiate it. // we will ask the browser to initiate it.
CaptureLocalPixelsDump(); CaptureLocalPixelsDump();
...@@ -476,33 +478,34 @@ void BlinkTestRunner::TestFinished() { ...@@ -476,33 +478,34 @@ void BlinkTestRunner::TestFinished() {
// for layout dump results. Any test can only require the browser to // for layout dump results. Any test can only require the browser to
// dump one or the other at this time. // dump one or the other at this time.
DCHECK(!waiting_for_layout_dump_results_); DCHECK(!waiting_for_layout_dump_results_);
if (interfaces->TestRunner()->ShouldDumpSelectionRect()) { if (test_runner->ShouldDumpSelectionRect()) {
dump_result_->selection_rect = dump_result_->selection_rect =
web_frame->GetSelectionBoundsRectForTesting(); web_frame->GetSelectionBoundsRectForTesting();
} }
} }
GetWebTestClientRemote()->InitiateCaptureDump( GetWebTestClientRemote()->InitiateCaptureDump(
browser_should_dump_back_forward_list, browser_should_dump_back_forward_list,
!interfaces->TestRunner()->CanDumpPixelsFromRenderer()); !test_runner->CanDumpPixelsFromRenderer());
} }
void BlinkTestRunner::CaptureLocalAudioDump() { void BlinkTestRunner::CaptureLocalAudioDump() {
TRACE_EVENT0("shell", "BlinkTestRunner::CaptureLocalAudioDump"); TRACE_EVENT0("shell", "BlinkTestRunner::CaptureLocalAudioDump");
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
dump_result_->audio.emplace(); dump_result_->audio.emplace();
interfaces->TestRunner()->GetAudioData(&*dump_result_->audio); interfaces->GetTestRunner()->GetAudioData(&*dump_result_->audio);
} }
void BlinkTestRunner::CaptureLocalLayoutDump() { void BlinkTestRunner::CaptureLocalLayoutDump() {
TRACE_EVENT0("shell", "BlinkTestRunner::CaptureLocalLayoutDump"); TRACE_EVENT0("shell", "BlinkTestRunner::CaptureLocalLayoutDump");
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
test_runner::TestRunner* test_runner = interfaces->GetTestRunner();
std::string layout; std::string layout;
if (interfaces->TestRunner()->HasCustomTextDump(&layout)) { if (test_runner->HasCustomTextDump(&layout)) {
dump_result_->layout.emplace(layout + "\n"); dump_result_->layout.emplace(layout + "\n");
} else if (!interfaces->TestRunner()->IsRecursiveLayoutDumpRequested()) { } else if (!test_runner->IsRecursiveLayoutDumpRequested()) {
dump_result_->layout.emplace(interfaces->TestRunner()->DumpLayout( dump_result_->layout.emplace(test_runner->DumpLayout(
render_view()->GetMainRenderFrame()->GetWebFrame())); render_view()->GetMainRenderFrame()->GetWebFrame()));
} else { } else {
// TODO(vmpstr): Since CaptureDump is called from the browser, we can be // TODO(vmpstr): Since CaptureDump is called from the browser, we can be
...@@ -521,9 +524,9 @@ void BlinkTestRunner::CaptureLocalPixelsDump() { ...@@ -521,9 +524,9 @@ void BlinkTestRunner::CaptureLocalPixelsDump() {
waiting_for_pixels_dump_result_ = true; waiting_for_pixels_dump_result_ = true;
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
interfaces->TestRunner()->DumpPixelsAsync( interfaces->GetTestRunner()->DumpPixelsAsync(
render_view(), base::BindOnce(&BlinkTestRunner::OnPixelsDumpCompleted, render_view(), base::BindOnce(&BlinkTestRunner::OnPixelsDumpCompleted,
base::Unretained(this))); base::Unretained(this)));
} }
...@@ -771,7 +774,7 @@ void BlinkTestRunner::OnSetupSecondaryRenderer() { ...@@ -771,7 +774,7 @@ void BlinkTestRunner::OnSetupSecondaryRenderer() {
// |!is_main_window_|. // |!is_main_window_|.
is_secondary_window_ = true; is_secondary_window_ = true;
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
interfaces->SetTestIsRunning(true); interfaces->SetTestIsRunning(true);
ForceResizeRenderView(render_view(), WebSize(800, 600)); ForceResizeRenderView(render_view(), WebSize(800, 600));
...@@ -779,7 +782,7 @@ void BlinkTestRunner::OnSetupSecondaryRenderer() { ...@@ -779,7 +782,7 @@ void BlinkTestRunner::OnSetupSecondaryRenderer() {
void BlinkTestRunner::ApplyTestConfiguration( void BlinkTestRunner::ApplyTestConfiguration(
mojom::ShellTestConfigurationPtr params) { mojom::ShellTestConfigurationPtr params) {
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
test_config_ = params.Clone(); test_config_ = params.Clone();
...@@ -805,10 +808,10 @@ void BlinkTestRunner::OnSetTestConfiguration( ...@@ -805,10 +808,10 @@ void BlinkTestRunner::OnSetTestConfiguration(
WebSize(local_params->initial_size.width(), WebSize(local_params->initial_size.width(),
local_params->initial_size.height())); local_params->initial_size.height()));
WebTestRenderThreadObserver::GetInstance() test_runner::TestInterfaces* interfaces =
->test_interfaces() WebTestRenderThreadObserver::GetInstance()->test_interfaces();
->TestRunner() test_runner::TestRunner* test_runner = interfaces->GetTestRunner();
->SetFocus(render_view()->GetWebView(), true); test_runner->SetFocus(render_view()->GetWebView(), true);
} }
void BlinkTestRunner::OnReset() { void BlinkTestRunner::OnReset() {
...@@ -836,7 +839,7 @@ void BlinkTestRunner::OnTestFinishedInSecondaryRenderer() { ...@@ -836,7 +839,7 @@ void BlinkTestRunner::OnTestFinishedInSecondaryRenderer() {
// Avoid a situation where TestFinished is called twice, because // Avoid a situation where TestFinished is called twice, because
// of a racey test finish in 2 secondary renderers. // of a racey test finish in 2 secondary renderers.
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
if (!interfaces->TestIsRunning()) if (!interfaces->TestIsRunning())
return; return;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "content/shell/renderer/web_test/web_test_render_frame_observer.h" #include "content/shell/renderer/web_test/web_test_render_frame_observer.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h" #include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
#include "content/shell/test_runner/web_frame_test_proxy.h" #include "content/shell/test_runner/web_frame_test_proxy.h"
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_test_runner.h" #include "content/shell/test_runner/web_test_runner.h"
#include "media/base/audio_latency.h" #include "media/base/audio_latency.h"
#include "media/base/mime_util.h" #include "media/base/mime_util.h"
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "content/shell/renderer/web_test/blink_test_runner.h" #include "content/shell/renderer/web_test/blink_test_runner.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h" #include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
#include "content/shell/test_runner/web_test_interfaces.h" #include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/web_test_runner.h" #include "content/shell/test_runner/test_runner.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h" #include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/public/web/web_frame_widget.h"
...@@ -25,10 +25,10 @@ namespace content { ...@@ -25,10 +25,10 @@ namespace content {
WebTestRenderFrameObserver::WebTestRenderFrameObserver( WebTestRenderFrameObserver::WebTestRenderFrameObserver(
RenderFrame* render_frame) RenderFrame* render_frame)
: RenderFrameObserver(render_frame) { : RenderFrameObserver(render_frame) {
test_runner::WebTestRunner* test_runner = test_runner::TestRunner* test_runner =
WebTestRenderThreadObserver::GetInstance() WebTestRenderThreadObserver::GetInstance()
->test_interfaces() ->test_interfaces()
->TestRunner(); ->GetTestRunner();
render_frame->GetWebFrame()->SetContentSettingsClient( render_frame->GetWebFrame()->SetContentSettingsClient(
test_runner->GetWebContentSettings()); test_runner->GetWebContentSettings());
render_frame->GetWebFrame()->SetTextCheckClient( render_frame->GetWebFrame()->SetTextCheckClient(
...@@ -78,11 +78,11 @@ void WebTestRenderFrameObserver::CompositeWithRaster( ...@@ -78,11 +78,11 @@ void WebTestRenderFrameObserver::CompositeWithRaster(
void WebTestRenderFrameObserver::DumpFrameLayout( void WebTestRenderFrameObserver::DumpFrameLayout(
DumpFrameLayoutCallback callback) { DumpFrameLayoutCallback callback) {
std::string dump = WebTestRenderThreadObserver::GetInstance() test_runner::TestInterfaces* interfaces =
->test_interfaces() WebTestRenderThreadObserver::GetInstance()->test_interfaces();
->TestRunner() test_runner::TestRunner* test_runner = interfaces->GetTestRunner();
->DumpLayout(render_frame()->GetWebFrame()); std::string dump = test_runner->DumpLayout(render_frame()->GetWebFrame());
std::move(callback).Run(dump); std::move(callback).Run(std::move(dump));
} }
void WebTestRenderFrameObserver::ReplicateTestConfiguration( void WebTestRenderFrameObserver::ReplicateTestConfiguration(
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "content/public/test/web_test_support.h" #include "content/public/test/web_test_support.h"
#include "content/shell/common/web_test/web_test_switches.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_interfaces.h"
#include "content/shell/test_runner/web_test_interfaces.h" #include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/web_test_runner.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/web/blink.h"
namespace content { namespace content {
...@@ -28,9 +28,11 @@ WebTestRenderThreadObserver::WebTestRenderThreadObserver() { ...@@ -28,9 +28,11 @@ WebTestRenderThreadObserver::WebTestRenderThreadObserver() {
CHECK(!g_instance); CHECK(!g_instance);
g_instance = this; g_instance = this;
RenderThread::Get()->AddObserver(this); RenderThread::Get()->AddObserver(this);
EnableRendererWebTestMode(); EnableRendererWebTestMode();
blink::SetWebTestMode(true);
test_interfaces_.reset(new test_runner::WebTestInterfaces); test_interfaces_ = std::make_unique<test_runner::TestInterfaces>();
test_interfaces_->ResetAll(); test_interfaces_->ResetAll();
} }
...@@ -63,7 +65,7 @@ void WebTestRenderThreadObserver::ReplicateWebTestRuntimeFlagsChanges( ...@@ -63,7 +65,7 @@ void WebTestRenderThreadObserver::ReplicateWebTestRuntimeFlagsChanges(
bool ok = changed_layout_test_runtime_flags.GetAsDictionary( bool ok = changed_layout_test_runtime_flags.GetAsDictionary(
&changed_web_test_runtime_flags_dictionary); &changed_web_test_runtime_flags_dictionary);
DCHECK(ok); DCHECK(ok);
test_interfaces()->TestRunner()->ReplicateWebTestRuntimeFlagsChanges( test_interfaces()->GetTestRunner()->ReplicateWebTestRuntimeFlagsChanges(
*changed_web_test_runtime_flags_dictionary); *changed_web_test_runtime_flags_dictionary);
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
namespace test_runner { namespace test_runner {
class WebTestInterfaces; class TestInterfaces;
} }
namespace content { namespace content {
...@@ -27,7 +27,7 @@ class WebTestRenderThreadObserver : public RenderThreadObserver, ...@@ -27,7 +27,7 @@ class WebTestRenderThreadObserver : public RenderThreadObserver,
WebTestRenderThreadObserver(); WebTestRenderThreadObserver();
~WebTestRenderThreadObserver() override; ~WebTestRenderThreadObserver() override;
test_runner::WebTestInterfaces* test_interfaces() const { test_runner::TestInterfaces* test_interfaces() const {
return test_interfaces_.get(); return test_interfaces_.get();
} }
...@@ -37,14 +37,16 @@ class WebTestRenderThreadObserver : public RenderThreadObserver, ...@@ -37,14 +37,16 @@ class WebTestRenderThreadObserver : public RenderThreadObserver,
void UnregisterMojoInterfaces( void UnregisterMojoInterfaces(
blink::AssociatedInterfaceRegistry* associated_interfaces) override; blink::AssociatedInterfaceRegistry* associated_interfaces) override;
private:
// mojom::WebTestControl implementation.
void ReplicateWebTestRuntimeFlagsChanges( void ReplicateWebTestRuntimeFlagsChanges(
base::Value changed_layout_test_runtime_flags) override; base::Value changed_layout_test_runtime_flags) override;
private: // Helper to bind this class as the mojom::WebTestControl.
void OnWebTestControlAssociatedRequest( void OnWebTestControlAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver); mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver);
std::unique_ptr<test_runner::WebTestInterfaces> test_interfaces_; std::unique_ptr<test_runner::TestInterfaces> test_interfaces_;
mojo::AssociatedReceiver<mojom::WebTestControl> receiver_{this}; mojo::AssociatedReceiver<mojom::WebTestControl> receiver_{this};
......
...@@ -69,8 +69,6 @@ jumbo_component("test_runner") { ...@@ -69,8 +69,6 @@ jumbo_component("test_runner") {
"web_frame_test_proxy.cc", "web_frame_test_proxy.cc",
"web_frame_test_proxy.h", "web_frame_test_proxy.h",
"web_test_delegate.h", "web_test_delegate.h",
"web_test_interfaces.cc",
"web_test_interfaces.h",
"web_test_runner.h", "web_test_runner.h",
"web_test_runtime_flags.cc", "web_test_runtime_flags.cc",
"web_test_runtime_flags.h", "web_test_runtime_flags.h",
......
...@@ -27,10 +27,7 @@ namespace test_runner { ...@@ -27,10 +27,7 @@ namespace test_runner {
TestInterfaces::TestInterfaces() TestInterfaces::TestInterfaces()
: gamepad_controller_(new GamepadController()), : gamepad_controller_(new GamepadController()),
test_runner_(new TestRunner(this)), test_runner_(new TestRunner(this)) {
delegate_(nullptr),
main_view_(nullptr) {
blink::SetWebTestMode(true);
// NOTE: please don't put feature specific enable flags here, // NOTE: please don't put feature specific enable flags here,
// instead add them to runtime_enabled_features.json5 // instead add them to runtime_enabled_features.json5
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "content/shell/test_runner/test_runner_export.h"
namespace blink { namespace blink {
class WebLocalFrame; class WebLocalFrame;
...@@ -18,13 +19,12 @@ class WebView; ...@@ -18,13 +19,12 @@ class WebView;
} }
namespace test_runner { namespace test_runner {
class GamepadController; class GamepadController;
class TestRunner; class TestRunner;
class WebTestDelegate; class WebTestDelegate;
class WebViewTestProxy; class WebViewTestProxy;
class TestInterfaces { class TEST_RUNNER_EXPORT TestInterfaces {
public: public:
TestInterfaces(); TestInterfaces();
~TestInterfaces(); ~TestInterfaces();
...@@ -56,10 +56,10 @@ class TestInterfaces { ...@@ -56,10 +56,10 @@ class TestInterfaces {
std::unique_ptr<GamepadController> gamepad_controller_; std::unique_ptr<GamepadController> gamepad_controller_;
std::unique_ptr<TestRunner> test_runner_; std::unique_ptr<TestRunner> test_runner_;
WebTestDelegate* delegate_; WebTestDelegate* delegate_ = nullptr;
std::vector<WebViewTestProxy*> window_list_; std::vector<WebViewTestProxy*> window_list_;
blink::WebView* main_view_; blink::WebView* main_view_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(TestInterfaces); DISALLOW_COPY_AND_ASSIGN(TestInterfaces);
}; };
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "content/shell/test_runner/test_runner.h" #include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/web_frame_test_client.h" #include "content/shell/test_runner/web_frame_test_client.h"
#include "content/shell/test_runner/web_test_delegate.h" #include "content/shell/test_runner/web_test_delegate.h"
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_view_test_proxy.h" #include "content/shell/test_runner/web_view_test_proxy.h"
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
...@@ -120,14 +119,16 @@ class TestRenderFrameObserver : public content::RenderFrameObserver { ...@@ -120,14 +119,16 @@ class TestRenderFrameObserver : public content::RenderFrameObserver {
WebFrameTestProxy::~WebFrameTestProxy() = default; WebFrameTestProxy::~WebFrameTestProxy() = default;
void WebFrameTestProxy::Initialize( void WebFrameTestProxy::Initialize(
WebTestInterfaces* interfaces,
content::RenderViewImpl* render_view_for_frame) { content::RenderViewImpl* render_view_for_frame) {
// The RenderViewImpl will also be a test proxy type. // The RenderViewImpl will also be a test proxy type.
auto* view_proxy_for_frame = auto* view_proxy_for_frame =
static_cast<WebViewTestProxy*>(render_view_for_frame); static_cast<WebViewTestProxy*>(render_view_for_frame);
// Creates a WebLocalFrameClient implementation providing test behavior (i.e.
// forwarding javascript console output to the test harness).
test_client_ = test_client_ =
interfaces->CreateWebFrameTestClient(view_proxy_for_frame, this); std::make_unique<WebFrameTestClient>(view_proxy_for_frame, this);
new TestRenderFrameObserver(this, view_proxy_for_frame); // deletes itself. new TestRenderFrameObserver(this, view_proxy_for_frame); // deletes itself.
} }
......
...@@ -23,7 +23,6 @@ class RenderViewImpl; ...@@ -23,7 +23,6 @@ class RenderViewImpl;
} // namespace content } // namespace content
namespace test_runner { namespace test_runner {
class WebTestInterfaces;
// WebFrameTestProxy is used during running web tests instead of a // WebFrameTestProxy is used during running web tests instead of a
// RenderFrameImpl to inject test-only behaviour by overriding methods in the // RenderFrameImpl to inject test-only behaviour by overriding methods in the
...@@ -35,8 +34,7 @@ class TEST_RUNNER_EXPORT WebFrameTestProxy : public content::RenderFrameImpl { ...@@ -35,8 +34,7 @@ class TEST_RUNNER_EXPORT WebFrameTestProxy : public content::RenderFrameImpl {
: RenderFrameImpl(std::forward<Args>(args)...) {} : RenderFrameImpl(std::forward<Args>(args)...) {}
~WebFrameTestProxy() override; ~WebFrameTestProxy() override;
void Initialize(WebTestInterfaces* interfaces, void Initialize(content::RenderViewImpl* render_view_for_frame);
content::RenderViewImpl* render_view_for_frame);
// Returns a frame name that can be used in the output of web tests // Returns a frame name that can be used in the output of web tests
// (the name is derived from the frame's unique name). // (the name is derived from the frame's unique name).
......
// Copyright 2013 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/shell/test_runner/web_test_interfaces.h"
#include <utility>
#include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/web_frame_test_client.h"
#include "content/shell/test_runner/web_view_test_proxy.h"
#include "content/shell/test_runner/web_widget_test_proxy.h"
namespace test_runner {
WebTestInterfaces::WebTestInterfaces() : interfaces_(new TestInterfaces()) {}
WebTestInterfaces::~WebTestInterfaces() {}
void WebTestInterfaces::SetMainView(blink::WebView* web_view) {
interfaces_->SetMainView(web_view);
}
void WebTestInterfaces::SetDelegate(WebTestDelegate* delegate) {
interfaces_->SetDelegate(delegate);
}
bool WebTestInterfaces::HasDelegate() {
return interfaces_->GetDelegate();
}
void WebTestInterfaces::ResetAll() {
interfaces_->ResetAll();
}
bool WebTestInterfaces::TestIsRunning() {
return interfaces_->TestIsRunning();
}
void WebTestInterfaces::SetTestIsRunning(bool running) {
interfaces_->SetTestIsRunning(running);
}
void WebTestInterfaces::ConfigureForTestWithURL(const blink::WebURL& test_url,
bool protocol_mode) {
interfaces_->ConfigureForTestWithURL(test_url, protocol_mode);
}
WebTestRunner* WebTestInterfaces::TestRunner() {
return interfaces_->GetTestRunner();
}
TestInterfaces* WebTestInterfaces::GetTestInterfaces() {
return interfaces_.get();
}
std::unique_ptr<WebFrameTestClient> WebTestInterfaces::CreateWebFrameTestClient(
WebViewTestProxy* web_view_test_proxy,
WebFrameTestProxy* web_frame_test_proxy) {
return std::make_unique<WebFrameTestClient>(web_view_test_proxy,
web_frame_test_proxy);
}
std::vector<blink::WebView*> WebTestInterfaces::GetWindowList() {
std::vector<blink::WebView*> result;
for (WebViewTestProxy* proxy : interfaces_->GetWindowList())
result.push_back(proxy->GetWebView());
return result;
}
} // namespace test_runner
// Copyright 2013 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_SHELL_TEST_RUNNER_WEB_TEST_INTERFACES_H_
#define CONTENT_SHELL_TEST_RUNNER_WEB_TEST_INTERFACES_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "content/shell/test_runner/test_runner_export.h"
namespace blink {
class WebLocalFrameClient;
class WebRTCPeerConnectionHandler;
class WebRTCPeerConnectionHandlerClient;
class WebURL;
class WebView;
}
namespace test_runner {
class TestInterfaces;
class WebFrameTestClient;
class WebFrameTestProxy;
class WebTestDelegate;
class WebViewTestProxy;
class WebTestRunner;
class TEST_RUNNER_EXPORT WebTestInterfaces {
public:
WebTestInterfaces();
~WebTestInterfaces();
void SetMainView(blink::WebView* web_view);
void SetDelegate(WebTestDelegate* delegate);
bool HasDelegate();
void ResetAll();
bool TestIsRunning();
void SetTestIsRunning(bool running);
// Configures the renderer for the test, based on |test_url| and
// |procotol_mode|.
void ConfigureForTestWithURL(const blink::WebURL& test_url,
bool protocol_mode);
WebTestRunner* TestRunner();
std::unique_ptr<blink::WebRTCPeerConnectionHandler>
CreateWebRTCPeerConnectionHandler(
blink::WebRTCPeerConnectionHandlerClient* client);
TestInterfaces* GetTestInterfaces();
// Creates a WebLocalFrameClient implementation providing test behavior (i.e.
// forwarding javascript console output to the test harness). The caller
// should guarantee that the returned object won't be used beyond the lifetime
// of WebTestInterfaces and/or the lifetime of |web_view_test_proxy|.
std::unique_ptr<WebFrameTestClient> CreateWebFrameTestClient(
WebViewTestProxy* web_view_test_proxy,
WebFrameTestProxy* web_frame_test_proxy);
// Gets a list of currently opened windows created by the current test.
std::vector<blink::WebView*> GetWindowList();
private:
std::unique_ptr<TestInterfaces> interfaces_;
DISALLOW_COPY_AND_ASSIGN(WebTestInterfaces);
};
} // namespace test_runner
#endif // CONTENT_SHELL_TEST_RUNNER_WEB_TEST_INTERFACES_H_
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "content/shell/test_runner/test_interfaces.h" #include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/test_runner.h" #include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/web_test_delegate.h" #include "content/shell/test_runner/web_test_delegate.h"
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_widget_test_proxy.h" #include "content/shell/test_runner/web_widget_test_proxy.h"
#include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/web_frame.h" #include "third_party/blink/public/web/web_frame.h"
...@@ -22,10 +21,10 @@ ...@@ -22,10 +21,10 @@
namespace test_runner { namespace test_runner {
void WebViewTestProxy::Initialize(WebTestInterfaces* interfaces, void WebViewTestProxy::Initialize(TestInterfaces* interfaces,
std::unique_ptr<WebTestDelegate> delegate) { std::unique_ptr<WebTestDelegate> delegate) {
delegate_ = std::move(delegate); delegate_ = std::move(delegate);
test_interfaces_ = interfaces->GetTestInterfaces(); test_interfaces_ = interfaces;
test_interfaces()->WindowOpened(this); test_interfaces()->WindowOpened(this);
} }
......
...@@ -41,7 +41,6 @@ class TestInterfaces; ...@@ -41,7 +41,6 @@ class TestInterfaces;
class TestRunnerForSpecificView; class TestRunnerForSpecificView;
class TextInputController; class TextInputController;
class WebTestDelegate; class WebTestDelegate;
class WebTestInterfaces;
// WebViewTestProxy is used to run web tests. This class is a partial fake // WebViewTestProxy is used to run web tests. This class is a partial fake
// implementation of RenderViewImpl that overrides the minimal necessary // implementation of RenderViewImpl that overrides the minimal necessary
...@@ -65,7 +64,7 @@ class TEST_RUNNER_EXPORT WebViewTestProxy : public content::RenderViewImpl { ...@@ -65,7 +64,7 @@ class TEST_RUNNER_EXPORT WebViewTestProxy : public content::RenderViewImpl {
template <typename... Args> template <typename... Args>
explicit WebViewTestProxy(Args&&... args) explicit WebViewTestProxy(Args&&... args)
: RenderViewImpl(std::forward<Args>(args)...) {} : RenderViewImpl(std::forward<Args>(args)...) {}
void Initialize(WebTestInterfaces* interfaces, void Initialize(TestInterfaces* interfaces,
std::unique_ptr<WebTestDelegate> delegate); std::unique_ptr<WebTestDelegate> delegate);
// WebViewClient implementation. // WebViewClient implementation.
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "content/shell/test_runner/test_runner.h" #include "content/shell/test_runner/test_runner.h"
#include "content/shell/test_runner/test_runner_for_specific_view.h" #include "content/shell/test_runner/test_runner_for_specific_view.h"
#include "content/shell/test_runner/web_test_delegate.h" #include "content/shell/test_runner/web_test_delegate.h"
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_view_test_proxy.h" #include "content/shell/test_runner/web_view_test_proxy.h"
#include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "content/renderer/render_widget.h" #include "content/renderer/render_widget.h"
#include "content/shell/renderer/web_test/blink_test_runner.h" #include "content/shell/renderer/web_test/blink_test_runner.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h" #include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
#include "content/shell/test_runner/test_interfaces.h"
#include "content/shell/test_runner/web_frame_test_proxy.h" #include "content/shell/test_runner/web_frame_test_proxy.h"
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_view_test_proxy.h" #include "content/shell/test_runner/web_view_test_proxy.h"
#include "content/shell/test_runner/web_widget_test_proxy.h" #include "content/shell/test_runner/web_widget_test_proxy.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
...@@ -56,22 +56,22 @@ namespace { ...@@ -56,22 +56,22 @@ namespace {
RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps, RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps,
const mojom::CreateViewParams& params) { const mojom::CreateViewParams& params) {
test_runner::WebTestInterfaces* interfaces = test_runner::TestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces(); WebTestRenderThreadObserver::GetInstance()->test_interfaces();
auto* render_view_proxy = auto* render_view_proxy =
new test_runner::WebViewTestProxy(compositor_deps, params); new test_runner::WebViewTestProxy(compositor_deps, params);
auto test_runner = std::make_unique<BlinkTestRunner>(render_view_proxy); auto blink_test_runner = std::make_unique<BlinkTestRunner>(render_view_proxy);
// TODO(lukasza): Using the first BlinkTestRunner as the main delegate is // TODO(lukasza): Using the first BlinkTestRunner as the main delegate is
// wrong, but it is difficult to change because this behavior has been baked // wrong, but it is difficult to change because this behavior has been baked
// for a long time into test assumptions (i.e. which PrintMessage gets // for a long time into test assumptions (i.e. which PrintMessage gets
// delivered to the browser depends on this). // delivered to the browser depends on this).
if (!interfaces->HasDelegate()) { if (!interfaces->GetDelegate()) {
interfaces->SetDelegate(test_runner.get()); interfaces->SetDelegate(blink_test_runner.get());
} }
render_view_proxy->Initialize(interfaces, std::move(test_runner)); render_view_proxy->Initialize(interfaces, std::move(blink_test_runner));
return render_view_proxy; return render_view_proxy;
} }
...@@ -87,15 +87,12 @@ std::unique_ptr<RenderWidget> CreateRenderWidgetForFrame( ...@@ -87,15 +87,12 @@ std::unique_ptr<RenderWidget> CreateRenderWidgetForFrame(
} }
RenderFrameImpl* CreateWebFrameTestProxy(RenderFrameImpl::CreateParams params) { RenderFrameImpl* CreateWebFrameTestProxy(RenderFrameImpl::CreateParams params) {
test_runner::WebTestInterfaces* interfaces =
WebTestRenderThreadObserver::GetInstance()->test_interfaces();
// RenderFrameImpl always has a RenderViewImpl for it. // RenderFrameImpl always has a RenderViewImpl for it.
RenderViewImpl* render_view_impl = params.render_view; RenderViewImpl* render_view_impl = params.render_view;
auto* render_frame_proxy = auto* render_frame_proxy =
new test_runner::WebFrameTestProxy(std::move(params)); new test_runner::WebFrameTestProxy(std::move(params));
render_frame_proxy->Initialize(interfaces, render_view_impl); render_frame_proxy->Initialize(render_view_impl);
return render_frame_proxy; return render_frame_proxy;
} }
......
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