Chromium Code Reviews| Index: third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp |
| diff --git a/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp b/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp |
| index cba3d02a08f7f82c329d1ac8a1e91038d7291b51..dd4c69e9d985021a507ca5261444e117f50010e6 100644 |
| --- a/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp |
| +++ b/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp |
| @@ -24,13 +24,15 @@ class PointerEventFactoryTest : public ::testing::Test { |
| int rawId, |
| int uniqueId, |
| bool isPrimary, |
| - PlatformTouchPoint::TouchState = PlatformTouchPoint::TouchPressed); |
| + PlatformTouchPoint::TouchState = PlatformTouchPoint::TouchPressed, |
| + size_t coalescedEventCount = 0); |
| PointerEvent* createAndCheckMouseEvent( |
| WebPointerProperties::PointerType, |
| int rawId, |
| int uniqueId, |
| bool isPrimary, |
| - PlatformEvent::Modifiers = PlatformEvent::NoModifiers); |
| + PlatformEvent::Modifiers = PlatformEvent::NoModifiers, |
| + size_t coalescedEventCount = 0); |
| void createAndCheckPointerTransitionEvent(PointerEvent*, const AtomicString&); |
| PointerEventFactory m_pointerEventFactory; |
| @@ -105,14 +107,24 @@ PointerEvent* PointerEventFactoryTest::createAndCheckTouchEvent( |
| int rawId, |
| int uniqueId, |
| bool isPrimary, |
| - PlatformTouchPoint::TouchState state) { |
| + PlatformTouchPoint::TouchState state, |
| + size_t coalescedEventCount) { |
|
mustaq
2016/11/21 20:53:53
May be pass id[], isPrimary[] and pointerType[] an
Navid Zolghadr
2016/11/21 21:31:21
I'm a little confused here. What throw? The code n
|
| + Vector<PlatformTouchPoint> coalescedEvents; |
| + for (size_t i = 0; i < coalescedEventCount; i++) { |
| + coalescedEvents.append(PointerEventFactoryTest::PlatformTouchPointBuilder( |
| + pointerType, rawId, state)); |
| + } |
| PointerEvent* pointerEvent = m_pointerEventFactory.create( |
| - EventTypeNames::pointerdown, |
| PointerEventFactoryTest::PlatformTouchPointBuilder(pointerType, rawId, |
| state), |
| - PlatformEvent::NoModifiers, FloatSize(), FloatPoint(), nullptr); |
| + coalescedEvents, PlatformEvent::NoModifiers, nullptr, nullptr); |
| EXPECT_EQ(uniqueId, pointerEvent->pointerId()); |
| EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); |
| + EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size()); |
| + for (size_t i = 0; i < coalescedEventCount; i++) { |
| + EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId()); |
| + EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary()); |
|
mustaq
2016/11/21 20:53:53
Also check pointerType. Same for the container ("d
|
| + } |
| return pointerEvent; |
| } |
| @@ -121,12 +133,27 @@ PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( |
| int rawId, |
| int uniqueId, |
| bool isPrimary, |
| - PlatformEvent::Modifiers modifiers) { |
| + PlatformEvent::Modifiers modifiers, |
| + size_t coalescedEventCount) { |
| + Vector<PlatformMouseEvent> coalescedEvents; |
| + for (size_t i = 0; i < coalescedEventCount; i++) { |
| + coalescedEvents.append(PointerEventFactoryTest::PlatformMouseEventBuilder( |
| + pointerType, rawId, modifiers)); |
| + } |
| PointerEvent* pointerEvent = m_pointerEventFactory.create( |
| - EventTypeNames::mousedown, |
| - PlatformMouseEventBuilder(pointerType, rawId, modifiers), nullptr); |
| + coalescedEventCount ? EventTypeNames::mousemove |
| + : EventTypeNames::mousedown, |
| + PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, |
| + modifiers), |
| + coalescedEvents, nullptr); |
| EXPECT_EQ(uniqueId, pointerEvent->pointerId()); |
| EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); |
| + EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size()); |
| + for (size_t i = 0; i < coalescedEventCount; i++) { |
| + EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId()); |
| + EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary()); |
| + } |
| + |
| return pointerEvent; |
| } |
| @@ -388,4 +415,13 @@ TEST_F(PointerEventFactoryTest, OutOfRange) { |
| m_expectedMouseId, true); |
| } |
| +TEST_F(PointerEventFactoryTest, CoalescedEvents) { |
| + createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, |
| + m_expectedMouseId, true, PlatformEvent::NoModifiers, |
| + 4); |
| + createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, |
| + m_mappedIdStart, true, |
| + PlatformTouchPoint::TouchMoved, 3); |
| +} |
| + |
| } // namespace blink |