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

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

Issue 560493003: Remove WebTouchEvent.changedTouches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@input_remove_target_changed_touches
Patch Set: Fix test Created 6 years, 3 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
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | public/web/WebInputEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 RefPtrWillBeRawPtr<Touch> touch1 = Touch::create(toLocalFrame(webViewImpl->p age()->mainFrame()), document.get(), p1.id, p1.screenPosition, p1.position, Floa tSize(p1.radiusX, p1.radiusY), p1.rotationAngle, p1.force); 126 RefPtrWillBeRawPtr<Touch> touch1 = Touch::create(toLocalFrame(webViewImpl->p age()->mainFrame()), document.get(), p1.id, p1.screenPosition, p1.position, Floa tSize(p1.radiusX, p1.radiusY), p1.rotationAngle, p1.force);
127 127
128 // Test touchstart. 128 // Test touchstart.
129 { 129 {
130 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); 130 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create();
131 touchList->append(touch0); 131 touchList->append(touch0);
132 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow, false, false, false, false, false); 132 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow, false, false, false, false, false);
133 133
134 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 134 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
135 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 135 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
136 ASSERT_EQ(0u, webTouchBuilder.changedTouchesLength);
137 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); 136 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type);
138 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state) ; 137 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state) ;
139 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo sition.x); 138 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo sition.x);
140 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo sition.y); 139 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo sition.y);
141 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); 140 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x);
142 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); 141 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y);
143 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); 142 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX);
144 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); 143 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY);
145 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng le); 144 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng le);
146 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); 145 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force);
147 } 146 }
148 147
149 // Test touchmove. 148 // Test touchmove.
150 { 149 {
151 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); 150 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create();
152 RefPtrWillBeRawPtr<TouchList> movedTouchList = TouchList::create(); 151 RefPtrWillBeRawPtr<TouchList> movedTouchList = TouchList::create();
153 activeTouchList->append(touch0); 152 activeTouchList->append(touch0);
154 activeTouchList->append(touch1); 153 activeTouchList->append(touch1);
155 movedTouchList->append(touch0); 154 movedTouchList->append(touch0);
156 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), movedTouchList.get(), EventTypeNames::touch move, domWindow, false, false, false, false, false); 155 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), movedTouchList.get(), EventTypeNames::touch move, domWindow, false, false, false, false, false);
157 156
158 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 157 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
159 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 158 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
160 ASSERT_EQ(0u, webTouchBuilder.changedTouchesLength);
161 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); 159 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type);
162 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); 160 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state);
163 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te); 161 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te);
164 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 162 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
165 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 163 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
166 } 164 }
167 165
168 // Test touchend. 166 // Test touchend.
169 { 167 {
170 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); 168 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create();
171 RefPtrWillBeRawPtr<TouchList> releasedTouchList = TouchList::create(); 169 RefPtrWillBeRawPtr<TouchList> releasedTouchList = TouchList::create();
172 activeTouchList->append(touch0); 170 activeTouchList->append(touch0);
173 releasedTouchList->append(touch1); 171 releasedTouchList->append(touch1);
174 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), releasedTouchList.get(), EventTypeNames::to uchend, domWindow, false, false, false, false, false); 172 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), releasedTouchList.get(), EventTypeNames::to uchend, domWindow, false, false, false, false, false);
175 173
176 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 174 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
177 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 175 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
178 ASSERT_EQ(0u, webTouchBuilder.changedTouchesLength);
179 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); 176 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type);
180 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[0].state ); 177 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[0].state );
181 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te); 178 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta te);
182 EXPECT_EQ(p1.id, webTouchBuilder.touches[0].id); 179 EXPECT_EQ(p1.id, webTouchBuilder.touches[0].id);
183 EXPECT_EQ(p0.id, webTouchBuilder.touches[1].id); 180 EXPECT_EQ(p0.id, webTouchBuilder.touches[1].id);
184 } 181 }
185 182
186 // Test touchcancel. 183 // Test touchcancel.
187 { 184 {
188 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); 185 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create();
189 RefPtrWillBeRawPtr<TouchList> cancelledTouchList = TouchList::create(); 186 RefPtrWillBeRawPtr<TouchList> cancelledTouchList = TouchList::create();
190 cancelledTouchList->append(touch0); 187 cancelledTouchList->append(touch0);
191 cancelledTouchList->append(touch1); 188 cancelledTouchList->append(touch1);
192 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), cancelledTouchList.get(), EventTypeNames::t ouchcancel, domWindow, false, false, false, false, false); 189 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou chList.get(), activeTouchList.get(), cancelledTouchList.get(), EventTypeNames::t ouchcancel, domWindow, false, false, false, false, false);
193 190
194 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 191 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
195 ASSERT_EQ(2u, webTouchBuilder.touchesLength); 192 ASSERT_EQ(2u, webTouchBuilder.touchesLength);
196 ASSERT_EQ(0u, webTouchBuilder.changedTouchesLength);
197 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); 193 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type);
198 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat e); 194 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat e);
199 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat e); 195 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat e);
200 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); 196 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id);
201 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); 197 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id);
202 } 198 }
203 199
204 // Test max point limit. 200 // Test max point limit.
205 { 201 {
206 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); 202 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create();
207 RefPtrWillBeRawPtr<TouchList> changedTouchList = TouchList::create(); 203 RefPtrWillBeRawPtr<TouchList> changedTouchList = TouchList::create();
208 for (unsigned i = 0; i <= static_cast<unsigned>(WebTouchEvent::touchesLe ngthCap) * 2; ++i) { 204 for (unsigned i = 0; i <= static_cast<unsigned>(WebTouchEvent::touchesLe ngthCap) * 2; ++i) {
209 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webView Impl->page()->mainFrame()), document.get(), i, p0.screenPosition, p0.position, F loatSize(p0.radiusX, p0.radiusY), p0.rotationAngle, p0.force); 205 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webView Impl->page()->mainFrame()), document.get(), i, p0.screenPosition, p0.position, F loatSize(p0.radiusX, p0.radiusY), p0.rotationAngle, p0.force);
210 touchList->append(touch); 206 touchList->append(touch);
211 changedTouchList->append(touch); 207 changedTouchList->append(touch);
212 } 208 }
213 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow, false, false, false, false, false); 209 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow, false, false, false, false, false);
214 210
215 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 211 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
216 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), webTou chBuilder.touchesLength); 212 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), webTou chBuilder.touchesLength);
217 ASSERT_EQ(0u, webTouchBuilder.changedTouchesLength);
218 } 213 }
219 } 214 }
220 215
221 TEST(WebInputEventConversionTest, InputEventsScaling) 216 TEST(WebInputEventConversionTest, InputEventsScaling)
222 { 217 {
223 const std::string baseURL("http://www.test.com/"); 218 const std::string baseURL("http://www.test.com/");
224 const std::string fileName("fixed_layout.html"); 219 const std::string fileName("fixed_layout.html");
225 220
226 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
227 FrameTestHelpers::WebViewHelper webViewHelper; 222 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 707
713 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 708 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
714 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); 709 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x());
715 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); 710 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y());
716 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); 711 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x());
717 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); 712 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y());
718 } 713 }
719 } 714 }
720 715
721 } // anonymous namespace 716 } // anonymous namespace
OLDNEW
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | public/web/WebInputEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698