| OLD | NEW |
| 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 "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/browser/browser_thread_impl.h" | 17 #include "content/browser/browser_thread_impl.h" |
| 18 #include "content/browser/gpu/compositor_util.h" | 18 #include "content/browser/gpu/compositor_util.h" |
| 19 #include "content/browser/gpu/gpu_surface_tracker.h" | 19 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 20 #include "content/browser/renderer_host/input/input_router_impl.h" | 20 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 21 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 22 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 22 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 23 #include "content/common/input/synthetic_web_input_event_builders.h" | 23 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 24 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
| 25 #include "content/common/resize_params.h" | 25 #include "content/common/resize_params.h" |
| 26 #include "content/common/text_input_state.h" | |
| 27 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 28 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_browser_context.h" | 29 #include "content/public/test/test_browser_context.h" |
| 31 #include "content/test/test_render_view_host.h" | 30 #include "content/test/test_render_view_host.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "ui/events/keycodes/keyboard_codes.h" | 32 #include "ui/events/keycodes/keyboard_codes.h" |
| 34 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 35 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
| 36 | 35 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 public: | 340 public: |
| 342 MockRenderWidgetHostDelegate() | 341 MockRenderWidgetHostDelegate() |
| 343 : prehandle_keyboard_event_(false), | 342 : prehandle_keyboard_event_(false), |
| 344 prehandle_keyboard_event_is_shortcut_(false), | 343 prehandle_keyboard_event_is_shortcut_(false), |
| 345 prehandle_keyboard_event_called_(false), | 344 prehandle_keyboard_event_called_(false), |
| 346 prehandle_keyboard_event_type_(WebInputEvent::Undefined), | 345 prehandle_keyboard_event_type_(WebInputEvent::Undefined), |
| 347 unhandled_keyboard_event_called_(false), | 346 unhandled_keyboard_event_called_(false), |
| 348 unhandled_keyboard_event_type_(WebInputEvent::Undefined), | 347 unhandled_keyboard_event_type_(WebInputEvent::Undefined), |
| 349 handle_wheel_event_(false), | 348 handle_wheel_event_(false), |
| 350 handle_wheel_event_called_(false), | 349 handle_wheel_event_called_(false), |
| 351 unresponsive_timer_fired_(false), | 350 unresponsive_timer_fired_(false) {} |
| 352 text_input_state_(new TextInputState()) {} | |
| 353 ~MockRenderWidgetHostDelegate() override {} | 351 ~MockRenderWidgetHostDelegate() override {} |
| 354 | 352 |
| 355 // Tests that make sure we ignore keyboard event acknowledgments to events we | 353 // Tests that make sure we ignore keyboard event acknowledgments to events we |
| 356 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). | 354 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). |
| 357 bool unhandled_keyboard_event_called() const { | 355 bool unhandled_keyboard_event_called() const { |
| 358 return unhandled_keyboard_event_called_; | 356 return unhandled_keyboard_event_called_; |
| 359 } | 357 } |
| 360 | 358 |
| 361 WebInputEvent::Type unhandled_keyboard_event_type() const { | 359 WebInputEvent::Type unhandled_keyboard_event_type() const { |
| 362 return unhandled_keyboard_event_type_; | 360 return unhandled_keyboard_event_type_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 379 } | 377 } |
| 380 | 378 |
| 381 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) { | 379 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) { |
| 382 prehandle_keyboard_event_is_shortcut_ = is_shortcut; | 380 prehandle_keyboard_event_is_shortcut_ = is_shortcut; |
| 383 } | 381 } |
| 384 | 382 |
| 385 bool handle_wheel_event_called() const { return handle_wheel_event_called_; } | 383 bool handle_wheel_event_called() const { return handle_wheel_event_called_; } |
| 386 | 384 |
| 387 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; } | 385 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; } |
| 388 | 386 |
| 389 const TextInputState* GetTextInputState() override { | |
| 390 return text_input_state_.get(); | |
| 391 } | |
| 392 | |
| 393 protected: | 387 protected: |
| 394 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 388 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 395 bool* is_keyboard_shortcut) override { | 389 bool* is_keyboard_shortcut) override { |
| 396 prehandle_keyboard_event_type_ = event.type; | 390 prehandle_keyboard_event_type_ = event.type; |
| 397 prehandle_keyboard_event_called_ = true; | 391 prehandle_keyboard_event_called_ = true; |
| 398 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; | 392 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; |
| 399 return prehandle_keyboard_event_; | 393 return prehandle_keyboard_event_; |
| 400 } | 394 } |
| 401 | 395 |
| 402 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { | 396 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 424 bool prehandle_keyboard_event_called_; | 418 bool prehandle_keyboard_event_called_; |
| 425 WebInputEvent::Type prehandle_keyboard_event_type_; | 419 WebInputEvent::Type prehandle_keyboard_event_type_; |
| 426 | 420 |
| 427 bool unhandled_keyboard_event_called_; | 421 bool unhandled_keyboard_event_called_; |
| 428 WebInputEvent::Type unhandled_keyboard_event_type_; | 422 WebInputEvent::Type unhandled_keyboard_event_type_; |
| 429 | 423 |
| 430 bool handle_wheel_event_; | 424 bool handle_wheel_event_; |
| 431 bool handle_wheel_event_called_; | 425 bool handle_wheel_event_called_; |
| 432 | 426 |
| 433 bool unresponsive_timer_fired_; | 427 bool unresponsive_timer_fired_; |
| 434 | |
| 435 scoped_ptr<TextInputState> text_input_state_; | |
| 436 }; | 428 }; |
| 437 | 429 |
| 438 // RenderWidgetHostTest -------------------------------------------------------- | 430 // RenderWidgetHostTest -------------------------------------------------------- |
| 439 | 431 |
| 440 class RenderWidgetHostTest : public testing::Test { | 432 class RenderWidgetHostTest : public testing::Test { |
| 441 public: | 433 public: |
| 442 RenderWidgetHostTest() | 434 RenderWidgetHostTest() |
| 443 : process_(NULL), | 435 : process_(NULL), |
| 444 handle_key_press_event_(false), | 436 handle_key_press_event_(false), |
| 445 handle_mouse_event_(false), | 437 handle_mouse_event_(false), |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 ui::LatencyInfo()); | 1672 ui::LatencyInfo()); |
| 1681 | 1673 |
| 1682 | 1674 |
| 1683 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1675 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1684 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1676 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1685 | 1677 |
| 1686 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1678 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1687 } | 1679 } |
| 1688 | 1680 |
| 1689 } // namespace content | 1681 } // namespace content |
| OLD | NEW |