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/common/input/input_param_traits.h" | 5 #include "content/common/input/input_param_traits.h" |
6 | 6 |
7 #include "content/common/input/input_event.h" | 7 #include "content/common/input/input_event.h" |
8 #include "content/common/input/synthetic_gesture_params.h" | 8 #include "content/common/input/synthetic_gesture_params.h" |
9 #include "content/common/input/synthetic_pinch_gesture_params.h" | 9 #include "content/common/input/synthetic_pinch_gesture_params.h" |
10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 new SyntheticSmoothScrollGestureParams); | 192 new SyntheticSmoothScrollGestureParams); |
193 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 193 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
194 gesture_params->anchor.SetPoint(234, 345); | 194 gesture_params->anchor.SetPoint(234, 345); |
195 gesture_params->distances.push_back(gfx::Vector2d(123, -789)); | 195 gesture_params->distances.push_back(gfx::Vector2d(123, -789)); |
196 gesture_params->distances.push_back(gfx::Vector2d(-78, 43)); | 196 gesture_params->distances.push_back(gfx::Vector2d(-78, 43)); |
197 gesture_params->prevent_fling = false; | 197 gesture_params->prevent_fling = false; |
198 gesture_params->speed_in_pixels_s = 456; | 198 gesture_params->speed_in_pixels_s = 456; |
199 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE, | 199 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE, |
200 gesture_params->GetGestureType()); | 200 gesture_params->GetGestureType()); |
201 SyntheticGesturePacket packet_in; | 201 SyntheticGesturePacket packet_in; |
202 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 202 packet_in.set_gesture_params(gesture_params.Pass()); |
203 | 203 |
204 Verify(packet_in); | 204 Verify(packet_in); |
205 } | 205 } |
206 | 206 |
207 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { | 207 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { |
208 scoped_ptr<SyntheticPinchGestureParams> gesture_params( | 208 scoped_ptr<SyntheticPinchGestureParams> gesture_params( |
209 new SyntheticPinchGestureParams); | 209 new SyntheticPinchGestureParams); |
210 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 210 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
211 gesture_params->scale_factor = 2.3f; | 211 gesture_params->scale_factor = 2.3f; |
212 gesture_params->anchor.SetPoint(234, 345); | 212 gesture_params->anchor.SetPoint(234, 345); |
213 gesture_params->relative_pointer_speed_in_pixels_s = 456; | 213 gesture_params->relative_pointer_speed_in_pixels_s = 456; |
214 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE, | 214 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE, |
215 gesture_params->GetGestureType()); | 215 gesture_params->GetGestureType()); |
216 SyntheticGesturePacket packet_in; | 216 SyntheticGesturePacket packet_in; |
217 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 217 packet_in.set_gesture_params(gesture_params.Pass()); |
218 | 218 |
219 Verify(packet_in); | 219 Verify(packet_in); |
220 } | 220 } |
221 | 221 |
222 TEST_F(InputParamTraitsTest, SyntheticTapGestureParams) { | 222 TEST_F(InputParamTraitsTest, SyntheticTapGestureParams) { |
223 scoped_ptr<SyntheticTapGestureParams> gesture_params( | 223 scoped_ptr<SyntheticTapGestureParams> gesture_params( |
224 new SyntheticTapGestureParams); | 224 new SyntheticTapGestureParams); |
225 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 225 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
226 gesture_params->position.SetPoint(798, 233); | 226 gesture_params->position.SetPoint(798, 233); |
227 gesture_params->duration_ms = 13; | 227 gesture_params->duration_ms = 13; |
228 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, | 228 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, |
229 gesture_params->GetGestureType()); | 229 gesture_params->GetGestureType()); |
230 SyntheticGesturePacket packet_in; | 230 SyntheticGesturePacket packet_in; |
231 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 231 packet_in.set_gesture_params(gesture_params.Pass()); |
232 | 232 |
233 Verify(packet_in); | 233 Verify(packet_in); |
234 } | 234 } |
235 | 235 |
236 } // namespace | 236 } // namespace |
237 } // namespace content | 237 } // namespace content |
OLD | NEW |