| 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_drag_gesture_params.h" |
| 10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 11 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 11 #include "content/common/input_messages.h" | 12 #include "content/common/input_messages.h" |
| 12 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/WebKit/public/web/WebInputEvent.h" | 15 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 typedef ScopedVector<InputEvent> InputEvents; | 20 typedef ScopedVector<InputEvent> InputEvents; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 36 for (size_t i = 0; i < a->size(); ++i) | 37 for (size_t i = 0; i < a->size(); ++i) |
| 37 Compare((*a)[i], (*b)[i]); | 38 Compare((*a)[i], (*b)[i]); |
| 38 } | 39 } |
| 39 | 40 |
| 40 static void Compare(const SyntheticSmoothScrollGestureParams* a, | 41 static void Compare(const SyntheticSmoothScrollGestureParams* a, |
| 41 const SyntheticSmoothScrollGestureParams* b) { | 42 const SyntheticSmoothScrollGestureParams* b) { |
| 42 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 43 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 43 EXPECT_EQ(a->anchor, b->anchor); | 44 EXPECT_EQ(a->anchor, b->anchor); |
| 44 EXPECT_EQ(a->distances.size(), b->distances.size()); | 45 EXPECT_EQ(a->distances.size(), b->distances.size()); |
| 45 for (size_t i = 0; i < a->distances.size(); i++) | 46 for (size_t i = 0; i < a->distances.size(); i++) |
| 46 EXPECT_EQ(a->distances[i], b->distances[i]); | 47 EXPECT_EQ(a->distances[i], b->distances[i]); |
| 47 EXPECT_EQ(a->prevent_fling, b->prevent_fling); | 48 EXPECT_EQ(a->prevent_fling, b->prevent_fling); |
| 48 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); | 49 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); |
| 49 } | 50 } |
| 50 | 51 |
| 52 static void Compare(const SyntheticSmoothDragGestureParams* a, |
| 53 const SyntheticSmoothDragGestureParams* b) { |
| 54 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 55 EXPECT_EQ(a->start_point, b->start_point); |
| 56 EXPECT_EQ(a->distances.size(), b->distances.size()); |
| 57 for (size_t i = 0; i < a->distances.size(); i++) |
| 58 EXPECT_EQ(a->distances[i], b->distances[i]); |
| 59 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); |
| 60 } |
| 61 |
| 51 static void Compare(const SyntheticPinchGestureParams* a, | 62 static void Compare(const SyntheticPinchGestureParams* a, |
| 52 const SyntheticPinchGestureParams* b) { | 63 const SyntheticPinchGestureParams* b) { |
| 53 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 64 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 54 EXPECT_EQ(a->scale_factor, b->scale_factor); | 65 EXPECT_EQ(a->scale_factor, b->scale_factor); |
| 55 EXPECT_EQ(a->anchor, b->anchor); | 66 EXPECT_EQ(a->anchor, b->anchor); |
| 56 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s, | 67 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s, |
| 57 b->relative_pointer_speed_in_pixels_s); | 68 b->relative_pointer_speed_in_pixels_s); |
| 58 } | 69 } |
| 59 | 70 |
| 60 static void Compare(const SyntheticTapGestureParams* a, | 71 static void Compare(const SyntheticTapGestureParams* a, |
| 61 const SyntheticTapGestureParams* b) { | 72 const SyntheticTapGestureParams* b) { |
| 62 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 73 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
| 63 EXPECT_EQ(a->position, b->position); | 74 EXPECT_EQ(a->position, b->position); |
| 64 EXPECT_EQ(a->duration_ms, b->duration_ms); | 75 EXPECT_EQ(a->duration_ms, b->duration_ms); |
| 65 } | 76 } |
| 66 | 77 |
| 67 static void Compare(const SyntheticGesturePacket* a, | 78 static void Compare(const SyntheticGesturePacket* a, |
| 68 const SyntheticGesturePacket* b) { | 79 const SyntheticGesturePacket* b) { |
| 69 ASSERT_EQ(!!a, !!b); | 80 ASSERT_EQ(!!a, !!b); |
| 70 if (!a) return; | 81 if (!a) return; |
| 71 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params()); | 82 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params()); |
| 72 if (!a->gesture_params()) return; | 83 if (!a->gesture_params()) return; |
| 73 ASSERT_EQ(a->gesture_params()->GetGestureType(), | 84 ASSERT_EQ(a->gesture_params()->GetGestureType(), |
| 74 b->gesture_params()->GetGestureType()); | 85 b->gesture_params()->GetGestureType()); |
| 75 switch (a->gesture_params()->GetGestureType()) { | 86 switch (a->gesture_params()->GetGestureType()) { |
| 76 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: | 87 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: |
| 77 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()), | 88 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()), |
| 78 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params())); | 89 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params())); |
| 79 break; | 90 break; |
| 91 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE: |
| 92 Compare(SyntheticSmoothDragGestureParams::Cast(a->gesture_params()), |
| 93 SyntheticSmoothDragGestureParams::Cast(b->gesture_params())); |
| 94 break; |
| 80 case SyntheticGestureParams::PINCH_GESTURE: | 95 case SyntheticGestureParams::PINCH_GESTURE: |
| 81 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()), | 96 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()), |
| 82 SyntheticPinchGestureParams::Cast(b->gesture_params())); | 97 SyntheticPinchGestureParams::Cast(b->gesture_params())); |
| 83 break; | 98 break; |
| 84 case SyntheticGestureParams::TAP_GESTURE: | 99 case SyntheticGestureParams::TAP_GESTURE: |
| 85 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()), | 100 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()), |
| 86 SyntheticTapGestureParams::Cast(b->gesture_params())); | 101 SyntheticTapGestureParams::Cast(b->gesture_params())); |
| 87 break; | 102 break; |
| 88 } | 103 } |
| 89 } | 104 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, | 243 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, |
| 229 gesture_params->GetGestureType()); | 244 gesture_params->GetGestureType()); |
| 230 SyntheticGesturePacket packet_in; | 245 SyntheticGesturePacket packet_in; |
| 231 packet_in.set_gesture_params(gesture_params.Pass()); | 246 packet_in.set_gesture_params(gesture_params.Pass()); |
| 232 | 247 |
| 233 Verify(packet_in); | 248 Verify(packet_in); |
| 234 } | 249 } |
| 235 | 250 |
| 236 } // namespace | 251 } // namespace |
| 237 } // namespace content | 252 } // namespace content |
| OLD | NEW |