Commit f186ec6b authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Convert WebTestHostMsg_SimulateWebNotificationClick to Mojo

This CL migrates the legacy SetPermission IPC message
to the new Mojo defined in WebTestClient interface.

Mojo doesn't support base::Optional<int>. So, this CL passes
a value if it exists. It the value doesn't exist, a minimum
integer value is passed instead. Then, the handler function sets
the passed value to base::Optional<> again.

Bug: 1039247
Change-Id: I75850e1d642812c7e930a38e317b3eccda51e8ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2045270
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741092}
parent 8495f49a
...@@ -89,6 +89,19 @@ void WebTestClientImpl::TestFinishedInSecondaryRenderer() { ...@@ -89,6 +89,19 @@ void WebTestClientImpl::TestFinishedInSecondaryRenderer() {
BlinkTestController::Get()->OnTestFinishedInSecondaryRenderer(); BlinkTestController::Get()->OnTestFinishedInSecondaryRenderer();
} }
void WebTestClientImpl::SimulateWebNotificationClick(
const std::string& title,
int32_t action_index,
const base::Optional<base::string16>& reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GetMockPlatformNotificationService()->SimulateClick(
title,
action_index == std::numeric_limits<int32_t>::min()
? base::Optional<int>()
: base::Optional<int>(action_index),
reply);
}
void WebTestClientImpl::SimulateWebNotificationClose(const std::string& title, void WebTestClientImpl::SimulateWebNotificationClose(const std::string& title,
bool by_user) { bool by_user) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
...@@ -42,6 +42,10 @@ class WebTestClientImpl : public mojom::WebTestClient { ...@@ -42,6 +42,10 @@ class WebTestClientImpl : public mojom::WebTestClient {
// WebTestClient implementation. // WebTestClient implementation.
void InspectSecondaryWindow() override; void InspectSecondaryWindow() override;
void TestFinishedInSecondaryRenderer() override; void TestFinishedInSecondaryRenderer() override;
void SimulateWebNotificationClick(
const std::string& title,
int32_t action_index,
const base::Optional<base::string16>& reply) override;
void SimulateWebNotificationClose(const std::string& title, void SimulateWebNotificationClose(const std::string& title,
bool by_user) override; bool by_user) override;
void SimulateWebContentIndexDelete(const std::string& id) override; void SimulateWebContentIndexDelete(const std::string& id) override;
......
...@@ -35,18 +35,6 @@ ...@@ -35,18 +35,6 @@
namespace content { namespace content {
namespace {
MockPlatformNotificationService* GetMockPlatformNotificationService() {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
auto* service = client->GetPlatformNotificationService(context);
return static_cast<MockPlatformNotificationService*>(service);
}
} // namespace
WebTestMessageFilter::WebTestMessageFilter( WebTestMessageFilter::WebTestMessageFilter(
int render_process_id, int render_process_id,
storage::DatabaseTracker* database_tracker, storage::DatabaseTracker* database_tracker,
...@@ -70,7 +58,6 @@ WebTestMessageFilter::OverrideTaskRunnerForMessage( ...@@ -70,7 +58,6 @@ WebTestMessageFilter::OverrideTaskRunnerForMessage(
switch (message.type()) { switch (message.type()) {
case WebTestHostMsg_ClearAllDatabases::ID: case WebTestHostMsg_ClearAllDatabases::ID:
return database_tracker_->task_runner(); return database_tracker_->task_runner();
case WebTestHostMsg_SimulateWebNotificationClick::ID:
case WebTestHostMsg_InitiateCaptureDump::ID: case WebTestHostMsg_InitiateCaptureDump::ID:
return base::CreateSingleThreadTaskRunner({BrowserThread::UI}); return base::CreateSingleThreadTaskRunner({BrowserThread::UI});
} }
...@@ -82,8 +69,6 @@ bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) { ...@@ -82,8 +69,6 @@ bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(WebTestMessageFilter, message) IPC_BEGIN_MESSAGE_MAP(WebTestMessageFilter, message)
IPC_MESSAGE_HANDLER(WebTestHostMsg_ClearAllDatabases, OnClearAllDatabases) IPC_MESSAGE_HANDLER(WebTestHostMsg_ClearAllDatabases, OnClearAllDatabases)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SetDatabaseQuota, OnSetDatabaseQuota) IPC_MESSAGE_HANDLER(WebTestHostMsg_SetDatabaseQuota, OnSetDatabaseQuota)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SimulateWebNotificationClick,
OnSimulateWebNotificationClick)
IPC_MESSAGE_HANDLER(WebTestHostMsg_InitiateCaptureDump, IPC_MESSAGE_HANDLER(WebTestHostMsg_InitiateCaptureDump,
OnInitiateCaptureDump) OnInitiateCaptureDump)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
...@@ -111,15 +96,6 @@ void WebTestMessageFilter::OnSetDatabaseQuota(int quota) { ...@@ -111,15 +96,6 @@ void WebTestMessageFilter::OnSetDatabaseQuota(int quota) {
} }
} }
void WebTestMessageFilter::OnSimulateWebNotificationClick(
const std::string& title,
const base::Optional<int>& action_index,
const base::Optional<base::string16>& reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GetMockPlatformNotificationService()->SimulateClick(title, action_index,
reply);
}
void WebTestMessageFilter::OnInitiateCaptureDump( void WebTestMessageFilter::OnInitiateCaptureDump(
bool capture_navigation_history, bool capture_navigation_history,
bool capture_pixels) { bool capture_pixels) {
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -44,10 +42,6 @@ class WebTestMessageFilter : public BrowserMessageFilter { ...@@ -44,10 +42,6 @@ class WebTestMessageFilter : public BrowserMessageFilter {
void OnClearAllDatabases(); void OnClearAllDatabases();
void OnSetDatabaseQuota(int quota); void OnSetDatabaseQuota(int quota);
void OnSimulateWebNotificationClick(
const std::string& title,
const base::Optional<int>& action_index,
const base::Optional<base::string16>& reply);
void OnInitiateCaptureDump(bool capture_navigation_history, void OnInitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels); bool capture_pixels);
void OnSetFilePathForMockFileDialog(const base::FilePath& path); void OnSetFilePathForMockFileDialog(const base::FilePath& path);
......
...@@ -6,6 +6,7 @@ module content.mojom; ...@@ -6,6 +6,7 @@ module content.mojom;
import "mojo/public/mojom/base/file_path.mojom"; import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/values.mojom"; import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "third_party/blink/public/mojom/permissions/permission_status.mojom"; import "third_party/blink/public/mojom/permissions/permission_status.mojom";
import "url/mojom/url.mojom"; import "url/mojom/url.mojom";
...@@ -17,8 +18,12 @@ interface WebTestClient { ...@@ -17,8 +18,12 @@ interface WebTestClient {
// Sent by secondary test window to notify the test has finished. // Sent by secondary test window to notify the test has finished.
TestFinishedInSecondaryRenderer(); TestFinishedInSecondaryRenderer();
// Simulates a user deleting a content index entry. // Simulates a click on the notification.
SimulateWebContentIndexDelete(string id); // - |title|: the title of the notification.
// - |action_index|: indicates which action was clicked.
// - |reply|: indicates the user reply.
SimulateWebNotificationClick(
string title, int32 action_index, mojo_base.mojom.String16? reply);
// Simulates closing a titled web notification depending on the user // Simulates closing a titled web notification depending on the user
// click. // click.
...@@ -26,6 +31,9 @@ interface WebTestClient { ...@@ -26,6 +31,9 @@ interface WebTestClient {
// - |by_user|: whether the user clicks the notification. // - |by_user|: whether the user clicks the notification.
SimulateWebNotificationClose(string title, bool by_user); SimulateWebNotificationClose(string title, bool by_user);
// Simulates a user deleting a content index entry.
SimulateWebContentIndexDelete(string id);
// Sets the cookie policy to: // Sets the cookie policy to:
// - allow all cookies when |block| is false // - allow all cookies when |block| is false
// - block only third-party cookies when |block| is true // - block only third-party cookies when |block| is true
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/optional.h"
#include "base/strings/string16.h"
#include "content/public/common/common_param_traits_macros.h" #include "content/public/common/common_param_traits_macros.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
...@@ -21,10 +19,6 @@ ...@@ -21,10 +19,6 @@
IPC_MESSAGE_ROUTED0(WebTestHostMsg_ClearAllDatabases) IPC_MESSAGE_ROUTED0(WebTestHostMsg_ClearAllDatabases)
IPC_MESSAGE_ROUTED1(WebTestHostMsg_SetDatabaseQuota, int /* quota */) IPC_MESSAGE_ROUTED1(WebTestHostMsg_SetDatabaseQuota, int /* quota */)
IPC_MESSAGE_ROUTED3(WebTestHostMsg_SimulateWebNotificationClick,
std::string /* title */,
base::Optional<int> /* action_index */,
base::Optional<base::string16> /* reply */)
IPC_MESSAGE_ROUTED2(WebTestHostMsg_InitiateCaptureDump, IPC_MESSAGE_ROUTED2(WebTestHostMsg_InitiateCaptureDump,
bool /* should dump navigation history */, bool /* should dump navigation history */,
bool /* should dump pixels */) bool /* should dump pixels */)
......
...@@ -290,8 +290,8 @@ void BlinkTestRunner::SimulateWebNotificationClick( ...@@ -290,8 +290,8 @@ void BlinkTestRunner::SimulateWebNotificationClick(
const std::string& title, const std::string& title,
const base::Optional<int>& action_index, const base::Optional<int>& action_index,
const base::Optional<base::string16>& reply) { const base::Optional<base::string16>& reply) {
Send(new WebTestHostMsg_SimulateWebNotificationClick(routing_id(), title, GetWebTestClientRemote().SimulateWebNotificationClick(
action_index, reply)); title, action_index.value_or(std::numeric_limits<int32_t>::min()), reply);
} }
void BlinkTestRunner::SimulateWebNotificationClose(const std::string& title, void BlinkTestRunner::SimulateWebNotificationClose(const std::string& title,
......
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