Commit 96d5012f authored by johnme's avatar johnme Committed by Commit bot
parent 6e98f5c0
...@@ -178,7 +178,7 @@ void WebTestDelegateImpl::SetDatabaseQuota(int quota) { ...@@ -178,7 +178,7 @@ void WebTestDelegateImpl::SetDatabaseQuota(int quota) {
} }
void WebTestDelegateImpl::SimulateWebNotificationClick( void WebTestDelegateImpl::SimulateWebNotificationClick(
const std::string& title) { const std::string& title, int action_index) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -65,7 +65,8 @@ class WebTestDelegateImpl : public test_runner::WebTestDelegate { ...@@ -65,7 +65,8 @@ class WebTestDelegateImpl : public test_runner::WebTestDelegate {
void EvaluateInWebInspector(long call_id, const std::string& script) override; void EvaluateInWebInspector(long call_id, const std::string& script) override;
void ClearAllDatabases() override; void ClearAllDatabases() override;
void SetDatabaseQuota(int quota) override; void SetDatabaseQuota(int quota) override;
void SimulateWebNotificationClick(const std::string& title) override; void SimulateWebNotificationClick(const std::string& title,
int action_index) override;
void SetDeviceScaleFactor(float factor) override; void SetDeviceScaleFactor(float factor) override;
void SetDeviceColorProfile(const std::string& name) override; void SetDeviceColorProfile(const std::string& name) override;
void SetBluetoothMockDataSet(const std::string& data_set) override; void SetBluetoothMockDataSet(const std::string& data_set) override;
......
...@@ -273,7 +273,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> { ...@@ -273,7 +273,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
v8::Local<v8::Function> callback); v8::Local<v8::Function> callback);
void SetPOSIXLocale(const std::string& locale); void SetPOSIXLocale(const std::string& locale);
void SetMIDIAccessorResult(bool result); void SetMIDIAccessorResult(bool result);
void SimulateWebNotificationClick(const std::string& title); void SimulateWebNotificationClick(gin::Arguments* args);
void AddMockSpeechRecognitionResult(const std::string& transcript, void AddMockSpeechRecognitionResult(const std::string& transcript,
double confidence); double confidence);
void SetMockSpeechRecognitionError(const std::string& error, void SetMockSpeechRecognitionError(const std::string& error,
...@@ -1343,10 +1343,16 @@ void TestRunnerBindings::SetMIDIAccessorResult(bool result) { ...@@ -1343,10 +1343,16 @@ void TestRunnerBindings::SetMIDIAccessorResult(bool result) {
runner_->SetMIDIAccessorResult(result); runner_->SetMIDIAccessorResult(result);
} }
void TestRunnerBindings::SimulateWebNotificationClick( void TestRunnerBindings::SimulateWebNotificationClick(gin::Arguments* args) {
const std::string& title) { if (!runner_)
if (runner_) return;
runner_->SimulateWebNotificationClick(title); std::string title;
int action_index = -1;
if (args->GetNext(&title) &&
(args->PeekNext().IsEmpty() || args->GetNext(&action_index)))
runner_->SimulateWebNotificationClick(title, action_index);
else
args->ThrowError();
} }
void TestRunnerBindings::AddMockSpeechRecognitionResult( void TestRunnerBindings::AddMockSpeechRecognitionResult(
...@@ -2854,8 +2860,9 @@ void TestRunner::SetMIDIAccessorResult(bool result) { ...@@ -2854,8 +2860,9 @@ void TestRunner::SetMIDIAccessorResult(bool result) {
midi_accessor_result_ = result; midi_accessor_result_ = result;
} }
void TestRunner::SimulateWebNotificationClick(const std::string& title) { void TestRunner::SimulateWebNotificationClick(const std::string& title,
delegate_->SimulateWebNotificationClick(title); int action_index) {
delegate_->SimulateWebNotificationClick(title, action_index);
} }
void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript,
......
...@@ -560,7 +560,7 @@ class TestRunner : public WebTestRunner, ...@@ -560,7 +560,7 @@ class TestRunner : public WebTestRunner,
void SetMIDIAccessorResult(bool result); void SetMIDIAccessorResult(bool result);
// Simulates a click on a Web Notification. // Simulates a click on a Web Notification.
void SimulateWebNotificationClick(const std::string& title); void SimulateWebNotificationClick(const std::string& title, int action_index);
// Speech recognition related functions. // Speech recognition related functions.
void AddMockSpeechRecognitionResult(const std::string& transcript, void AddMockSpeechRecognitionResult(const std::string& transcript,
......
...@@ -149,7 +149,8 @@ class WebTestDelegate { ...@@ -149,7 +149,8 @@ class WebTestDelegate {
virtual void SetDatabaseQuota(int quota) = 0; virtual void SetDatabaseQuota(int quota) = 0;
// Controls Web Notifications. // Controls Web Notifications.
virtual void SimulateWebNotificationClick(const std::string& title) = 0; virtual void SimulateWebNotificationClick(const std::string& title,
int action_index) = 0;
// Controls the device scale factor of the main WebView for hidpi tests. // Controls the device scale factor of the main WebView for hidpi tests.
virtual void SetDeviceScaleFactor(float factor) = 0; virtual void SetDeviceScaleFactor(float factor) = 0;
......
...@@ -112,11 +112,11 @@ void LayoutTestMessageFilter::OnSetDatabaseQuota(int quota) { ...@@ -112,11 +112,11 @@ void LayoutTestMessageFilter::OnSetDatabaseQuota(int quota) {
} }
void LayoutTestMessageFilter::OnSimulateWebNotificationClick( void LayoutTestMessageFilter::OnSimulateWebNotificationClick(
const std::string& title) { const std::string& title, int action_index) {
LayoutTestNotificationManager* manager = LayoutTestNotificationManager* manager =
LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager(); LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
if (manager) if (manager)
manager->SimulateClick(title); manager->SimulateClick(title, action_index);
} }
void LayoutTestMessageFilter::OnAcceptAllCookies(bool accept) { void LayoutTestMessageFilter::OnAcceptAllCookies(bool accept) {
......
...@@ -54,7 +54,8 @@ class LayoutTestMessageFilter : public BrowserMessageFilter { ...@@ -54,7 +54,8 @@ class LayoutTestMessageFilter : public BrowserMessageFilter {
void OnGrantWebNotificationPermission(const GURL& origin, void OnGrantWebNotificationPermission(const GURL& origin,
bool permission_granted); bool permission_granted);
void OnClearWebNotificationPermissions(); void OnClearWebNotificationPermissions();
void OnSimulateWebNotificationClick(const std::string& title); void OnSimulateWebNotificationClick(const std::string& title,
int action_index);
void OnSetPushMessagingPermission(const GURL& origin, bool allowed); void OnSetPushMessagingPermission(const GURL& origin, bool allowed);
void OnClearPushMessagingPermissions(); void OnClearPushMessagingPermissions();
void OnAcceptAllCookies(bool accept); void OnAcceptAllCookies(bool accept);
......
...@@ -106,12 +106,14 @@ bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications( ...@@ -106,12 +106,14 @@ bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications(
return false; return false;
} }
void LayoutTestNotificationManager::SimulateClick(const std::string& title) { void LayoutTestNotificationManager::SimulateClick(const std::string& title,
int action_index) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// First check for page-notifications with the given title. // First check for page-notifications with the given title.
const auto& page_iterator = page_notifications_.find(title); const auto& page_iterator = page_notifications_.find(title);
if (page_iterator != page_notifications_.end()) { if (page_iterator != page_notifications_.end()) {
// TODO(johnme): Pass action_index once it's supported.
page_iterator->second->NotificationClick(); page_iterator->second->NotificationClick();
return; return;
} }
...@@ -127,7 +129,7 @@ void LayoutTestNotificationManager::SimulateClick(const std::string& title) { ...@@ -127,7 +129,7 @@ void LayoutTestNotificationManager::SimulateClick(const std::string& title) {
notification.browser_context, notification.browser_context,
notification.persistent_id, notification.persistent_id,
notification.origin, notification.origin,
-1 /* action_index */, action_index,
base::Bind(&OnEventDispatchComplete)); base::Bind(&OnEventDispatchComplete));
} }
......
...@@ -27,9 +27,10 @@ class LayoutTestNotificationManager : public PlatformNotificationService { ...@@ -27,9 +27,10 @@ class LayoutTestNotificationManager : public PlatformNotificationService {
LayoutTestNotificationManager(); LayoutTestNotificationManager();
~LayoutTestNotificationManager() override; ~LayoutTestNotificationManager() override;
// Simulates a click on the notification titled |title|. Must be called on the // Simulates a click on the notification titled |title|. |action_index|
// UI thread. // indicates which action was clicked, or -1 if the main notification body was
void SimulateClick(const std::string& title); // clicked. Must be called on the UI thread.
void SimulateClick(const std::string& title, int action_index);
// PlatformNotificationService implementation. // PlatformNotificationService implementation.
blink::WebNotificationPermission CheckPermissionOnUIThread( blink::WebNotificationPermission CheckPermissionOnUIThread(
......
...@@ -27,8 +27,9 @@ IPC_SYNC_MESSAGE_ROUTED1_1(LayoutTestHostMsg_RegisterIsolatedFileSystem, ...@@ -27,8 +27,9 @@ IPC_SYNC_MESSAGE_ROUTED1_1(LayoutTestHostMsg_RegisterIsolatedFileSystem,
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_ClearAllDatabases) IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_ClearAllDatabases)
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_SetDatabaseQuota, IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_SetDatabaseQuota,
int /* quota */) int /* quota */)
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_SimulateWebNotificationClick, IPC_MESSAGE_ROUTED2(LayoutTestHostMsg_SimulateWebNotificationClick,
std::string /* title */) std::string /* title */,
int /* action_index */)
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_AcceptAllCookies, IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_AcceptAllCookies,
bool /* accept */) bool /* accept */)
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_DeleteAllCookies) IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_DeleteAllCookies)
......
...@@ -459,8 +459,10 @@ void BlinkTestRunner::SetDatabaseQuota(int quota) { ...@@ -459,8 +459,10 @@ void BlinkTestRunner::SetDatabaseQuota(int quota) {
Send(new LayoutTestHostMsg_SetDatabaseQuota(routing_id(), quota)); Send(new LayoutTestHostMsg_SetDatabaseQuota(routing_id(), quota));
} }
void BlinkTestRunner::SimulateWebNotificationClick(const std::string& title) { void BlinkTestRunner::SimulateWebNotificationClick(const std::string& title,
Send(new LayoutTestHostMsg_SimulateWebNotificationClick(routing_id(), title)); int action_index) {
Send(new LayoutTestHostMsg_SimulateWebNotificationClick(routing_id(), title,
action_index));
} }
void BlinkTestRunner::SetDeviceScaleFactor(float factor) { void BlinkTestRunner::SetDeviceScaleFactor(float factor) {
......
...@@ -91,7 +91,8 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -91,7 +91,8 @@ class BlinkTestRunner : public RenderViewObserver,
void EvaluateInWebInspector(long call_id, const std::string& script) override; void EvaluateInWebInspector(long call_id, const std::string& script) override;
void ClearAllDatabases() override; void ClearAllDatabases() override;
void SetDatabaseQuota(int quota) override; void SetDatabaseQuota(int quota) override;
void SimulateWebNotificationClick(const std::string& title) override; void SimulateWebNotificationClick(const std::string& title,
int action_index) override;
void SetDeviceScaleFactor(float factor) override; void SetDeviceScaleFactor(float factor) override;
void SetDeviceColorProfile(const std::string& name) override; void SetDeviceColorProfile(const std::string& name) override;
void SetBluetoothMockDataSet(const std::string& name) override; void SetBluetoothMockDataSet(const std::string& name) override;
......
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