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

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

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged Created 4 years, 8 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 "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"
26 #include "content/common/view_messages.h" 27 #include "content/common/view_messages.h"
27 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
28 #include "content/public/test/mock_render_process_host.h" 29 #include "content/public/test/mock_render_process_host.h"
29 #include "content/public/test/test_browser_context.h" 30 #include "content/public/test/test_browser_context.h"
30 #include "content/test/test_render_view_host.h" 31 #include "content/test/test_render_view_host.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "ui/events/keycodes/keyboard_codes.h" 33 #include "ui/events/keycodes/keyboard_codes.h"
33 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
34 #include "ui/gfx/screen.h" 35 #include "ui/gfx/screen.h"
35 36
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 public: 341 public:
341 MockRenderWidgetHostDelegate() 342 MockRenderWidgetHostDelegate()
342 : prehandle_keyboard_event_(false), 343 : prehandle_keyboard_event_(false),
343 prehandle_keyboard_event_is_shortcut_(false), 344 prehandle_keyboard_event_is_shortcut_(false),
344 prehandle_keyboard_event_called_(false), 345 prehandle_keyboard_event_called_(false),
345 prehandle_keyboard_event_type_(WebInputEvent::Undefined), 346 prehandle_keyboard_event_type_(WebInputEvent::Undefined),
346 unhandled_keyboard_event_called_(false), 347 unhandled_keyboard_event_called_(false),
347 unhandled_keyboard_event_type_(WebInputEvent::Undefined), 348 unhandled_keyboard_event_type_(WebInputEvent::Undefined),
348 handle_wheel_event_(false), 349 handle_wheel_event_(false),
349 handle_wheel_event_called_(false), 350 handle_wheel_event_called_(false),
350 unresponsive_timer_fired_(false) {} 351 unresponsive_timer_fired_(false),
352 text_input_state_(new TextInputState()) {}
351 ~MockRenderWidgetHostDelegate() override {} 353 ~MockRenderWidgetHostDelegate() override {}
352 354
353 // Tests that make sure we ignore keyboard event acknowledgments to events we 355 // Tests that make sure we ignore keyboard event acknowledgments to events we
354 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). 356 // didn't send work by making sure we didn't call UnhandledKeyboardEvent().
355 bool unhandled_keyboard_event_called() const { 357 bool unhandled_keyboard_event_called() const {
356 return unhandled_keyboard_event_called_; 358 return unhandled_keyboard_event_called_;
357 } 359 }
358 360
359 WebInputEvent::Type unhandled_keyboard_event_type() const { 361 WebInputEvent::Type unhandled_keyboard_event_type() const {
360 return unhandled_keyboard_event_type_; 362 return unhandled_keyboard_event_type_;
(...skipping 16 matching lines...) Expand all
377 } 379 }
378 380
379 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) { 381 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) {
380 prehandle_keyboard_event_is_shortcut_ = is_shortcut; 382 prehandle_keyboard_event_is_shortcut_ = is_shortcut;
381 } 383 }
382 384
383 bool handle_wheel_event_called() const { return handle_wheel_event_called_; } 385 bool handle_wheel_event_called() const { return handle_wheel_event_called_; }
384 386
385 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; } 387 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; }
386 388
389 const TextInputState* GetTextInputState() override {
390 return text_input_state_.get();
391 }
392
387 protected: 393 protected:
388 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 394 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
389 bool* is_keyboard_shortcut) override { 395 bool* is_keyboard_shortcut) override {
390 prehandle_keyboard_event_type_ = event.type; 396 prehandle_keyboard_event_type_ = event.type;
391 prehandle_keyboard_event_called_ = true; 397 prehandle_keyboard_event_called_ = true;
392 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; 398 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_;
393 return prehandle_keyboard_event_; 399 return prehandle_keyboard_event_;
394 } 400 }
395 401
396 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { 402 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
(...skipping 21 matching lines...) Expand all
418 bool prehandle_keyboard_event_called_; 424 bool prehandle_keyboard_event_called_;
419 WebInputEvent::Type prehandle_keyboard_event_type_; 425 WebInputEvent::Type prehandle_keyboard_event_type_;
420 426
421 bool unhandled_keyboard_event_called_; 427 bool unhandled_keyboard_event_called_;
422 WebInputEvent::Type unhandled_keyboard_event_type_; 428 WebInputEvent::Type unhandled_keyboard_event_type_;
423 429
424 bool handle_wheel_event_; 430 bool handle_wheel_event_;
425 bool handle_wheel_event_called_; 431 bool handle_wheel_event_called_;
426 432
427 bool unresponsive_timer_fired_; 433 bool unresponsive_timer_fired_;
434
435 scoped_ptr<TextInputState> text_input_state_;
428 }; 436 };
429 437
430 // RenderWidgetHostTest -------------------------------------------------------- 438 // RenderWidgetHostTest --------------------------------------------------------
431 439
432 class RenderWidgetHostTest : public testing::Test { 440 class RenderWidgetHostTest : public testing::Test {
433 public: 441 public:
434 RenderWidgetHostTest() 442 RenderWidgetHostTest()
435 : process_(NULL), 443 : process_(NULL),
436 handle_key_press_event_(false), 444 handle_key_press_event_(false),
437 handle_mouse_event_(false), 445 handle_mouse_event_(false),
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 ui::LatencyInfo()); 1680 ui::LatencyInfo());
1673 1681
1674 1682
1675 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). 1683 // Tests RWHI::ForwardWheelEventWithLatencyInfo().
1676 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); 1684 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo());
1677 1685
1678 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1686 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1679 } 1687 }
1680 1688
1681 } // namespace content 1689 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698