Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp

Issue 2585283002: Migrate WTF::Vector::append() to ::push_back() [part 6 of N] (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 PointerEvent* PointerEventFactoryTest::createAndCheckTouchEvent( 127 PointerEvent* PointerEventFactoryTest::createAndCheckTouchEvent(
128 WebPointerProperties::PointerType pointerType, 128 WebPointerProperties::PointerType pointerType,
129 int rawId, 129 int rawId,
130 int uniqueId, 130 int uniqueId,
131 bool isPrimary, 131 bool isPrimary,
132 PlatformTouchPoint::TouchState state, 132 PlatformTouchPoint::TouchState state,
133 size_t coalescedEventCount) { 133 size_t coalescedEventCount) {
134 Vector<PlatformTouchPoint> coalescedEvents; 134 Vector<PlatformTouchPoint> coalescedEvents;
135 for (size_t i = 0; i < coalescedEventCount; i++) { 135 for (size_t i = 0; i < coalescedEventCount; i++) {
136 coalescedEvents.append(PointerEventFactoryTest::PlatformTouchPointBuilder( 136 coalescedEvents.push_back(
137 pointerType, rawId, state)); 137 PointerEventFactoryTest::PlatformTouchPointBuilder(pointerType, rawId,
138 state));
138 } 139 }
139 PointerEvent* pointerEvent = m_pointerEventFactory.create( 140 PointerEvent* pointerEvent = m_pointerEventFactory.create(
140 PointerEventFactoryTest::PlatformTouchPointBuilder(pointerType, rawId, 141 PointerEventFactoryTest::PlatformTouchPointBuilder(pointerType, rawId,
141 state), 142 state),
142 coalescedEvents, PlatformEvent::NoModifiers, nullptr, nullptr); 143 coalescedEvents, PlatformEvent::NoModifiers, nullptr, nullptr);
143 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); 144 EXPECT_EQ(uniqueId, pointerEvent->pointerId());
144 EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); 145 EXPECT_EQ(isPrimary, pointerEvent->isPrimary());
145 const char* expectedPointerType = 146 const char* expectedPointerType =
146 pointerTypeNameForWebPointPointerType(pointerType); 147 pointerTypeNameForWebPointPointerType(pointerType);
147 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); 148 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType());
148 EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size()); 149 EXPECT_EQ(coalescedEventCount, pointerEvent->getCoalescedEvents().size());
149 for (size_t i = 0; i < coalescedEventCount; i++) { 150 for (size_t i = 0; i < coalescedEventCount; i++) {
150 EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId()); 151 EXPECT_EQ(uniqueId, pointerEvent->getCoalescedEvents()[i]->pointerId());
151 EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary()); 152 EXPECT_EQ(isPrimary, pointerEvent->getCoalescedEvents()[i]->isPrimary());
152 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType()); 153 EXPECT_EQ(expectedPointerType, pointerEvent->pointerType());
153 } 154 }
154 return pointerEvent; 155 return pointerEvent;
155 } 156 }
156 157
157 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( 158 PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent(
158 WebPointerProperties::PointerType pointerType, 159 WebPointerProperties::PointerType pointerType,
159 int rawId, 160 int rawId,
160 int uniqueId, 161 int uniqueId,
161 bool isPrimary, 162 bool isPrimary,
162 PlatformEvent::Modifiers modifiers, 163 PlatformEvent::Modifiers modifiers,
163 size_t coalescedEventCount) { 164 size_t coalescedEventCount) {
164 Vector<PlatformMouseEvent> coalescedEvents; 165 Vector<PlatformMouseEvent> coalescedEvents;
165 for (size_t i = 0; i < coalescedEventCount; i++) { 166 for (size_t i = 0; i < coalescedEventCount; i++) {
166 coalescedEvents.append(PointerEventFactoryTest::PlatformMouseEventBuilder( 167 coalescedEvents.push_back(
167 pointerType, rawId, modifiers)); 168 PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId,
169 modifiers));
168 } 170 }
169 PointerEvent* pointerEvent = m_pointerEventFactory.create( 171 PointerEvent* pointerEvent = m_pointerEventFactory.create(
170 coalescedEventCount ? EventTypeNames::mousemove 172 coalescedEventCount ? EventTypeNames::mousemove
171 : EventTypeNames::mousedown, 173 : EventTypeNames::mousedown,
172 PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, 174 PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId,
173 modifiers), 175 modifiers),
174 coalescedEvents, nullptr); 176 coalescedEvents, nullptr);
175 EXPECT_EQ(uniqueId, pointerEvent->pointerId()); 177 EXPECT_EQ(uniqueId, pointerEvent->pointerId());
176 EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); 178 EXPECT_EQ(isPrimary, pointerEvent->isPrimary());
177 const char* expectedPointerType = 179 const char* expectedPointerType =
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 TEST_F(PointerEventFactoryTest, CoalescedEvents) { 449 TEST_F(PointerEventFactoryTest, CoalescedEvents) {
448 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0, 450 createAndCheckMouseEvent(WebPointerProperties::PointerType::Mouse, 0,
449 m_expectedMouseId, true, PlatformEvent::NoModifiers, 451 m_expectedMouseId, true, PlatformEvent::NoModifiers,
450 4); 452 4);
451 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0, 453 createAndCheckTouchEvent(WebPointerProperties::PointerType::Touch, 0,
452 m_mappedIdStart, true, 454 m_mappedIdStart, true,
453 PlatformTouchPoint::TouchMoved, 3); 455 PlatformTouchPoint::TouchMoved, 3);
454 } 456 }
455 457
456 } // namespace blink 458 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698