Commit 92f32d54 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Convert renderer side's legacy IPCs of BlinkTest message to Mojo

As a step to convert legacy IPCs to the Mojo, this CL
converts renderer side's BlinkTest IPC messages to the Mojo.
This CL adds the IPC messages to WebTestControl interface in
web_test.mojom file. Now it starts to support the original
messages. The added methods are as follow,

 - Reset();
 - TestFinishedInSecondaryRenderer();
 - LayoutDumpCompleted(string completed_layout_dump);
 - ReplyBluetoothManualChooserEvents(array<string> events);

This CL should not change any behavior.

Bug: 1039247
Change-Id: I43dbdbb9d9d4fb20a4f7a55e4e10fbf33e5622ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1991045Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#732323}
parent de1ecbb8
...@@ -578,10 +578,9 @@ void BlinkTestController::OpenURL(const GURL& url) { ...@@ -578,10 +578,9 @@ void BlinkTestController::OpenURL(const GURL& url) {
} }
void BlinkTestController::OnTestFinishedInSecondaryRenderer() { void BlinkTestController::OnTestFinishedInSecondaryRenderer() {
RenderViewHost* main_render_view_host = GetWebTestControlRemote(
main_window_->web_contents()->GetRenderViewHost(); main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
main_render_view_host->Send(new BlinkTestMsg_TestFinishedInSecondaryRenderer( ->TestFinishedInSecondaryRenderer();
main_render_view_host->GetRoutingID()));
} }
void BlinkTestController::OnInitiateCaptureDump(bool capture_navigation_history, void BlinkTestController::OnInitiateCaptureDump(bool capture_navigation_history,
...@@ -1041,14 +1040,15 @@ void BlinkTestController::OnTestFinished() { ...@@ -1041,14 +1040,15 @@ void BlinkTestController::OnTestFinished() {
void BlinkTestController::OnCleanupFinished() { void BlinkTestController::OnCleanupFinished() {
if (main_window_) { if (main_window_) {
main_window_->web_contents()->Stop(); main_window_->web_contents()->Stop();
RenderViewHost* rvh = main_window_->web_contents()->GetRenderViewHost(); GetWebTestControlRemote(
rvh->Send(new BlinkTestMsg_Reset(rvh->GetRoutingID())); main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->Reset();
} }
if (secondary_window_) { if (secondary_window_) {
secondary_window_->web_contents()->Stop(); secondary_window_->web_contents()->Stop();
RenderViewHost* rvh = GetWebTestControlRemote(
secondary_window_->web_contents()->GetRenderViewHost(); secondary_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
rvh->Send(new BlinkTestMsg_Reset(rvh->GetRoutingID())); ->Reset();
} }
} }
...@@ -1223,10 +1223,9 @@ void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id, ...@@ -1223,10 +1223,9 @@ void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
} }
// Continue finishing the test. // Continue finishing the test.
RenderViewHost* render_view_host = GetWebTestControlRemote(
main_window_->web_contents()->GetRenderViewHost(); main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
render_view_host->Send(new BlinkTestMsg_LayoutDumpCompleted( ->LayoutDumpCompleted(stitched_layout_dump);
render_view_host->GetRoutingID(), stitched_layout_dump));
} }
void BlinkTestController::OnPrintMessage(const std::string& message) { void BlinkTestController::OnPrintMessage(const std::string& message) {
...@@ -1404,9 +1403,10 @@ void BlinkTestController::OnGetBluetoothManualChooserEvents() { ...@@ -1404,9 +1403,10 @@ void BlinkTestController::OnGetBluetoothManualChooserEvents() {
"getBluetoothManualChooserEvents."); "getBluetoothManualChooserEvents.");
return; return;
} }
RenderViewHost* rvh = main_window_->web_contents()->GetRenderViewHost(); GetWebTestControlRemote(
rvh->Send(new BlinkTestMsg_ReplyBluetoothManualChooserEvents( main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
rvh->GetRoutingID(), bluetooth_chooser_factory_->GetAndResetEvents())); ->ReplyBluetoothManualChooserEvents(
bluetooth_chooser_factory_->GetAndResetEvents());
} }
void BlinkTestController::OnSendBluetoothManualChooserEvent( void BlinkTestController::OnSendBluetoothManualChooserEvent(
......
...@@ -68,4 +68,20 @@ interface WebTestControl { ...@@ -68,4 +68,20 @@ interface WebTestControl {
// Sets up a secondary renderer (renderer that doesn't [yet] host parts of the // Sets up a secondary renderer (renderer that doesn't [yet] host parts of the
// main test window) for a web test. // main test window) for a web test.
SetupSecondaryRenderer(); SetupSecondaryRenderer();
// Tells the renderer to reset all test runners.
Reset();
// Tells the main window that a secondary renderer in a different process
// asked to finish the test.
TestFinishedInSecondaryRenderer();
// Notifies BlinkTestRunner that the layout dump has completed (and that it
// can proceed with finishing up the test).
// TODO(crbug.com/1039247): This message should be removed and the callback
// should happen part of LayoutDump call on the host interface.
LayoutDumpCompleted(string completed_layout_dump);
// Reply Bluetooth manual events to BlinkTestRunner.
ReplyBluetoothManualChooserEvents(array<string> events);
}; };
...@@ -15,25 +15,12 @@ ...@@ -15,25 +15,12 @@
#define IPC_MESSAGE_START BlinkTestMsgStart #define IPC_MESSAGE_START BlinkTestMsgStart
// Tells the renderer to reset all test runners.
IPC_MESSAGE_ROUTED0(BlinkTestMsg_Reset)
// Tells the main window that a secondary renderer in a different process asked
// to finish the test.
IPC_MESSAGE_ROUTED0(BlinkTestMsg_TestFinishedInSecondaryRenderer)
// Notifies BlinkTestRunner that the layout dump has completed
// (and that it can proceed with finishing up the test).
IPC_MESSAGE_ROUTED1(BlinkTestMsg_LayoutDumpCompleted,
std::string /* completed/stitched layout dump */)
IPC_MESSAGE_ROUTED1(BlinkTestMsg_ReplyBluetoothManualChooserEvents,
std::vector<std::string> /* events */)
// Asks the browser process to perform a layout dump spanning all the // Asks the browser process to perform a layout dump spanning all the
// (potentially cross-process) frames. This goes through multiple // (potentially cross-process) frames. This goes through multiple
// WebTestControl.DumpFrameLayout calls and ends with sending of // WebTestControl.DumpFrameLayout calls and ends with sending of
// BlinkTestMsg_LayoutDumpCompleted. // LayoutDumpCompleted.
// TODO(crbug.com/1039247): LayoutDumpCompleted call should be removed and the
// callback should happen part of LayoutDump call on the host interface.
IPC_MESSAGE_ROUTED0(BlinkTestHostMsg_InitiateLayoutDump) IPC_MESSAGE_ROUTED0(BlinkTestHostMsg_InitiateLayoutDump)
IPC_MESSAGE_ROUTED0(BlinkTestHostMsg_ResetDone) IPC_MESSAGE_ROUTED0(BlinkTestHostMsg_ResetDone)
......
...@@ -683,21 +683,6 @@ void BlinkTestRunner::DidClearWindowObject(WebLocalFrame* frame) { ...@@ -683,21 +683,6 @@ void BlinkTestRunner::DidClearWindowObject(WebLocalFrame* frame) {
WebTestingSupport::InjectInternalsObject(frame); WebTestingSupport::InjectInternalsObject(frame);
} }
bool BlinkTestRunner::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BlinkTestRunner, message)
IPC_MESSAGE_HANDLER(BlinkTestMsg_Reset, OnReset)
IPC_MESSAGE_HANDLER(BlinkTestMsg_TestFinishedInSecondaryRenderer,
OnTestFinishedInSecondaryRenderer)
IPC_MESSAGE_HANDLER(BlinkTestMsg_ReplyBluetoothManualChooserEvents,
OnReplyBluetoothManualChooserEvents)
IPC_MESSAGE_HANDLER(BlinkTestMsg_LayoutDumpCompleted, OnLayoutDumpCompleted)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
// Public methods - ----------------------------------------------------------- // Public methods - -----------------------------------------------------------
void BlinkTestRunner::Reset(bool for_new_test) { void BlinkTestRunner::Reset(bool for_new_test) {
......
...@@ -51,7 +51,6 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -51,7 +51,6 @@ class BlinkTestRunner : public RenderViewObserver,
~BlinkTestRunner() override; ~BlinkTestRunner() override;
// RenderViewObserver implementation. // RenderViewObserver implementation.
bool OnMessageReceived(const IPC::Message& message) override;
void DidClearWindowObject(blink::WebLocalFrame* frame) override; void DidClearWindowObject(blink::WebLocalFrame* frame) override;
// WebTestDelegate implementation. // WebTestDelegate implementation.
...@@ -154,14 +153,13 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -154,14 +153,13 @@ class BlinkTestRunner : public RenderViewObserver,
void OnSetupSecondaryRenderer(); void OnSetupSecondaryRenderer();
void CaptureDump(mojom::WebTestControl::CaptureDumpCallback callback); void CaptureDump(mojom::WebTestControl::CaptureDumpCallback callback);
void DidCommitNavigationInMainFrame(); void DidCommitNavigationInMainFrame();
private:
// Message handlers.
void OnReset(); void OnReset();
void OnTestFinishedInSecondaryRenderer(); void OnTestFinishedInSecondaryRenderer();
void OnLayoutDumpCompleted(std::string completed_layout_dump);
void OnReplyBluetoothManualChooserEvents( void OnReplyBluetoothManualChooserEvents(
const std::vector<std::string>& events); const std::vector<std::string>& events);
private:
// RenderViewObserver implementation. // RenderViewObserver implementation.
void OnDestruct() override; void OnDestruct() override;
...@@ -170,7 +168,6 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -170,7 +168,6 @@ class BlinkTestRunner : public RenderViewObserver,
// After finishing the test, retrieves the audio, text, and pixel dumps from // After finishing the test, retrieves the audio, text, and pixel dumps from
// the TestRunner library and sends them to the browser process. // the TestRunner library and sends them to the browser process.
void OnLayoutDumpCompleted(std::string completed_layout_dump);
void OnPixelsDumpCompleted(const SkBitmap& snapshot); void OnPixelsDumpCompleted(const SkBitmap& snapshot);
void CaptureDumpComplete(); void CaptureDumpComplete();
void CaptureLocalAudioDump(); void CaptureLocalAudioDump();
......
...@@ -116,4 +116,25 @@ void WebTestRenderFrameObserver::SetupSecondaryRenderer() { ...@@ -116,4 +116,25 @@ void WebTestRenderFrameObserver::SetupSecondaryRenderer() {
->OnSetupSecondaryRenderer(); ->OnSetupSecondaryRenderer();
} }
void WebTestRenderFrameObserver::Reset() {
BlinkTestRunner::Get(render_frame()->GetRenderView())->OnReset();
}
void WebTestRenderFrameObserver::TestFinishedInSecondaryRenderer() {
BlinkTestRunner::Get(render_frame()->GetRenderView())
->OnTestFinishedInSecondaryRenderer();
}
void WebTestRenderFrameObserver::LayoutDumpCompleted(
const std::string& completed_layout_dump) {
BlinkTestRunner::Get(render_frame()->GetRenderView())
->OnLayoutDumpCompleted(completed_layout_dump);
}
void WebTestRenderFrameObserver::ReplyBluetoothManualChooserEvents(
const std::vector<std::string>& events) {
BlinkTestRunner::Get(render_frame()->GetRenderView())
->OnReplyBluetoothManualChooserEvents(events);
}
} // namespace content } // namespace content
...@@ -36,6 +36,12 @@ class WebTestRenderFrameObserver : public RenderFrameObserver, ...@@ -36,6 +36,12 @@ class WebTestRenderFrameObserver : public RenderFrameObserver,
void ReplicateTestConfiguration( void ReplicateTestConfiguration(
mojom::ShellTestConfigurationPtr config) override; mojom::ShellTestConfigurationPtr config) override;
void SetupSecondaryRenderer() override; void SetupSecondaryRenderer() override;
void Reset() override;
void TestFinishedInSecondaryRenderer() override;
void LayoutDumpCompleted(const std::string& completed_layout_dump) override;
void ReplyBluetoothManualChooserEvents(
const std::vector<std::string>& events) override;
void BindReceiver( void BindReceiver(
mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver); mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver);
......
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