| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/events/PointerEventFactory.h" | 5 #include "core/events/PointerEventFactory.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/page/Page.h" | 8 #include "core/page/Page.h" |
| 9 #include "public/platform/WebPointerProperties.h" | 9 #include "public/platform/WebPointerProperties.h" |
| 10 #include <climits> | 10 #include <climits> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 unsigned m_expectedMouseId; | 59 unsigned m_expectedMouseId; |
| 60 unsigned m_mappedIdStart; | 60 unsigned m_mappedIdStart; |
| 61 | 61 |
| 62 class WebTouchPointBuilder : public WebTouchPoint { | 62 class WebTouchPointBuilder : public WebTouchPoint { |
| 63 public: | 63 public: |
| 64 WebTouchPointBuilder(WebPointerProperties::PointerType, | 64 WebTouchPointBuilder(WebPointerProperties::PointerType, |
| 65 int, | 65 int, |
| 66 WebTouchPoint::State); | 66 WebTouchPoint::State); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class PlatformMouseEventBuilder : public PlatformMouseEvent { | 69 class WebMouseEventBuilder : public WebMouseEvent { |
| 70 public: | 70 public: |
| 71 PlatformMouseEventBuilder(WebPointerProperties::PointerType, | 71 WebMouseEventBuilder(WebPointerProperties::PointerType, |
| 72 int, | 72 int, |
| 73 PlatformEvent::Modifiers); | 73 PlatformEvent::Modifiers); |
| 74 }; | 74 }; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 void PointerEventFactoryTest::SetUp() { | 77 void PointerEventFactoryTest::SetUp() { |
| 78 m_expectedMouseId = 1; | 78 m_expectedMouseId = 1; |
| 79 m_mappedIdStart = 2; | 79 m_mappedIdStart = 2; |
| 80 } | 80 } |
| 81 | 81 |
| 82 PointerEventFactoryTest::WebTouchPointBuilder::WebTouchPointBuilder( | 82 PointerEventFactoryTest::WebTouchPointBuilder::WebTouchPointBuilder( |
| 83 WebPointerProperties::PointerType pointerTypeParam, | 83 WebPointerProperties::PointerType pointerTypeParam, |
| 84 int idParam, | 84 int idParam, |
| 85 WebTouchPoint::State stateParam) { | 85 WebTouchPoint::State stateParam) { |
| 86 id = idParam; | 86 id = idParam; |
| 87 pointerType = pointerTypeParam; | 87 pointerType = pointerTypeParam; |
| 88 force = 1.0; | 88 force = 1.0; |
| 89 state = stateParam; | 89 state = stateParam; |
| 90 } | 90 } |
| 91 | 91 |
| 92 PointerEventFactoryTest::PlatformMouseEventBuilder::PlatformMouseEventBuilder( | 92 PointerEventFactoryTest::WebMouseEventBuilder::WebMouseEventBuilder( |
| 93 WebPointerProperties::PointerType pointerType, | 93 WebPointerProperties::PointerType pointerTypeParam, |
| 94 int id, | 94 int idParam, |
| 95 PlatformEvent::Modifiers modifiers) { | 95 PlatformEvent::Modifiers modifiersParam) { |
| 96 m_pointerProperties.pointerType = pointerType; | 96 pointerType = pointerTypeParam; |
| 97 m_pointerProperties.id = id; | 97 id = idParam; |
| 98 m_modifiers = modifiers; | 98 m_modifiers = modifiersParam; |
| 99 } | 99 } |
| 100 | 100 |
| 101 PointerEvent* PointerEventFactoryTest::createAndCheckTouchCancel( | 101 PointerEvent* PointerEventFactoryTest::createAndCheckTouchCancel( |
| 102 WebPointerProperties::PointerType pointerType, | 102 WebPointerProperties::PointerType pointerType, |
| 103 int rawId, | 103 int rawId, |
| 104 int uniqueId, | 104 int uniqueId, |
| 105 bool isPrimary) { | 105 bool isPrimary) { |
| 106 PointerEvent* pointerEvent = | 106 PointerEvent* pointerEvent = |
| 107 m_pointerEventFactory.createPointerCancelEvent(uniqueId, pointerType); | 107 m_pointerEventFactory.createPointerCancelEvent(uniqueId, pointerType); |
| 108 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); | 108 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return pointerEvent; | 153 return pointerEvent; |
| 154 } | 154 } |
| 155 | 155 |
| 156 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( | 156 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( |
| 157 WebPointerProperties::PointerType pointerType, | 157 WebPointerProperties::PointerType pointerType, |
| 158 int rawId, | 158 int rawId, |
| 159 int uniqueId, | 159 int uniqueId, |
| 160 bool isPrimary, | 160 bool isPrimary, |
| 161 PlatformEvent::Modifiers modifiers, | 161 PlatformEvent::Modifiers modifiers, |
| 162 size_t coalescedEventCount) { | 162 size_t coalescedEventCount) { |
| 163 Vector<PlatformMouseEvent> coalescedEvents; | 163 Vector<WebMouseEvent> coalescedEvents; |
| 164 for (size_t i = 0; i < coalescedEventCount; i++) { | 164 for (size_t i = 0; i < coalescedEventCount; i++) { |
| 165 coalescedEvents.push_back( | 165 coalescedEvents.push_back(PointerEventFactoryTest::WebMouseEventBuilder( |
| 166 PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, | 166 pointerType, rawId, modifiers)); |
| 167 modifiers)); | |
| 168 } | 167 } |
| 169 PointerEvent* pointerEvent = m_pointerEventFactory.create( | 168 PointerEvent* pointerEvent = m_pointerEventFactory.create( |
| 170 coalescedEventCount ? EventTypeNames::mousemove | 169 coalescedEventCount ? EventTypeNames::mousemove |
| 171 : EventTypeNames::mousedown, | 170 : EventTypeNames::mousedown, |
| 172 PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, | 171 PointerEventFactoryTest::WebMouseEventBuilder(pointerType, rawId, |
| 173 modifiers), | 172 modifiers), |
| 174 coalescedEvents, nullptr); | 173 coalescedEvents, nullptr); |
| 175 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); | 174 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); |
| 176 EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); | 175 EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); |
| 177 const char* expectedPointerType = | 176 const char* expectedPointerType = |
| 178 pointerTypeNameForWebPointPointerType(pointerType); | 177 pointerTypeNameForWebPointPointerType(pointerType); |
| 179 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); | 178 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); |
| 180 EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size()); | 179 EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size()); |
| 181 for (size_t i = 0; i < coalescedEventCount; i++) { | 180 for (size_t i = 0; i < coalescedEventCount; i++) { |
| 182 EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId()); | 181 EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId()); |
| 183 EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary()); | 182 EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary()); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 444 |
| 446 TEST_F(PointerEventFactoryTest, CoalescedEvents) { | 445 TEST_F(PointerEventFactoryTest, CoalescedEvents) { |
| 447 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, | 446 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, |
| 448 m_expectedMouseId, true, PlatformEvent::NoModifiers, | 447 m_expectedMouseId, true, PlatformEvent::NoModifiers, |
| 449 4); | 448 4); |
| 450 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, | 449 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, |
| 451 m_mappedIdStart, true, WebTouchPoint::StateMoved, 3); | 450 m_mappedIdStart, true, WebTouchPoint::StateMoved, 3); |
| 452 } | 451 } |
| 453 | 452 |
| 454 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |