| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 EXPECT_EQ(a->distances.size(), b->distances.size()); | 44 EXPECT_EQ(a->distances.size(), b->distances.size()); |
| 45 for (size_t i = 0; i < a->distances.size(); i++) | 45 for (size_t i = 0; i < a->distances.size(); i++) |
| 46 EXPECT_EQ(a->distances[i], b->distances[i]); | 46 EXPECT_EQ(a->distances[i], b->distances[i]); |
| 47 EXPECT_EQ(a->prevent_fling, b->prevent_fling); | 47 EXPECT_EQ(a->prevent_fling, b->prevent_fling); |
| 48 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); | 48 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); |
| 49 } | 49 } |
| 50 | 50 |
| 51 static void Compare(const SyntheticPinchGestureParams* a, | 51 static void Compare(const SyntheticPinchGestureParams* a, |
| 52 const SyntheticPinchGestureParams* b) { | 52 const SyntheticPinchGestureParams* b) { |
| 53 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 53 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 54 EXPECT_EQ(a->zoom_in, b->zoom_in); | 54 EXPECT_EQ(a->scale_factor, b->scale_factor); |
| 55 EXPECT_EQ(a->total_num_pixels_covered, b->total_num_pixels_covered); | |
| 56 EXPECT_EQ(a->anchor, b->anchor); | 55 EXPECT_EQ(a->anchor, b->anchor); |
| 57 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s, | 56 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s, |
| 58 b->relative_pointer_speed_in_pixels_s); | 57 b->relative_pointer_speed_in_pixels_s); |
| 59 } | 58 } |
| 60 | 59 |
| 61 static void Compare(const SyntheticTapGestureParams* a, | 60 static void Compare(const SyntheticTapGestureParams* a, |
| 62 const SyntheticTapGestureParams* b) { | 61 const SyntheticTapGestureParams* b) { |
| 63 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 62 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 64 EXPECT_EQ(a->position, b->position); | 63 EXPECT_EQ(a->position, b->position); |
| 65 EXPECT_EQ(a->duration_ms, b->duration_ms); | 64 EXPECT_EQ(a->duration_ms, b->duration_ms); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 SyntheticGesturePacket packet_in; | 201 SyntheticGesturePacket packet_in; |
| 203 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 202 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); |
| 204 | 203 |
| 205 Verify(packet_in); | 204 Verify(packet_in); |
| 206 } | 205 } |
| 207 | 206 |
| 208 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { | 207 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { |
| 209 scoped_ptr<SyntheticPinchGestureParams> gesture_params( | 208 scoped_ptr<SyntheticPinchGestureParams> gesture_params( |
| 210 new SyntheticPinchGestureParams); | 209 new SyntheticPinchGestureParams); |
| 211 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 210 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 212 gesture_params->zoom_in = true; | 211 gesture_params->scale_factor = 2.3f; |
| 213 gesture_params->total_num_pixels_covered = 123; | |
| 214 gesture_params->anchor.SetPoint(234, 345); | 212 gesture_params->anchor.SetPoint(234, 345); |
| 215 gesture_params->relative_pointer_speed_in_pixels_s = 456; | 213 gesture_params->relative_pointer_speed_in_pixels_s = 456; |
| 216 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE, | 214 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE, |
| 217 gesture_params->GetGestureType()); | 215 gesture_params->GetGestureType()); |
| 218 SyntheticGesturePacket packet_in; | 216 SyntheticGesturePacket packet_in; |
| 219 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 217 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); |
| 220 | 218 |
| 221 Verify(packet_in); | 219 Verify(packet_in); |
| 222 } | 220 } |
| 223 | 221 |
| 224 TEST_F(InputParamTraitsTest, SyntheticTapGestureParams) { | 222 TEST_F(InputParamTraitsTest, SyntheticTapGestureParams) { |
| 225 scoped_ptr<SyntheticTapGestureParams> gesture_params( | 223 scoped_ptr<SyntheticTapGestureParams> gesture_params( |
| 226 new SyntheticTapGestureParams); | 224 new SyntheticTapGestureParams); |
| 227 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 225 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 228 gesture_params->position.SetPoint(798, 233); | 226 gesture_params->position.SetPoint(798, 233); |
| 229 gesture_params->duration_ms = 13; | 227 gesture_params->duration_ms = 13; |
| 230 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, | 228 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, |
| 231 gesture_params->GetGestureType()); | 229 gesture_params->GetGestureType()); |
| 232 SyntheticGesturePacket packet_in; | 230 SyntheticGesturePacket packet_in; |
| 233 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 231 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); |
| 234 | 232 |
| 235 Verify(packet_in); | 233 Verify(packet_in); |
| 236 } | 234 } |
| 237 | 235 |
| 238 } // namespace | 236 } // namespace |
| 239 } // namespace content | 237 } // namespace content |
| OLD | NEW |