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

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

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

Powered by Google App Engine
This is Rietveld 408576698