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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp

Issue 1888163003: Articulate the cancel behavior in the WebTouchEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and non-const ref passed back Created 4 years, 8 months 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); 132 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type);
133 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state) ; 133 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state) ;
134 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo sition.x); 134 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo sition.x);
135 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo sition.y); 135 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo sition.y);
136 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); 136 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x);
137 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); 137 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y);
138 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); 138 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX);
139 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); 139 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY);
140 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng le); 140 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng le);
141 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); 141 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force);
142 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
143 }
144
145 // Test cancelable touchstart.
146 {
147 TouchList* touchList = TouchList::create();
148 touchList->append(touch0);
149 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL ist, EventTypeNames::touchstart, domWindow, PlatformEvent::NoModifiers, true, fa lse, 0);
150
151 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
152 EXPECT_EQ(WebInputEvent::Blocking, webTouchBuilder.dispatchType);
142 } 153 }
143 154
144 // Test touchmove. 155 // Test touchmove.
145 { 156 {
146 TouchList* activeTouchList = TouchList::create(); 157 TouchList* activeTouchList = TouchList::create();
147 TouchList* movedTouchList = TouchList::create(); 158 TouchList* movedTouchList = TouchList::create();
148 activeTouchList->append(touch0); 159 activeTouchList->append(touch0);
149 activeTouchList->append(touch1); 160 activeTouchList->append(touch1);
150 movedTouchList->append(touch0); 161 movedTouchList->append(touch0);
151 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod ifiers, false, false, 0); 162 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod ifiers, false, false, 0);
152 163
153 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 164 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
154 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 165 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
155 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); 166 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type);
156 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); 167 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state);
157 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te); 168 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te);
158 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 169 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
159 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 170 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
171 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
160 } 172 }
161 173
162 // Test touchmove, different point yields same ordering. 174 // Test touchmove, different point yields same ordering.
163 { 175 {
164 TouchList* activeTouchList = TouchList::create(); 176 TouchList* activeTouchList = TouchList::create();
165 TouchList* movedTouchList = TouchList::create(); 177 TouchList* movedTouchList = TouchList::create();
166 activeTouchList->append(touch0); 178 activeTouchList->append(touch0);
167 activeTouchList->append(touch1); 179 activeTouchList->append(touch1);
168 movedTouchList->append(touch1); 180 movedTouchList->append(touch1);
169 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod ifiers, false, false, 0); 181 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod ifiers, false, false, 0);
170 182
171 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 183 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
172 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 184 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
173 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); 185 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type);
174 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta te); 186 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta te);
175 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); 187 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state);
176 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 188 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
177 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 189 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
190 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
178 } 191 }
179 192
180 // Test touchend. 193 // Test touchend.
181 { 194 {
182 TouchList* activeTouchList = TouchList::create(); 195 TouchList* activeTouchList = TouchList::create();
183 TouchList* releasedTouchList = TouchList::create(); 196 TouchList* releasedTouchList = TouchList::create();
184 activeTouchList->append(touch0); 197 activeTouchList->append(touch0);
185 releasedTouchList->append(touch1); 198 releasedTouchList->append(touch1);
186 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, releasedTouchList, EventTypeNames::touchend, domWindow, PlatformEvent::NoM odifiers, false, false, 0); 199 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, releasedTouchList, EventTypeNames::touchend, domWindow, PlatformEvent::NoM odifiers, false, false, 0);
187 200
188 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 201 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
189 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 202 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
190 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); 203 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type);
191 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta te); 204 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta te);
192 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state ); 205 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state );
193 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 206 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
194 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 207 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
208 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
195 } 209 }
196 210
197 // Test touchcancel. 211 // Test touchcancel.
198 { 212 {
199 TouchList* activeTouchList = TouchList::create(); 213 TouchList* activeTouchList = TouchList::create();
200 TouchList* cancelledTouchList = TouchList::create(); 214 TouchList* cancelledTouchList = TouchList::create();
201 cancelledTouchList->append(touch0); 215 cancelledTouchList->append(touch0);
202 cancelledTouchList->append(touch1); 216 cancelledTouchList->append(touch1);
203 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, cancelledTouchList, EventTypeNames::touchcancel, domWindow, PlatformEvent: :NoModifiers, false, false, 0); 217 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch List, cancelledTouchList, EventTypeNames::touchcancel, domWindow, PlatformEvent: :NoModifiers, false, false, 0);
204 218
205 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 219 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
206 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 220 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
207 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); 221 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type);
208 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat e); 222 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat e);
209 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat e); 223 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat e);
210 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 224 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
211 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 225 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
226 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
212 } 227 }
213 228
214 // Test max point limit. 229 // Test max point limit.
215 { 230 {
216 TouchList* touchList = TouchList::create(); 231 TouchList* touchList = TouchList::create();
217 TouchList* changedTouchList = TouchList::create(); 232 TouchList* changedTouchList = TouchList::create();
218 for (int i = 0; i <= static_cast<int>(WebTouchEvent::touchesLengthCap) * 2; ++i) { 233 for (int i = 0; i <= static_cast<int>(WebTouchEvent::touchesLengthCap) * 2; ++i) {
219 Touch* touch = Touch::create(toLocalFrame(webViewImpl->page()->mainF rame()), document, i, p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.r adiusY), p0.rotationAngle, p0.force, String()); 234 Touch* touch = Touch::create(toLocalFrame(webViewImpl->page()->mainF rame()), document, i, p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.r adiusY), p0.rotationAngle, p0.force, String());
220 touchList->append(touch); 235 touchList->append(touch);
221 changedTouchList->append(touch); 236 changedTouchList->append(touch);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL ist, EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, fa lse, 0); 485 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL ist, EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, fa lse, 0);
471 486
472 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); 487 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent);
473 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 488 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
474 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); 489 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
475 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); 490 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y);
476 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); 491 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x);
477 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); 492 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y);
478 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); 493 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX);
479 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); 494 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY);
480 EXPECT_FALSE(webTouchBuilder.cancelable); 495 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType) ;
481 } 496 }
482 } 497 }
483 498
484 TEST(WebInputEventConversionTest, InputEventsTransform) 499 TEST(WebInputEventConversionTest, InputEventsTransform)
485 { 500 {
486 const std::string baseURL("http://www.test2.com/"); 501 const std::string baseURL("http://www.test2.com/");
487 const std::string fileName("fixed_layout.html"); 502 const std::string fileName("fixed_layout.html");
488 503
489 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 504 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
490 FrameTestHelpers::WebViewHelper webViewHelper; 505 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 EXPECT_EQ(5, platformGestureBuilder.position().y()); 1072 EXPECT_EQ(5, platformGestureBuilder.position().y());
1058 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); 1073 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x());
1059 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); 1074 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y());
1060 EXPECT_FALSE(platformGestureBuilder.inertial()); 1075 EXPECT_FALSE(platformGestureBuilder.inertial());
1061 EXPECT_TRUE(platformGestureBuilder.synthetic()); 1076 EXPECT_TRUE(platformGestureBuilder.synthetic());
1062 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU nits()); 1077 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU nits());
1063 } 1078 }
1064 } 1079 }
1065 1080
1066 } // namespace blink 1081 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/TouchActionTest.cpp ('k') | third_party/WebKit/public/web/WebInputEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698