Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 2775553002: Adds the ability for WebContentsDelegate to decide if event should be updated (Closed)
Patch Set: Fix compile Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <tuple> 9 #include <tuple>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/test/scoped_feature_list.h" 17 #include "base/test/scoped_feature_list.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "content/browser/gpu/compositor_util.h" 21 #include "content/browser/gpu/compositor_util.h"
22 #include "content/browser/renderer_host/input/input_router_impl.h" 22 #include "content/browser/renderer_host/input/input_router_impl.h"
23 #include "content/browser/renderer_host/render_widget_host_delegate.h" 23 #include "content/browser/renderer_host/render_widget_host_delegate.h"
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" 24 #include "content/browser/renderer_host/render_widget_host_view_base.h"
25 #include "content/common/edit_command.h" 25 #include "content/common/edit_command.h"
26 #include "content/common/input/synthetic_web_input_event_builders.h" 26 #include "content/common/input/synthetic_web_input_event_builders.h"
27 #include "content/common/input_messages.h" 27 #include "content/common/input_messages.h"
28 #include "content/common/resize_params.h" 28 #include "content/common/resize_params.h"
29 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
30 #include "content/public/browser/keyboard_event_processing_result.h"
30 #include "content/public/common/content_features.h" 31 #include "content/public/common/content_features.h"
31 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
32 #include "content/public/test/mock_render_process_host.h" 33 #include "content/public/test/mock_render_process_host.h"
33 #include "content/public/test/test_browser_context.h" 34 #include "content/public/test/test_browser_context.h"
34 #include "content/public/test/test_browser_thread_bundle.h" 35 #include "content/public/test/test_browser_thread_bundle.h"
35 #include "content/test/test_render_view_host.h" 36 #include "content/test/test_render_view_host.h"
36 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
37 #include "ui/display/screen.h" 38 #include "ui/display/screen.h"
38 #include "ui/events/base_event_utils.h" 39 #include "ui/events/base_event_utils.h"
39 #include "ui/events/blink/web_input_event_traits.h" 40 #include "ui/events/blink/web_input_event_traits.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 void SetScreenInfo(const ScreenInfo& screen_info) { 405 void SetScreenInfo(const ScreenInfo& screen_info) {
405 screen_info_ = screen_info; 406 screen_info_ = screen_info;
406 } 407 }
407 408
408 // RenderWidgetHostDelegate overrides. 409 // RenderWidgetHostDelegate overrides.
409 void GetScreenInfo(ScreenInfo* screen_info) override { 410 void GetScreenInfo(ScreenInfo* screen_info) override {
410 *screen_info = screen_info_; 411 *screen_info = screen_info_;
411 } 412 }
412 413
413 protected: 414 protected:
414 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 415 KeyboardEventProcessingResult PreHandleKeyboardEvent(
415 bool* is_keyboard_shortcut) override { 416 const NativeWebKeyboardEvent& event) override {
416 prehandle_keyboard_event_type_ = event.type(); 417 prehandle_keyboard_event_type_ = event.type();
417 prehandle_keyboard_event_called_ = true; 418 prehandle_keyboard_event_called_ = true;
418 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; 419 if (prehandle_keyboard_event_)
419 return prehandle_keyboard_event_; 420 return KeyboardEventProcessingResult::HANDLED;
421 return prehandle_keyboard_event_is_shortcut_
422 ? KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT
423 : KeyboardEventProcessingResult::NOT_HANDLED;
420 } 424 }
421 425
422 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { 426 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
423 unhandled_keyboard_event_type_ = event.type(); 427 unhandled_keyboard_event_type_ = event.type();
424 unhandled_keyboard_event_called_ = true; 428 unhandled_keyboard_event_called_ = true;
425 } 429 }
426 430
427 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { 431 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override {
428 handle_wheel_event_called_ = true; 432 handle_wheel_event_called_ = true;
429 return handle_wheel_event_; 433 return handle_wheel_event_;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 NativeWebKeyboardEvent native_event(type, modifiers, 566 NativeWebKeyboardEvent native_event(type, modifiers,
563 GetNextSimulatedEventTimeSeconds()); 567 GetNextSimulatedEventTimeSeconds());
564 host_->ForwardKeyboardEvent(native_event); 568 host_->ForwardKeyboardEvent(native_event);
565 } 569 }
566 570
567 void SimulateKeyboardEventWithCommands(WebInputEvent::Type type) { 571 void SimulateKeyboardEventWithCommands(WebInputEvent::Type type) {
568 NativeWebKeyboardEvent native_event(type, 0, 572 NativeWebKeyboardEvent native_event(type, 0,
569 GetNextSimulatedEventTimeSeconds()); 573 GetNextSimulatedEventTimeSeconds());
570 EditCommands commands; 574 EditCommands commands;
571 commands.emplace_back("name", "value"); 575 commands.emplace_back("name", "value");
572 host_->ForwardKeyboardEventWithCommands(native_event, &commands); 576 host_->ForwardKeyboardEventWithCommands(native_event, &commands, nullptr);
573 } 577 }
574 578
575 void SimulateMouseEvent(WebInputEvent::Type type) { 579 void SimulateMouseEvent(WebInputEvent::Type type) {
576 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); 580 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type));
577 } 581 }
578 582
579 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, 583 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type,
580 const ui::LatencyInfo& ui_latency) { 584 const ui::LatencyInfo& ui_latency) {
581 host_->ForwardMouseEventWithLatencyInfo( 585 host_->ForwardMouseEventWithLatencyInfo(
582 SyntheticWebMouseEventBuilder::Build(type), 586 SyntheticWebMouseEventBuilder::Build(type),
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 ui::LatencyInfo()); 1827 ui::LatencyInfo());
1824 1828
1825 1829
1826 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). 1830 // Tests RWHI::ForwardWheelEventWithLatencyInfo().
1827 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); 1831 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo());
1828 1832
1829 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1833 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1830 } 1834 }
1831 1835
1832 } // namespace content 1836 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/browser/renderer_host/render_widget_host_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698