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

Side by Side Diff: content/renderer/render_widget_unittest.cc

Issue 2621303004: Keep track of coalesced events in main thread event queue (Closed)
Patch Set: Rebase Created 3 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/test/histogram_tester.h" 11 #include "base/test/histogram_tester.h"
12 #include "content/common/input/synthetic_web_input_event_builders.h" 12 #include "content/common/input/synthetic_web_input_event_builders.h"
13 #include "content/common/input_messages.h" 13 #include "content/common/input_messages.h"
14 #include "content/common/resize_params.h" 14 #include "content/common/resize_params.h"
15 #include "content/public/test/mock_render_thread.h" 15 #include "content/public/test/mock_render_thread.h"
16 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" 16 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h"
17 #include "content/test/fake_compositor_dependencies.h" 17 #include "content/test/fake_compositor_dependencies.h"
18 #include "content/test/mock_render_process.h" 18 #include "content/test/mock_render_process.h"
19 #include "ipc/ipc_test_sink.h" 19 #include "ipc/ipc_test_sink.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "third_party/WebKit/public/platform/WebInputEvent.h" 22 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h"
23 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 23 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
24 #include "ui/events/base_event_utils.h" 24 #include "ui/events/base_event_utils.h"
25 #include "ui/events/blink/web_input_event_traits.h" 25 #include "ui/events/blink/web_input_event_traits.h"
26 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
27 27
28 using testing::_; 28 using testing::_;
29 29
30 namespace content { 30 namespace content {
31 31
32 namespace { 32 namespace {
33 33
34 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; 34 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners";
35 35
36 // Keep in sync with enum defined in 36 // Keep in sync with enum defined in
37 // RenderWidgetInputHandler::LogPassiveEventListenersUma. 37 // RenderWidgetInputHandler::LogPassiveEventListenersUma.
38 enum { 38 enum {
39 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 39 PASSIVE_LISTENER_UMA_ENUM_PASSIVE,
40 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 40 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
41 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 41 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED,
42 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 42 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE,
43 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 43 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED,
44 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 44 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING,
45 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIVENES S, 45 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIVENES S,
46 PASSIVE_LISTENER_UMA_ENUM_COUNT 46 PASSIVE_LISTENER_UMA_ENUM_COUNT
47 }; 47 };
48 48
49 class MockWebWidget : public blink::WebWidget { 49 class MockWebWidget : public blink::WebWidget {
50 public: 50 public:
51 MOCK_METHOD1(handleInputEvent, 51 MOCK_METHOD1(
52 blink::WebInputEventResult(const blink::WebInputEvent&)); 52 handleInputEvent,
53 blink::WebInputEventResult(const blink::WebCoalescedInputEvent&));
53 }; 54 };
54 55
55 } // namespace 56 } // namespace
56 57
57 class InteractiveRenderWidget : public RenderWidget { 58 class InteractiveRenderWidget : public RenderWidget {
58 public: 59 public:
59 explicit InteractiveRenderWidget(CompositorDependencies* compositor_deps) 60 explicit InteractiveRenderWidget(CompositorDependencies* compositor_deps)
60 : RenderWidget(++next_routing_id_, 61 : RenderWidget(++next_routing_id_,
61 compositor_deps, 62 compositor_deps,
62 blink::WebPopupTypeNone, 63 blink::WebPopupTypeNone,
63 ScreenInfo(), 64 ScreenInfo(),
64 false, 65 false,
65 false, 66 false,
66 false), 67 false),
67 always_overscroll_(false) { 68 always_overscroll_(false) {
68 Init(RenderWidget::ShowCallback(), mock_webwidget()); 69 Init(RenderWidget::ShowCallback(), mock_webwidget());
69 } 70 }
70 71
71 void SetTouchRegion(const std::vector<gfx::Rect>& rects) { 72 void SetTouchRegion(const std::vector<gfx::Rect>& rects) {
72 rects_ = rects; 73 rects_ = rects;
73 } 74 }
74 75
75 void SendInputEvent(const blink::WebInputEvent& event) { 76 void SendInputEvent(const blink::WebInputEvent& event) {
76 OnHandleInputEvent( 77 OnHandleInputEvent(
77 &event, ui::LatencyInfo(), 78 &event, std::vector<const blink::WebInputEvent*>(), ui::LatencyInfo(),
78 ui::WebInputEventTraits::ShouldBlockEventStream(event) 79 ui::WebInputEventTraits::ShouldBlockEventStream(event)
79 ? InputEventDispatchType::DISPATCH_TYPE_BLOCKING 80 ? InputEventDispatchType::DISPATCH_TYPE_BLOCKING
80 : InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING); 81 : InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING);
81 } 82 }
82 83
83 void set_always_overscroll(bool overscroll) { 84 void set_always_overscroll(bool overscroll) {
84 always_overscroll_ = overscroll; 85 always_overscroll_ = overscroll;
85 } 86 }
86 87
87 IPC::TestSink* sink() { return &sink_; } 88 IPC::TestSink* sink() { return &sink_; }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 blink::WebRect popup_emulated_rect(130, 170, 100, 400); 523 blink::WebRect popup_emulated_rect(130, 170, 100, 400);
523 widget()->setWindowRect(popup_emulated_rect); 524 widget()->setWindowRect(popup_emulated_rect);
524 525
525 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); 526 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x);
526 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); 527 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y);
527 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); 528 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x);
528 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); 529 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y);
529 } 530 }
530 531
531 } // namespace content 532 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698