OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 widget->SendInputEvent(touch); | 83 widget->SendInputEvent(touch); |
84 ASSERT_EQ(1u, widget->sink()->message_count()); | 84 ASSERT_EQ(1u, widget->sink()->message_count()); |
85 | 85 |
86 // 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 |
87 // be 'no consumer exists'. | 87 // be 'no consumer exists'. |
88 const IPC::Message* message = widget->sink()->GetMessageAt(0); | 88 const IPC::Message* message = widget->sink()->GetMessageAt(0); |
89 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 89 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
90 InputHostMsg_HandleInputEvent_ACK::Param params; | 90 InputHostMsg_HandleInputEvent_ACK::Param params; |
91 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); | 91 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); |
92 InputEventAckState ack_state = params.b; | 92 InputEventAckState ack_state = params.a.state; |
93 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); | 93 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); |
94 widget->sink()->ClearMessages(); | 94 widget->sink()->ClearMessages(); |
95 | 95 |
96 std::vector<gfx::Rect> rects; | 96 std::vector<gfx::Rect> rects; |
97 rects.push_back(gfx::Rect(0, 0, 20, 20)); | 97 rects.push_back(gfx::Rect(0, 0, 20, 20)); |
98 rects.push_back(gfx::Rect(25, 0, 10, 10)); | 98 rects.push_back(gfx::Rect(25, 0, 10, 10)); |
99 widget->SetTouchRegion(rects); | 99 widget->SetTouchRegion(rects); |
100 | 100 |
101 widget->SendInputEvent(touch); | 101 widget->SendInputEvent(touch); |
102 ASSERT_EQ(1u, widget->sink()->message_count()); | 102 ASSERT_EQ(1u, widget->sink()->message_count()); |
103 message = widget->sink()->GetMessageAt(0); | 103 message = widget->sink()->GetMessageAt(0); |
104 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 104 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
105 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); | 105 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); |
106 ack_state = params.b; | 106 ack_state = params.a.state; |
107 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); | 107 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); |
108 widget->sink()->ClearMessages(); | 108 widget->sink()->ClearMessages(); |
109 } | 109 } |
110 | 110 |
111 TEST_F(RenderWidgetUnittest, TouchHitTestMultiplePoints) { | 111 TEST_F(RenderWidgetUnittest, TouchHitTestMultiplePoints) { |
112 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget(); | 112 scoped_refptr<TouchableRenderWidget> widget = new TouchableRenderWidget(); |
113 std::vector<gfx::Rect> rects; | 113 std::vector<gfx::Rect> rects; |
114 rects.push_back(gfx::Rect(0, 0, 20, 20)); | 114 rects.push_back(gfx::Rect(0, 0, 20, 20)); |
115 rects.push_back(gfx::Rect(25, 0, 10, 10)); | 115 rects.push_back(gfx::Rect(25, 0, 10, 10)); |
116 widget->SetTouchRegion(rects); | 116 widget->SetTouchRegion(rects); |
117 | 117 |
118 SyntheticWebTouchEvent touch; | 118 SyntheticWebTouchEvent touch; |
119 touch.PressPoint(25, 25); | 119 touch.PressPoint(25, 25); |
120 | 120 |
121 widget->SendInputEvent(touch); | 121 widget->SendInputEvent(touch); |
122 ASSERT_EQ(1u, widget->sink()->message_count()); | 122 ASSERT_EQ(1u, widget->sink()->message_count()); |
123 | 123 |
124 // 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 |
125 // be 'no consumer exists'. | 125 // be 'no consumer exists'. |
126 const IPC::Message* message = widget->sink()->GetMessageAt(0); | 126 const IPC::Message* message = widget->sink()->GetMessageAt(0); |
127 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 127 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
128 InputHostMsg_HandleInputEvent_ACK::Param params; | 128 InputHostMsg_HandleInputEvent_ACK::Param params; |
129 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); | 129 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); |
130 InputEventAckState ack_state = params.b; | 130 InputEventAckState ack_state = params.a.state; |
131 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); | 131 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, ack_state); |
132 widget->sink()->ClearMessages(); | 132 widget->sink()->ClearMessages(); |
133 | 133 |
134 // 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. |
135 touch.PressPoint(10, 10); | 135 touch.PressPoint(10, 10); |
136 widget->SendInputEvent(touch); | 136 widget->SendInputEvent(touch); |
137 ASSERT_EQ(1u, widget->sink()->message_count()); | 137 ASSERT_EQ(1u, widget->sink()->message_count()); |
138 message = widget->sink()->GetMessageAt(0); | 138 message = widget->sink()->GetMessageAt(0); |
139 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 139 EXPECT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
140 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); | 140 InputHostMsg_HandleInputEvent_ACK::Read(message, ¶ms); |
141 ack_state = params.b; | 141 ack_state = params.a.state; |
142 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); | 142 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_state); |
143 widget->sink()->ClearMessages(); | 143 widget->sink()->ClearMessages(); |
144 } | 144 } |
145 | 145 |
146 } // namespace content | 146 } // namespace content |
OLD | NEW |