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

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

Issue 283623002: Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for Web… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | ipc/ipc_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "content/common/input/synthetic_web_input_event_builders.h" 9 #include "content/common/input/synthetic_web_input_event_builders.h"
10 #include "content/common/input_messages.h" 10 #include "content/common/input_messages.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 private: 70 private:
71 std::vector<gfx::Rect> rects_; 71 std::vector<gfx::Rect> rects_;
72 IPC::TestSink sink_; 72 IPC::TestSink sink_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(TouchableRenderWidget); 74 DISALLOW_COPY_AND_ASSIGN(TouchableRenderWidget);
75 }; 75 };
76 76
77 TEST_F(RenderWidgetUnittest, TouchHitTestSinglePoint) { 77 TEST_F(RenderWidgetUnittest, TouchHitTestSinglePoint) {
78 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget(); 78 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget();
79 79
80 blink::WebInputEvent::Type type;
81 InputEventAckState ack_state;
82 ui::LatencyInfo latency;
83
84 SyntheticWebTouchEvent touch; 80 SyntheticWebTouchEvent touch;
85 touch.PressPoint(10, 10); 81 touch.PressPoint(10, 10);
86 82
87 widget->SendInputEvent(touch); 83 widget->SendInputEvent(touch);
88 ASSERT_EQ(1u, widget->sink()->message_count()); 84 ASSERT_EQ(1u, widget->sink()->message_count());
89 85
90 // Since there's currently no touch-event handling region, the response should 86 // Since there's currently no touch-event handling region, the response should
91 // be 'no consumer exists'. 87 // be 'no consumer exists'.
92 const IPC::Message* message = widget->sink()->GetMessageAt(0); 88 const IPC::Message* message = widget->sink()->GetMessageAt(0);
93 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); 89 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type());
94 InputHostMsg_HandleInputEvent_ACK::Read(message, &type, &ack_state, &latency); 90 InputHostMsg_HandleInputEvent_ACK::Param params;
91 InputHostMsg_HandleInputEvent_ACK::Read(message, &params);
92 InputEventAckState ack_state = params.b;
95 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); 93 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state);
96 widget->sink()->ClearMessages(); 94 widget->sink()->ClearMessages();
97 95
98 std::vector<gfx::Rect> rects; 96 std::vector<gfx::Rect> rects;
99 rects.push_back(gfx::Rect(0, 0, 20, 20)); 97 rects.push_back(gfx::Rect(0, 0, 20, 20));
100 rects.push_back(gfx::Rect(25, 0, 10, 10)); 98 rects.push_back(gfx::Rect(25, 0, 10, 10));
101 widget->SetTouchRegion(rects); 99 widget->SetTouchRegion(rects);
102 100
103 widget->SendInputEvent(touch); 101 widget->SendInputEvent(touch);
104 ASSERT_EQ(1u, widget->sink()->message_count()); 102 ASSERT_EQ(1u, widget->sink()->message_count());
105 message = widget->sink()->GetMessageAt(0); 103 message = widget->sink()->GetMessageAt(0);
106 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); 104 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type());
107 InputHostMsg_HandleInputEvent_ACK::Read(message, &type, &ack_state, &latency); 105 InputHostMsg_HandleInputEvent_ACK::Read(message, &params);
106 ack_state = params.b;
108 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); 107 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state);
109 widget->sink()->ClearMessages(); 108 widget->sink()->ClearMessages();
110 } 109 }
111 110
112 TEST_F(RenderWidgetUnittest, TouchHitTestMultiplePoints) { 111 TEST_F(RenderWidgetUnittest, TouchHitTestMultiplePoints) {
113 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget(); 112 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget();
114 std::vector<gfx::Rect> rects; 113 std::vector<gfx::Rect> rects;
115 rects.push_back(gfx::Rect(0, 0, 20, 20)); 114 rects.push_back(gfx::Rect(0, 0, 20, 20));
116 rects.push_back(gfx::Rect(25, 0, 10, 10)); 115 rects.push_back(gfx::Rect(25, 0, 10, 10));
117 widget->SetTouchRegion(rects); 116 widget->SetTouchRegion(rects);
118 117
119 blink::WebInputEvent::Type type;
120 InputEventAckState ack_state;
121 ui::LatencyInfo latency;
122
123 SyntheticWebTouchEvent touch; 118 SyntheticWebTouchEvent touch;
124 touch.PressPoint(25, 25); 119 touch.PressPoint(25, 25);
125 120
126 widget->SendInputEvent(touch); 121 widget->SendInputEvent(touch);
127 ASSERT_EQ(1u, widget->sink()->message_count()); 122 ASSERT_EQ(1u, widget->sink()->message_count());
128 123
129 // Since there's currently no touch-event handling region, the response should 124 // Since there's currently no touch-event handling region, the response should
130 // be 'no consumer exists'. 125 // be 'no consumer exists'.
131 const IPC::Message* message = widget->sink()->GetMessageAt(0); 126 const IPC::Message* message = widget->sink()->GetMessageAt(0);
132 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); 127 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type());
133 InputHostMsg_HandleInputEvent_ACK::Read(message, &type, &ack_state, &latency); 128 InputHostMsg_HandleInputEvent_ACK::Param params;
129 InputHostMsg_HandleInputEvent_ACK::Read(message, &params);
130 InputEventAckState ack_state = params.b;
134 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); 131 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state);
135 widget->sink()->ClearMessages(); 132 widget->sink()->ClearMessages();
136 133
137 // Press a second touch point. This time, on a touch-handling region. 134 // Press a second touch point. This time, on a touch-handling region.
138 touch.PressPoint(10, 10); 135 touch.PressPoint(10, 10);
139 widget->SendInputEvent(touch); 136 widget->SendInputEvent(touch);
140 ASSERT_EQ(1u, widget->sink()->message_count()); 137 ASSERT_EQ(1u, widget->sink()->message_count());
141 message = widget->sink()->GetMessageAt(0); 138 message = widget->sink()->GetMessageAt(0);
142 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); 139 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type());
143 InputHostMsg_HandleInputEvent_ACK::Read(message, &type, &ack_state, &latency); 140 InputHostMsg_HandleInputEvent_ACK::Read(message, &params);
141 ack_state = params.b;
144 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); 142 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state);
145 widget->sink()->ClearMessages(); 143 widget->sink()->ClearMessages();
146 } 144 }
147 145
148 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | ipc/ipc_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698