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

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

Issue 398673003: Rename WebCore namespace to blink in bindings and web (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/WebImageTest.cpp ('k') | Source/web/tests/WebPageNewSerializerTest.cpp » ('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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "core/rendering/RenderView.h" 45 #include "core/rendering/RenderView.h"
46 #include "public/web/WebFrame.h" 46 #include "public/web/WebFrame.h"
47 #include "public/web/WebSettings.h" 47 #include "public/web/WebSettings.h"
48 #include "web/WebViewImpl.h" 48 #include "web/WebViewImpl.h"
49 #include "web/tests/FrameTestHelpers.h" 49 #include "web/tests/FrameTestHelpers.h"
50 #include "web/tests/URLTestHelpers.h" 50 #include "web/tests/URLTestHelpers.h"
51 #include <gtest/gtest.h> 51 #include <gtest/gtest.h>
52 52
53 using namespace blink; 53 using namespace blink;
54 using namespace WebCore; 54 using namespace blink;
55 55
56 namespace { 56 namespace {
57 57
58 PassRefPtrWillBeRawPtr<WebCore::KeyboardEvent> createKeyboardEventWithLocation(W ebCore::KeyboardEvent::KeyLocationCode location) 58 PassRefPtrWillBeRawPtr<blink::KeyboardEvent> createKeyboardEventWithLocation(bli nk::KeyboardEvent::KeyLocationCode location)
59 { 59 {
60 return WebCore::KeyboardEvent::create("keydown", true, true, 0, "", location , false, false, false, false, false); 60 return blink::KeyboardEvent::create("keydown", true, true, 0, "", location, false, false, false, false, false);
61 } 61 }
62 62
63 int getModifiersForKeyLocationCode(WebCore::KeyboardEvent::KeyLocationCode locat ion) 63 int getModifiersForKeyLocationCode(blink::KeyboardEvent::KeyLocationCode locatio n)
64 { 64 {
65 RefPtrWillBeRawPtr<WebCore::KeyboardEvent> event = createKeyboardEventWithLo cation(location); 65 RefPtrWillBeRawPtr<blink::KeyboardEvent> event = createKeyboardEventWithLoca tion(location);
66 blink::WebKeyboardEventBuilder convertedEvent(*event); 66 blink::WebKeyboardEventBuilder convertedEvent(*event);
67 return convertedEvent.modifiers; 67 return convertedEvent.modifiers;
68 } 68 }
69 69
70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) 70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder)
71 { 71 {
72 // Test key location conversion. 72 // Test key location conversion.
73 int modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_K EY_LOCATION_STANDARD); 73 int modifiers = getModifiersForKeyLocationCode(blink::KeyboardEvent::DOM_KEY _LOCATION_STANDARD);
74 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); 74 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight);
75 75
76 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_LEFT); 76 modifiers = getModifiersForKeyLocationCode(blink::KeyboardEvent::DOM_KEY_LOC ATION_LEFT);
77 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); 77 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft);
78 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight); 78 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight);
79 79
80 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_RIGHT); 80 modifiers = getModifiersForKeyLocationCode(blink::KeyboardEvent::DOM_KEY_LOC ATION_RIGHT);
81 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); 81 EXPECT_TRUE(modifiers & WebInputEvent::IsRight);
82 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft); 82 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft);
83 83
84 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_NUMPAD); 84 modifiers = getModifiersForKeyLocationCode(blink::KeyboardEvent::DOM_KEY_LOC ATION_NUMPAD);
85 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); 85 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad);
86 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight); 86 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight);
87 } 87 }
88 88
89 TEST(WebInputEventConversionTest, WebTouchEventBuilder) 89 TEST(WebInputEventConversionTest, WebTouchEventBuilder)
90 { 90 {
91 RefPtrWillBeRawPtr<WebCore::TouchEvent> event = WebCore::TouchEvent::create( ); 91 RefPtrWillBeRawPtr<blink::TouchEvent> event = blink::TouchEvent::create();
92 WebMouseEventBuilder mouse(0, 0, *event); 92 WebMouseEventBuilder mouse(0, 0, *event);
93 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); 93 EXPECT_EQ(WebInputEvent::Undefined, mouse.type);
94 } 94 }
95 95
96 TEST(WebInputEventConversionTest, InputEventsScaling) 96 TEST(WebInputEventConversionTest, InputEventsScaling)
97 { 97 {
98 const std::string baseURL("http://www.test.com/"); 98 const std::string baseURL("http://www.test.com/");
99 const std::string fileName("fixed_layout.html"); 99 const std::string fileName("fixed_layout.html");
100 100
101 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 101 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].pos().x()); 245 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].pos().x());
246 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].pos().y()); 246 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].pos().y());
247 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].radius().wid th()); 247 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].radius().wid th());
248 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].radius().hei ght()); 248 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].radius().hei ght());
249 } 249 }
250 250
251 // Reverse builders should *not* go back to physical pixels, as they are use d for plugins 251 // Reverse builders should *not* go back to physical pixels, as they are use d for plugins
252 // which expect CSS pixel coordinates. 252 // which expect CSS pixel coordinates.
253 { 253 {
254 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); 254 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
255 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore:: EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); 255 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(blink::Ev entTypeNames::mousemove, domWindow, platformMouseEvent, 0, document);
256 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt); 256 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt);
257 257
258 EXPECT_EQ(10, webMouseBuilder.x); 258 EXPECT_EQ(10, webMouseBuilder.x);
259 EXPECT_EQ(10, webMouseBuilder.y); 259 EXPECT_EQ(10, webMouseBuilder.y);
260 EXPECT_EQ(10, webMouseBuilder.globalX); 260 EXPECT_EQ(10, webMouseBuilder.globalX);
261 EXPECT_EQ(10, webMouseBuilder.globalY); 261 EXPECT_EQ(10, webMouseBuilder.globalY);
262 EXPECT_EQ(10, webMouseBuilder.windowX); 262 EXPECT_EQ(10, webMouseBuilder.windowX);
263 EXPECT_EQ(10, webMouseBuilder.windowY); 263 EXPECT_EQ(10, webMouseBuilder.windowY);
264 } 264 }
265 265
266 { 266 {
267 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , NoButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); 267 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10) , NoButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
268 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore:: EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); 268 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(blink::Ev entTypeNames::mousemove, domWindow, platformMouseEvent, 0, document);
269 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt); 269 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve nt);
270 EXPECT_EQ(WebMouseEvent::ButtonNone, webMouseBuilder.button); 270 EXPECT_EQ(WebMouseEvent::ButtonNone, webMouseBuilder.button);
271 } 271 }
272 272
273 { 273 {
274 PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUp date, IntPoint(10, 10), IntPoint(10, 10), IntSize(10, 10), 0, false, false, fals e, false, 10, 10, 10, 10); 274 PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUp date, IntPoint(10, 10), IntPoint(10, 10), IntSize(10, 10), 0, false, false, fals e, false, 10, 10, 10, 10);
275 RefPtrWillBeRawPtr<GestureEvent> gestureEvent = GestureEvent::create(dom Window, platformGestureEvent); 275 RefPtrWillBeRawPtr<GestureEvent> gestureEvent = GestureEvent::create(dom Window, platformGestureEvent);
276 WebGestureEventBuilder webGestureBuilder(view, documentRenderView, *gest ureEvent); 276 WebGestureEventBuilder webGestureBuilder(view, documentRenderView, *gest ureEvent);
277 277
278 EXPECT_EQ(10, webGestureBuilder.x); 278 EXPECT_EQ(10, webGestureBuilder.x);
279 EXPECT_EQ(10, webGestureBuilder.y); 279 EXPECT_EQ(10, webGestureBuilder.y);
280 EXPECT_EQ(10, webGestureBuilder.globalX); 280 EXPECT_EQ(10, webGestureBuilder.globalX);
281 EXPECT_EQ(10, webGestureBuilder.globalY); 281 EXPECT_EQ(10, webGestureBuilder.globalY);
282 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaX); 282 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaX);
283 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaY); 283 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaY);
284 } 284 }
285 285
286 { 286 {
287 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); 287 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);
288 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); 288 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create();
289 touchList->append(touch); 289 touchList->append(touch);
290 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), WebCore::EventTypeNames::touchmove, do mWindow, false, false, false, false, false); 290 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList .get(), touchList.get(), touchList.get(), blink::EventTypeNames::touchmove, domW indow, false, false, false, false, false);
291 291
292 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt); 292 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve nt);
293 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 293 ASSERT_EQ(1u, webTouchBuilder.touchesLength);
294 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); 294 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
295 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); 295 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y);
296 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); 296 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x);
297 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); 297 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y);
298 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); 298 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX);
299 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); 299 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY);
300 EXPECT_FALSE(webTouchBuilder.cancelable); 300 EXPECT_FALSE(webTouchBuilder.cancelable);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 webGestureEvent.data.tap.width = 10; 477 webGestureEvent.data.tap.width = 10;
478 webGestureEvent.data.tap.height = 10; 478 webGestureEvent.data.tap.height = 10;
479 479
480 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent ); 480 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent );
481 EXPECT_EQ(10.f, platformGestureBuilder.position().x()); 481 EXPECT_EQ(10.f, platformGestureBuilder.position().x());
482 EXPECT_EQ(10.f, platformGestureBuilder.position().y()); 482 EXPECT_EQ(10.f, platformGestureBuilder.position().y());
483 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().x()); 483 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().x());
484 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().y()); 484 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().y());
485 EXPECT_EQ(1, platformGestureBuilder.tapCount()); 485 EXPECT_EQ(1, platformGestureBuilder.tapCount());
486 486
487 RefPtrWillBeRawPtr<WebCore::GestureEvent> coreGestureEvent = WebCore::Ge stureEvent::create(domWindow, platformGestureBuilder); 487 RefPtrWillBeRawPtr<blink::GestureEvent> coreGestureEvent = blink::Gestur eEvent::create(domWindow, platformGestureBuilder);
488 WebGestureEventBuilder recreatedWebGestureEvent(view, documentRenderView , *coreGestureEvent); 488 WebGestureEventBuilder recreatedWebGestureEvent(view, documentRenderView , *coreGestureEvent);
489 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type); 489 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type);
490 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x); 490 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x);
491 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y); 491 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y);
492 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX); 492 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX);
493 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY); 493 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY);
494 EXPECT_EQ(webGestureEvent.data.tap.tapCount, recreatedWebGestureEvent.da ta.tap.tapCount); 494 EXPECT_EQ(webGestureEvent.data.tap.tapCount, recreatedWebGestureEvent.da ta.tap.tapCount);
495 } 495 }
496 } 496 }
497 497
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 588 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
589 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); 589 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x());
590 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); 590 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y());
591 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); 591 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x());
592 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); 592 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y());
593 } 593 }
594 } 594 }
595 595
596 } // anonymous namespace 596 } // anonymous namespace
OLDNEW
« no previous file with comments | « Source/web/tests/WebImageTest.cpp ('k') | Source/web/tests/WebPageNewSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698