| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "content/common/input/synthetic_web_input_event_builders.h" | 7 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 8 #include "content/renderer/pepper/event_conversion.h" | 8 #include "content/renderer/pepper/event_conversion.h" |
| 9 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 9 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class EventConversionTest : public ::testing::Test { | 14 class EventConversionTest : public ::testing::Test { |
| 15 protected: | 15 protected: |
| 16 void CompareWebTouchEvents(const blink::WebTouchEvent& expected, | 16 void CompareWebTouchEvents(const blink::WebTouchEvent& expected, |
| 17 const blink::WebTouchEvent& actual) { | 17 const blink::WebTouchEvent& actual) { |
| 18 EXPECT_EQ(expected.type, actual.type); | 18 EXPECT_EQ(expected.type, actual.type); |
| 19 ASSERT_EQ(expected.touchesLength, actual.touchesLength); | 19 ASSERT_EQ(expected.touchesLength, actual.touchesLength); |
| 20 for (size_t i = 0; i < expected.touchesLength; ++i) { | 20 for (size_t i = 0; i < expected.touchesLength; ++i) { |
| 21 size_t j = 0; | 21 size_t j = 0; |
| 22 for (; j < actual.touchesLength; ++j) { | 22 for (; j < actual.touchesLength; ++j) { |
| 23 if (actual.touches[j].id == expected.touches[i].id) | 23 if (actual.touches[j].pointerId == expected.touches[i].pointerId) |
| 24 break; | 24 break; |
| 25 } | 25 } |
| 26 ASSERT_NE(j, actual.touchesLength); | 26 ASSERT_NE(j, actual.touchesLength); |
| 27 EXPECT_EQ(expected.touches[i].id, actual.touches[j].id); | 27 EXPECT_EQ(expected.touches[i].pointerId, actual.touches[j].pointerId); |
| 28 EXPECT_EQ(expected.touches[i].state, actual.touches[j].state); | 28 EXPECT_EQ(expected.touches[i].state, actual.touches[j].state); |
| 29 EXPECT_EQ(expected.touches[i].position.x, actual.touches[j].position.x); | 29 EXPECT_EQ(expected.touches[i].position.x, actual.touches[j].position.x); |
| 30 EXPECT_EQ(expected.touches[i].position.y, actual.touches[j].position.y); | 30 EXPECT_EQ(expected.touches[i].position.y, actual.touches[j].position.y); |
| 31 EXPECT_EQ(expected.touches[i].radiusX, actual.touches[j].radiusX); | 31 EXPECT_EQ(expected.touches[i].width, actual.touches[j].width); |
| 32 EXPECT_EQ(expected.touches[i].radiusY, actual.touches[j].radiusY); | 32 EXPECT_EQ(expected.touches[i].height, actual.touches[j].height); |
| 33 EXPECT_EQ(expected.touches[i].rotationAngle, | 33 EXPECT_EQ(expected.touches[i].rotationAngle, |
| 34 actual.touches[j].rotationAngle); | 34 actual.touches[j].rotationAngle); |
| 35 EXPECT_EQ(expected.touches[i].force, actual.touches[j].force); | 35 EXPECT_EQ(expected.touches[i].pressure, actual.touches[j].pressure); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 TEST_F(EventConversionTest, TouchStart) { | 40 TEST_F(EventConversionTest, TouchStart) { |
| 41 SyntheticWebTouchEvent touch; | 41 SyntheticWebTouchEvent touch; |
| 42 touch.PressPoint(1.f, 2.f); | 42 touch.PressPoint(1.f, 2.f); |
| 43 | 43 |
| 44 std::vector<ppapi::InputEventData> pp_events; | 44 std::vector<ppapi::InputEventData> pp_events; |
| 45 CreateInputEventData(touch, &pp_events); | 45 CreateInputEventData(touch, &pp_events); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 scoped_ptr<blink::WebInputEvent> event_out(CreateWebInputEvent(pp_event)); | 136 scoped_ptr<blink::WebInputEvent> event_out(CreateWebInputEvent(pp_event)); |
| 137 const blink::WebTouchEvent* touch_out = | 137 const blink::WebTouchEvent* touch_out = |
| 138 static_cast<const blink::WebTouchEvent*>(event_out.get()); | 138 static_cast<const blink::WebTouchEvent*>(event_out.get()); |
| 139 ASSERT_TRUE(touch_out); | 139 ASSERT_TRUE(touch_out); |
| 140 EXPECT_EQ(touch.type, touch_out->type); | 140 EXPECT_EQ(touch.type, touch_out->type); |
| 141 EXPECT_EQ(touch.touchesLength, touch_out->touchesLength); | 141 EXPECT_EQ(touch.touchesLength, touch_out->touchesLength); |
| 142 CompareWebTouchEvents(touch, *touch_out); | 142 CompareWebTouchEvents(touch, *touch_out); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace content | 145 } // namespace content |
| OLD | NEW |