| OLD | NEW |
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 p0.rotationAngle = p1.rotationAngle = 1.f; | 123 p0.rotationAngle = p1.rotationAngle = 1.f; |
| 124 p0.force = p1.force = 25.f; | 124 p0.force = p1.force = 25.f; |
| 125 | 125 |
| 126 RefPtrWillBeRawPtr<Touch> touch0 = Touch::create(toLocalFrame(webViewImpl->p
age()->mainFrame()), document.get(), p0.id, p0.screenPosition, p0.position, Floa
tSize(p0.radiusX, p0.radiusY), p0.rotationAngle, p0.force); | 126 RefPtrWillBeRawPtr<Touch> touch0 = Touch::create(toLocalFrame(webViewImpl->p
age()->mainFrame()), document.get(), p0.id, p0.screenPosition, p0.position, Floa
tSize(p0.radiusX, p0.radiusY), p0.rotationAngle, p0.force); |
| 127 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 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); |
| 128 | 128 |
| 129 // Test touchstart. | 129 // Test touchstart. |
| 130 { | 130 { |
| 131 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); | 131 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); |
| 132 touchList->append(touch0); | 132 touchList->append(touch0); |
| 133 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow,
false, false, false, false, false); | 133 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow,
false, false, false, false, false, false); |
| 134 | 134 |
| 135 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 135 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 136 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | 136 ASSERT_EQ(1u, webTouchBuilder.touchesLength); |
| 137 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); | 137 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); |
| 138 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state)
; | 138 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state)
; |
| 139 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo
sition.x); | 139 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); | 140 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo
sition.y); |
| 141 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); | 141 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); |
| 142 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); | 142 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); |
| 143 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); | 143 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); |
| 144 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); | 144 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); |
| 145 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng
le); | 145 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng
le); |
| 146 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); | 146 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Test touchmove. | 149 // Test touchmove. |
| 150 { | 150 { |
| 151 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); | 151 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); |
| 152 RefPtrWillBeRawPtr<TouchList> movedTouchList = TouchList::create(); | 152 RefPtrWillBeRawPtr<TouchList> movedTouchList = TouchList::create(); |
| 153 activeTouchList->append(touch0); | 153 activeTouchList->append(touch0); |
| 154 activeTouchList->append(touch1); | 154 activeTouchList->append(touch1); |
| 155 movedTouchList->append(touch0); | 155 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); | 156 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou
chList.get(), activeTouchList.get(), movedTouchList.get(), EventTypeNames::touch
move, domWindow, false, false, false, false, false, false); |
| 157 | 157 |
| 158 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 158 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 159 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 159 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 160 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); | 160 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); |
| 161 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); | 161 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); |
| 162 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); | 162 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); |
| 163 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 163 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 164 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 164 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Test touchend. | 167 // Test touchend. |
| 168 { | 168 { |
| 169 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); | 169 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); |
| 170 RefPtrWillBeRawPtr<TouchList> releasedTouchList = TouchList::create(); | 170 RefPtrWillBeRawPtr<TouchList> releasedTouchList = TouchList::create(); |
| 171 activeTouchList->append(touch0); | 171 activeTouchList->append(touch0); |
| 172 releasedTouchList->append(touch1); | 172 releasedTouchList->append(touch1); |
| 173 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou
chList.get(), activeTouchList.get(), releasedTouchList.get(), EventTypeNames::to
uchend, domWindow, false, false, false, false, false); | 173 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou
chList.get(), activeTouchList.get(), releasedTouchList.get(), EventTypeNames::to
uchend, domWindow, false, false, false, false, false, false); |
| 174 | 174 |
| 175 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 175 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 176 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 176 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 177 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); | 177 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); |
| 178 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[0].state
); | 178 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[0].state
); |
| 179 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); | 179 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); |
| 180 EXPECT_EQ(p1.id, webTouchBuilder.touches[0].id); | 180 EXPECT_EQ(p1.id, webTouchBuilder.touches[0].id); |
| 181 EXPECT_EQ(p0.id, webTouchBuilder.touches[1].id); | 181 EXPECT_EQ(p0.id, webTouchBuilder.touches[1].id); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Test touchcancel. | 184 // Test touchcancel. |
| 185 { | 185 { |
| 186 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); | 186 RefPtrWillBeRawPtr<TouchList> activeTouchList = TouchList::create(); |
| 187 RefPtrWillBeRawPtr<TouchList> cancelledTouchList = TouchList::create(); | 187 RefPtrWillBeRawPtr<TouchList> cancelledTouchList = TouchList::create(); |
| 188 cancelledTouchList->append(touch0); | 188 cancelledTouchList->append(touch0); |
| 189 cancelledTouchList->append(touch1); | 189 cancelledTouchList->append(touch1); |
| 190 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou
chList.get(), activeTouchList.get(), cancelledTouchList.get(), EventTypeNames::t
ouchcancel, domWindow, false, false, false, false, false); | 190 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(activeTou
chList.get(), activeTouchList.get(), cancelledTouchList.get(), EventTypeNames::t
ouchcancel, domWindow, false, false, false, false, false, false); |
| 191 | 191 |
| 192 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 192 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 193 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 193 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 194 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); | 194 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); |
| 195 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat
e); | 195 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat
e); |
| 196 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat
e); | 196 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat
e); |
| 197 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 197 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 198 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 198 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // Test max point limit. | 201 // Test max point limit. |
| 202 { | 202 { |
| 203 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); | 203 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); |
| 204 RefPtrWillBeRawPtr<TouchList> changedTouchList = TouchList::create(); | 204 RefPtrWillBeRawPtr<TouchList> changedTouchList = TouchList::create(); |
| 205 for (unsigned i = 0; i <= static_cast<unsigned>(WebTouchEvent::touchesLe
ngthCap) * 2; ++i) { | 205 for (unsigned i = 0; i <= static_cast<unsigned>(WebTouchEvent::touchesLe
ngthCap) * 2; ++i) { |
| 206 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); | 206 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); |
| 207 touchList->append(touch); | 207 touchList->append(touch); |
| 208 changedTouchList->append(touch); | 208 changedTouchList->append(touch); |
| 209 } | 209 } |
| 210 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow,
false, false, false, false, false); | 210 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchstart, domWindow,
false, false, false, false, false, false); |
| 211 | 211 |
| 212 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 212 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 213 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), webTou
chBuilder.touchesLength); | 213 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), webTou
chBuilder.touchesLength); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST(WebInputEventConversionTest, InputEventsScaling) | 217 TEST(WebInputEventConversionTest, InputEventsScaling) |
| 218 { | 218 { |
| 219 const std::string baseURL("http://www.test1.com/"); | 219 const std::string baseURL("http://www.test1.com/"); |
| 220 const std::string fileName("fixed_layout.html"); | 220 const std::string fileName("fixed_layout.html"); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 EXPECT_EQ(32, webGestureBuilder.data.scrollUpdate.deltaY); | 416 EXPECT_EQ(32, webGestureBuilder.data.scrollUpdate.deltaY); |
| 417 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityX); | 417 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityX); |
| 418 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityY); | 418 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityY); |
| 419 EXPECT_FALSE(webGestureBuilder.data.scrollUpdate.preventPropagation); | 419 EXPECT_FALSE(webGestureBuilder.data.scrollUpdate.preventPropagation); |
| 420 } | 420 } |
| 421 | 421 |
| 422 { | 422 { |
| 423 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webViewImpl
->page()->mainFrame()), document.get(), 0, FloatPoint(10, 9.5), FloatPoint(3.5,
2), FloatSize(4, 4.5), 0, 0); | 423 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webViewImpl
->page()->mainFrame()), document.get(), 0, FloatPoint(10, 9.5), FloatPoint(3.5,
2), FloatSize(4, 4.5), 0, 0); |
| 424 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); | 424 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); |
| 425 touchList->append(touch); | 425 touchList->append(touch); |
| 426 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchmove, domWindow,
false, false, false, false, false); | 426 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchmove, domWindow,
false, false, false, false, false, false); |
| 427 | 427 |
| 428 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 428 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 429 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | 429 ASSERT_EQ(1u, webTouchBuilder.touchesLength); |
| 430 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); | 430 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); |
| 431 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); | 431 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); |
| 432 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); | 432 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); |
| 433 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); | 433 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); |
| 434 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); | 434 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); |
| 435 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); | 435 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); |
| 436 EXPECT_FALSE(webTouchBuilder.cancelable); | 436 EXPECT_FALSE(webTouchBuilder.cancelable); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 852 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
| 853 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 853 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
| 854 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 854 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
| 855 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | 855 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
| 856 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 856 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 857 EXPECT_TRUE(platformWheelBuilder.canScroll()); | 857 EXPECT_TRUE(platformWheelBuilder.canScroll()); |
| 858 } | 858 } |
| 859 } | 859 } |
| 860 | 860 |
| 861 } // anonymous namespace | 861 } // anonymous namespace |
| OLD | NEW |