| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 KeyboardEventInit keyEventInit; | 59 KeyboardEventInit keyEventInit; |
| 60 keyEventInit.setBubbles(true); | 60 keyEventInit.setBubbles(true); |
| 61 keyEventInit.setCancelable(true); | 61 keyEventInit.setCancelable(true); |
| 62 keyEventInit.setLocation(location); | 62 keyEventInit.setLocation(location); |
| 63 return new KeyboardEvent("keydown", keyEventInit); | 63 return new KeyboardEvent("keydown", keyEventInit); |
| 64 } | 64 } |
| 65 | 65 |
| 66 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) { | 66 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) { |
| 67 KeyboardEvent* event = createKeyboardEventWithLocation(location); | 67 KeyboardEvent* event = createKeyboardEventWithLocation(location); |
| 68 WebKeyboardEventBuilder convertedEvent(*event); | 68 WebKeyboardEventBuilder convertedEvent(*event); |
| 69 return convertedEvent.modifiers; | 69 return convertedEvent.modifiers(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) { | 72 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) { |
| 73 // Test key location conversion. | 73 // Test key location conversion. |
| 74 int modifiers = | 74 int modifiers = |
| 75 getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationStandard); | 75 getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationStandard); |
| 76 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || | 76 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || |
| 77 modifiers & WebInputEvent::IsLeft || | 77 modifiers & WebInputEvent::IsLeft || |
| 78 modifiers & WebInputEvent::IsRight); | 78 modifiers & WebInputEvent::IsRight); |
| 79 | 79 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 92 modifiers = | 92 modifiers = |
| 93 getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationNumpad); | 93 getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationNumpad); |
| 94 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); | 94 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); |
| 95 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || | 95 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || |
| 96 modifiers & WebInputEvent::IsRight); | 96 modifiers & WebInputEvent::IsRight); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST(WebInputEventConversionTest, WebMouseEventBuilder) { | 99 TEST(WebInputEventConversionTest, WebMouseEventBuilder) { |
| 100 TouchEvent* event = TouchEvent::create(); | 100 TouchEvent* event = TouchEvent::create(); |
| 101 WebMouseEventBuilder mouse(0, 0, *event); | 101 WebMouseEventBuilder mouse(0, 0, *event); |
| 102 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); | 102 EXPECT_EQ(WebInputEvent::Undefined, mouse.type()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST(WebInputEventConversionTest, WebTouchEventBuilder) { | 105 TEST(WebInputEventConversionTest, WebTouchEventBuilder) { |
| 106 const std::string baseURL("http://www.test0.com/"); | 106 const std::string baseURL("http://www.test0.com/"); |
| 107 const std::string fileName("fixed_layout.html"); | 107 const std::string fileName("fixed_layout.html"); |
| 108 | 108 |
| 109 URLTestHelpers::registerMockedURLFromBaseURL( | 109 URLTestHelpers::registerMockedURLFromBaseURL( |
| 110 WebString::fromUTF8(baseURL.c_str()), | 110 WebString::fromUTF8(baseURL.c_str()), |
| 111 WebString::fromUTF8("fixed_layout.html")); | 111 WebString::fromUTF8("fixed_layout.html")); |
| 112 FrameTestHelpers::WebViewHelper webViewHelper; | 112 FrameTestHelpers::WebViewHelper webViewHelper; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 { | 147 { |
| 148 TouchList* touchList = TouchList::create(); | 148 TouchList* touchList = TouchList::create(); |
| 149 touchList->append(touch0); | 149 touchList->append(touch0); |
| 150 TouchEvent* touchEvent = TouchEvent::create( | 150 TouchEvent* touchEvent = TouchEvent::create( |
| 151 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, | 151 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, |
| 152 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), | 152 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), |
| 153 TouchActionAuto, WebPointerProperties::PointerType::Touch); | 153 TouchActionAuto, WebPointerProperties::PointerType::Touch); |
| 154 | 154 |
| 155 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 155 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 156 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | 156 ASSERT_EQ(1u, webTouchBuilder.touchesLength); |
| 157 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); | 157 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type()); |
| 158 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state); | 158 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state); |
| 159 EXPECT_FLOAT_EQ(p0.screenPosition.x, | 159 EXPECT_FLOAT_EQ(p0.screenPosition.x, |
| 160 webTouchBuilder.touches[0].screenPosition.x); | 160 webTouchBuilder.touches[0].screenPosition.x); |
| 161 EXPECT_FLOAT_EQ(p0.screenPosition.y, | 161 EXPECT_FLOAT_EQ(p0.screenPosition.y, |
| 162 webTouchBuilder.touches[0].screenPosition.y); | 162 webTouchBuilder.touches[0].screenPosition.y); |
| 163 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); | 163 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); |
| 164 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); | 164 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); |
| 165 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); | 165 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); |
| 166 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); | 166 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); |
| 167 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAngle); | 167 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAngle); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 192 activeTouchList->append(touch1); | 192 activeTouchList->append(touch1); |
| 193 movedTouchList->append(touch0); | 193 movedTouchList->append(touch0); |
| 194 TouchEvent* touchEvent = TouchEvent::create( | 194 TouchEvent* touchEvent = TouchEvent::create( |
| 195 activeTouchList, activeTouchList, movedTouchList, | 195 activeTouchList, activeTouchList, movedTouchList, |
| 196 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, | 196 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, |
| 197 false, true, TimeTicks(), TouchActionAuto, | 197 false, true, TimeTicks(), TouchActionAuto, |
| 198 WebPointerProperties::PointerType::Touch); | 198 WebPointerProperties::PointerType::Touch); |
| 199 | 199 |
| 200 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 200 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 201 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 201 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 202 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); | 202 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type()); |
| 203 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); | 203 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); |
| 204 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].state); | 204 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].state); |
| 205 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 205 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 206 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 206 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 207 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | 207 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Test touchmove, different point yields same ordering. | 210 // Test touchmove, different point yields same ordering. |
| 211 { | 211 { |
| 212 TouchList* activeTouchList = TouchList::create(); | 212 TouchList* activeTouchList = TouchList::create(); |
| 213 TouchList* movedTouchList = TouchList::create(); | 213 TouchList* movedTouchList = TouchList::create(); |
| 214 activeTouchList->append(touch0); | 214 activeTouchList->append(touch0); |
| 215 activeTouchList->append(touch1); | 215 activeTouchList->append(touch1); |
| 216 movedTouchList->append(touch1); | 216 movedTouchList->append(touch1); |
| 217 TouchEvent* touchEvent = TouchEvent::create( | 217 TouchEvent* touchEvent = TouchEvent::create( |
| 218 activeTouchList, activeTouchList, movedTouchList, | 218 activeTouchList, activeTouchList, movedTouchList, |
| 219 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, | 219 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, |
| 220 false, true, TimeTicks(), TouchActionAuto, | 220 false, true, TimeTicks(), TouchActionAuto, |
| 221 WebPointerProperties::PointerType::Touch); | 221 WebPointerProperties::PointerType::Touch); |
| 222 | 222 |
| 223 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 223 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 224 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 224 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 225 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); | 225 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type()); |
| 226 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); | 226 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); |
| 227 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); | 227 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); |
| 228 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 228 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 229 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 229 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 230 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | 230 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Test touchend. | 233 // Test touchend. |
| 234 { | 234 { |
| 235 TouchList* activeTouchList = TouchList::create(); | 235 TouchList* activeTouchList = TouchList::create(); |
| 236 TouchList* releasedTouchList = TouchList::create(); | 236 TouchList* releasedTouchList = TouchList::create(); |
| 237 activeTouchList->append(touch0); | 237 activeTouchList->append(touch0); |
| 238 releasedTouchList->append(touch1); | 238 releasedTouchList->append(touch1); |
| 239 TouchEvent* touchEvent = TouchEvent::create( | 239 TouchEvent* touchEvent = TouchEvent::create( |
| 240 activeTouchList, activeTouchList, releasedTouchList, | 240 activeTouchList, activeTouchList, releasedTouchList, |
| 241 EventTypeNames::touchend, domWindow, PlatformEvent::NoModifiers, false, | 241 EventTypeNames::touchend, domWindow, PlatformEvent::NoModifiers, false, |
| 242 false, false, TimeTicks(), TouchActionAuto, | 242 false, false, TimeTicks(), TouchActionAuto, |
| 243 WebPointerProperties::PointerType::Touch); | 243 WebPointerProperties::PointerType::Touch); |
| 244 | 244 |
| 245 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 245 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 246 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 246 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 247 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); | 247 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type()); |
| 248 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); | 248 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); |
| 249 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state); | 249 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state); |
| 250 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 250 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 251 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 251 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 252 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | 252 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Test touchcancel. | 255 // Test touchcancel. |
| 256 { | 256 { |
| 257 TouchList* activeTouchList = TouchList::create(); | 257 TouchList* activeTouchList = TouchList::create(); |
| 258 TouchList* cancelledTouchList = TouchList::create(); | 258 TouchList* cancelledTouchList = TouchList::create(); |
| 259 cancelledTouchList->append(touch0); | 259 cancelledTouchList->append(touch0); |
| 260 cancelledTouchList->append(touch1); | 260 cancelledTouchList->append(touch1); |
| 261 TouchEvent* touchEvent = TouchEvent::create( | 261 TouchEvent* touchEvent = TouchEvent::create( |
| 262 activeTouchList, activeTouchList, cancelledTouchList, | 262 activeTouchList, activeTouchList, cancelledTouchList, |
| 263 EventTypeNames::touchcancel, domWindow, PlatformEvent::NoModifiers, | 263 EventTypeNames::touchcancel, domWindow, PlatformEvent::NoModifiers, |
| 264 false, false, false, TimeTicks(), TouchActionAuto, | 264 false, false, false, TimeTicks(), TouchActionAuto, |
| 265 WebPointerProperties::PointerType::Touch); | 265 WebPointerProperties::PointerType::Touch); |
| 266 | 266 |
| 267 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 267 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 268 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 268 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
| 269 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); | 269 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type()); |
| 270 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].state); | 270 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].state); |
| 271 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].state); | 271 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].state); |
| 272 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 272 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
| 273 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 273 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 274 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | 274 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Test max point limit. | 277 // Test max point limit. |
| 278 { | 278 { |
| 279 TouchList* touchList = TouchList::create(); | 279 TouchList* touchList = TouchList::create(); |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), | 1105 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), |
| 1106 platformMouseBuilder.position().x()); | 1106 platformMouseBuilder.position().x()); |
| 1107 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), | 1107 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), |
| 1108 platformMouseBuilder.position().y()); | 1108 platformMouseBuilder.position().y()); |
| 1109 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); | 1109 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); |
| 1110 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); | 1110 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); |
| 1111 } | 1111 } |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 } // namespace blink | 1114 } // namespace blink |
| OLD | NEW |