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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 int rawId, | 44 int rawId, |
45 int uniqueId, | 45 int uniqueId, |
46 bool isPrimary, | 46 bool isPrimary, |
47 WebTouchPoint::State = WebTouchPoint::StatePressed, | 47 WebTouchPoint::State = WebTouchPoint::StatePressed, |
48 size_t coalescedEventCount = 0); | 48 size_t coalescedEventCount = 0); |
49 PointerEvent* createAndCheckMouseEvent( | 49 PointerEvent* createAndCheckMouseEvent( |
50 WebPointerProperties::PointerType, | 50 WebPointerProperties::PointerType, |
51 int rawId, | 51 int rawId, |
52 int uniqueId, | 52 int uniqueId, |
53 bool isPrimary, | 53 bool isPrimary, |
54 PlatformEvent::Modifiers = PlatformEvent::NoModifiers, | 54 WebInputEvent::Modifiers = WebInputEvent::NoModifiers, |
55 size_t coalescedEventCount = 0); | 55 size_t coalescedEventCount = 0); |
56 void createAndCheckPointerTransitionEvent(PointerEvent*, const AtomicString&); | 56 void createAndCheckPointerTransitionEvent(PointerEvent*, const AtomicString&); |
57 | 57 |
58 PointerEventFactory m_pointerEventFactory; | 58 PointerEventFactory m_pointerEventFactory; |
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 WebMouseEventBuilder : public WebMouseEvent { | 69 class WebMouseEventBuilder : public WebMouseEvent { |
70 public: | 70 public: |
71 WebMouseEventBuilder(WebPointerProperties::PointerType, | 71 WebMouseEventBuilder(WebPointerProperties::PointerType, |
72 int, | 72 int, |
73 PlatformEvent::Modifiers); | 73 WebInputEvent::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::WebMouseEventBuilder::WebMouseEventBuilder( | 92 PointerEventFactoryTest::WebMouseEventBuilder::WebMouseEventBuilder( |
93 WebPointerProperties::PointerType pointerTypeParam, | 93 WebPointerProperties::PointerType pointerTypeParam, |
94 int idParam, | 94 int idParam, |
95 PlatformEvent::Modifiers modifiersParam) { | 95 WebInputEvent::Modifiers modifiersParam) { |
96 pointerType = pointerTypeParam; | 96 pointerType = pointerTypeParam; |
97 id = idParam; | 97 id = idParam; |
98 m_modifiers = modifiersParam; | 98 m_modifiers = modifiersParam; |
99 m_frameScale = 1; | 99 m_frameScale = 1; |
100 } | 100 } |
101 | 101 |
102 PointerEvent* PointerEventFactoryTest::createAndCheckTouchCancel( | 102 PointerEvent* PointerEventFactoryTest::createAndCheckTouchCancel( |
103 WebPointerProperties::PointerType pointerType, | 103 WebPointerProperties::PointerType pointerType, |
104 int rawId, | 104 int rawId, |
105 int uniqueId, | 105 int uniqueId, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); | 152 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); |
153 } | 153 } |
154 return pointerEvent; | 154 return pointerEvent; |
155 } | 155 } |
156 | 156 |
157 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( | 157 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( |
158 WebPointerProperties::PointerType pointerType, | 158 WebPointerProperties::PointerType pointerType, |
159 int rawId, | 159 int rawId, |
160 int uniqueId, | 160 int uniqueId, |
161 bool isPrimary, | 161 bool isPrimary, |
162 PlatformEvent::Modifiers modifiers, | 162 WebInputEvent::Modifiers modifiers, |
163 size_t coalescedEventCount) { | 163 size_t coalescedEventCount) { |
164 Vector<WebMouseEvent> coalescedEvents; | 164 Vector<WebMouseEvent> coalescedEvents; |
165 for (size_t i = 0; i < coalescedEventCount; i++) { | 165 for (size_t i = 0; i < coalescedEventCount; i++) { |
166 coalescedEvents.push_back(PointerEventFactoryTest::WebMouseEventBuilder( | 166 coalescedEvents.push_back(PointerEventFactoryTest::WebMouseEventBuilder( |
167 pointerType, rawId, modifiers)); | 167 pointerType, rawId, modifiers)); |
168 } | 168 } |
169 PointerEvent* pointerEvent = m_pointerEventFactory.create( | 169 PointerEvent* pointerEvent = m_pointerEventFactory.create( |
170 coalescedEventCount ? EventTypeNames::mousemove | 170 coalescedEventCount ? EventTypeNames::mousemove |
171 : EventTypeNames::mousedown, | 171 : EventTypeNames::mousedown, |
172 PointerEventFactoryTest::WebMouseEventBuilder(pointerType, rawId, | 172 PointerEventFactoryTest::WebMouseEventBuilder(pointerType, rawId, |
(...skipping 14 matching lines...) Expand all Loading... |
187 } | 187 } |
188 | 188 |
189 TEST_F(PointerEventFactoryTest, MousePointer) { | 189 TEST_F(PointerEventFactoryTest, MousePointer) { |
190 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); | 190 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); |
191 EXPECT_FALSE(m_pointerEventFactory.isActiveButtonsState(m_expectedMouseId)); | 191 EXPECT_FALSE(m_pointerEventFactory.isActiveButtonsState(m_expectedMouseId)); |
192 | 192 |
193 PointerEvent* pointerEvent1 = createAndCheckMouseEvent( | 193 PointerEvent* pointerEvent1 = createAndCheckMouseEvent( |
194 WebPointerProperties::PointerType::Mouse, 0, m_expectedMouseId, true); | 194 WebPointerProperties::PointerType::Mouse, 0, m_expectedMouseId, true); |
195 PointerEvent* pointerEvent2 = createAndCheckMouseEvent( | 195 PointerEvent* pointerEvent2 = createAndCheckMouseEvent( |
196 WebPointerProperties::PointerType::Mouse, 0, m_expectedMouseId, true, | 196 WebPointerProperties::PointerType::Mouse, 0, m_expectedMouseId, true, |
197 PlatformEvent::LeftButtonDown); | 197 WebInputEvent::LeftButtonDown); |
198 | 198 |
199 createAndCheckPointerTransitionEvent(pointerEvent1, | 199 createAndCheckPointerTransitionEvent(pointerEvent1, |
200 EventTypeNames::pointerout); | 200 EventTypeNames::pointerout); |
201 | 201 |
202 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); | 202 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); |
203 EXPECT_TRUE(m_pointerEventFactory.isActiveButtonsState(m_expectedMouseId)); | 203 EXPECT_TRUE(m_pointerEventFactory.isActiveButtonsState(m_expectedMouseId)); |
204 | 204 |
205 m_pointerEventFactory.remove(pointerEvent1->pointerId()); | 205 m_pointerEventFactory.remove(pointerEvent1->pointerId()); |
206 | 206 |
207 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); | 207 EXPECT_TRUE(m_pointerEventFactory.isActive(m_expectedMouseId)); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 for (int i = 0; i < 100; ++i) { | 438 for (int i = 0; i < 100; ++i) { |
439 createAndCheckTouchEvent(WebPointerProperties::PointerType::Mouse, i, | 439 createAndCheckTouchEvent(WebPointerProperties::PointerType::Mouse, i, |
440 m_expectedMouseId, true); | 440 m_expectedMouseId, true); |
441 } | 441 } |
442 createAndCheckTouchCancel(WebPointerProperties::PointerType::Mouse, 0, | 442 createAndCheckTouchCancel(WebPointerProperties::PointerType::Mouse, 0, |
443 m_expectedMouseId, true); | 443 m_expectedMouseId, true); |
444 } | 444 } |
445 | 445 |
446 TEST_F(PointerEventFactoryTest, CoalescedEvents) { | 446 TEST_F(PointerEventFactoryTest, CoalescedEvents) { |
447 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, | 447 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, |
448 m_expectedMouseId, true, PlatformEvent::NoModifiers, | 448 m_expectedMouseId, true, WebInputEvent::NoModifiers, |
449 4); | 449 4); |
450 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, | 450 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, |
451 m_mappedIdStart, true, WebTouchPoint::StateMoved, 3); | 451 m_mappedIdStart, true, WebTouchPoint::StateMoved, 3); |
452 } | 452 } |
453 | 453 |
454 } // namespace blink | 454 } // namespace blink |
OLD | NEW |