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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/events/KeyboardEvent.h" | 42 #include "core/events/KeyboardEvent.h" |
43 #include "core/events/MouseEvent.h" | 43 #include "core/events/MouseEvent.h" |
44 #include "core/dom/Touch.h" | 44 #include "core/dom/Touch.h" |
45 #include "core/events/TouchEvent.h" | 45 #include "core/events/TouchEvent.h" |
46 #include "core/dom/TouchList.h" | 46 #include "core/dom/TouchList.h" |
47 #include "core/frame/Frame.h" | 47 #include "core/frame/Frame.h" |
48 #include "core/frame/FrameView.h" | 48 #include "core/frame/FrameView.h" |
49 | 49 |
50 using namespace blink; | 50 using namespace blink; |
51 using namespace WebCore; | 51 using namespace WebCore; |
| 52 using blink::FrameTestHelpers::setViewportSettings; |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
55 PassRefPtr<WebCore::KeyboardEvent> createKeyboardEventWithLocation(WebCore::Keyb
oardEvent::KeyLocationCode location) | 56 PassRefPtr<WebCore::KeyboardEvent> createKeyboardEventWithLocation(WebCore::Keyb
oardEvent::KeyLocationCode location) |
56 { | 57 { |
57 return WebCore::KeyboardEvent::create("keydown", true, true, 0, "", location
, false, false, false, false, false); | 58 return WebCore::KeyboardEvent::create("keydown", true, true, 0, "", location
, false, false, false, false, false); |
58 } | 59 } |
59 | 60 |
60 int getModifiersForKeyLocationCode(WebCore::KeyboardEvent::KeyLocationCode locat
ion) | 61 int getModifiersForKeyLocationCode(WebCore::KeyboardEvent::KeyLocationCode locat
ion) |
61 { | 62 { |
(...skipping 24 matching lines...) Expand all Loading... |
86 TEST(WebInputEventConversionTest, WebTouchEventBuilder) | 87 TEST(WebInputEventConversionTest, WebTouchEventBuilder) |
87 { | 88 { |
88 RefPtr<WebCore::TouchEvent> event = WebCore::TouchEvent::create(); | 89 RefPtr<WebCore::TouchEvent> event = WebCore::TouchEvent::create(); |
89 WebMouseEventBuilder mouse(0, 0, *event); | 90 WebMouseEventBuilder mouse(0, 0, *event); |
90 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); | 91 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); |
91 } | 92 } |
92 | 93 |
93 TEST(WebInputEventConversionTest, InputEventsScaling) | 94 TEST(WebInputEventConversionTest, InputEventsScaling) |
94 { | 95 { |
95 const std::string baseURL("http://www.test.com/"); | 96 const std::string baseURL("http://www.test.com/"); |
96 const std::string fileName("fixed_layout.html"); | 97 const std::string fileName("no_viewport_tag.html"); |
97 | 98 |
98 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 99 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("no_viewport_tag.html")); |
99 FrameTestHelpers::WebViewHelper webViewHelper; | 100 FrameTestHelpers::WebViewHelper webViewHelper; |
100 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true)); | 101 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true, 0, 0, setViewportSettings)); |
101 webViewImpl->settings()->setViewportEnabled(true); | |
102 int pageWidth = 640; | 102 int pageWidth = 640; |
103 int pageHeight = 480; | 103 int pageHeight = 480; |
104 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 104 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
105 webViewImpl->layout(); | 105 webViewImpl->layout(); |
106 | 106 |
107 webViewImpl->setPageScaleFactor(2, WebPoint()); | 107 webViewImpl->setPageScaleFactor(2, WebPoint()); |
108 | 108 |
109 FrameView* view = webViewImpl->page()->mainFrame()->view(); | 109 FrameView* view = webViewImpl->page()->mainFrame()->view(); |
110 RefPtr<Document> document = webViewImpl->page()->mainFrame()->document(); | 110 RefPtr<Document> document = webViewImpl->page()->mainFrame()->document(); |
111 DOMWindow* domWindow = webViewImpl->page()->mainFrame()->document()->domWind
ow(); | 111 DOMWindow* domWindow = webViewImpl->page()->mainFrame()->document()->domWind
ow(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 EXPECT_EQ(10, webTouchBuilder.touches[0].position.x); | 286 EXPECT_EQ(10, webTouchBuilder.touches[0].position.x); |
287 EXPECT_EQ(10, webTouchBuilder.touches[0].position.y); | 287 EXPECT_EQ(10, webTouchBuilder.touches[0].position.y); |
288 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX); | 288 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX); |
289 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY); | 289 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 TEST(WebInputEventConversionTest, InputEventsTransform) | 293 TEST(WebInputEventConversionTest, InputEventsTransform) |
294 { | 294 { |
295 const std::string baseURL("http://www.test2.com/"); | 295 const std::string baseURL("http://www.test2.com/"); |
296 const std::string fileName("fixed_layout.html"); | 296 const std::string fileName("no_viewport_tag.html"); |
297 | 297 |
298 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 298 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("no_viewport_tag.html")); |
299 FrameTestHelpers::WebViewHelper webViewHelper; | 299 FrameTestHelpers::WebViewHelper webViewHelper; |
300 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true)); | 300 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true, 0, 0, setViewportSettings)); |
301 webViewImpl->settings()->setViewportEnabled(true); | |
302 int pageWidth = 640; | 301 int pageWidth = 640; |
303 int pageHeight = 480; | 302 int pageHeight = 480; |
304 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 303 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
305 webViewImpl->layout(); | 304 webViewImpl->layout(); |
306 | 305 |
307 webViewImpl->setPageScaleFactor(2, WebPoint()); | 306 webViewImpl->setPageScaleFactor(2, WebPoint()); |
308 webViewImpl->setRootLayerTransform(WebSize(10, 20), 1.5); | 307 webViewImpl->setRootLayerTransform(WebSize(10, 20), 1.5); |
309 | 308 |
310 FrameView* view = webViewImpl->page()->mainFrame()->view(); | 309 FrameView* view = webViewImpl->page()->mainFrame()->view(); |
311 RefPtr<Document> document = webViewImpl->page()->mainFrame()->document(); | 310 RefPtr<Document> document = webViewImpl->page()->mainFrame()->document(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 EXPECT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); | 431 EXPECT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); |
433 EXPECT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); | 432 EXPECT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); |
434 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); | 433 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); |
435 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); | 434 EXPECT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); |
436 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusX()); | 435 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusX()); |
437 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusY()); | 436 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].radiusY()); |
438 } | 437 } |
439 } | 438 } |
440 | 439 |
441 } // anonymous namespace | 440 } // anonymous namespace |
OLD | NEW |