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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "web/WebViewImpl.h" | 50 #include "web/WebViewImpl.h" |
51 #include "web/tests/FrameTestHelpers.h" | 51 #include "web/tests/FrameTestHelpers.h" |
52 #include <gtest/gtest.h> | 52 #include <gtest/gtest.h> |
53 | 53 |
54 using namespace blink; | 54 using namespace blink; |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 PassRefPtrWillBeRawPtr<KeyboardEvent> createKeyboardEventWithLocation(KeyboardEv ent::KeyLocationCode location) | 58 PassRefPtrWillBeRawPtr<KeyboardEvent> createKeyboardEventWithLocation(KeyboardEv ent::KeyLocationCode location) |
59 { | 59 { |
60 return KeyboardEvent::create("keydown", true, true, 0, "", location, false, false, false, false); | 60 return KeyboardEvent::create("keydown", true, true, 0, "", "", location, fal se, false, false, false); |
61 } | 61 } |
62 | 62 |
63 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) | 63 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) |
64 { | 64 { |
65 const std::string baseURL("http://www.test0.com/"); | |
66 const std::string fileName("fixed_layout.html"); | |
67 | |
68 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); | |
69 FrameTestHelpers::WebViewHelper webViewHelper; | |
70 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
Wez
2015/01/17 02:35:10
Do you need to tear this page down somewhere?
It
bokan
2015/01/20 17:05:58
Ditto here
Habib Virji
2015/01/22 16:01:30
Acknowledged.
| |
71 int pageWidth = 640; | |
72 int pageHeight = 480; | |
73 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
74 webViewImpl->layout(); | |
75 | |
65 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo cation); | 76 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo cation); |
66 WebKeyboardEventBuilder convertedEvent(*event); | 77 WebKeyboardEventBuilder convertedEvent(toLocalFrame(webViewImpl->page()->mai nFrame())->view(), *event); |
67 return convertedEvent.modifiers; | 78 return convertedEvent.modifiers; |
68 } | 79 } |
69 | 80 |
70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) | 81 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) |
71 { | 82 { |
72 // Test key location conversion. | 83 // Test key location conversion. |
73 int modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATI ON_STANDARD); | 84 int modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATI ON_STANDARD); |
74 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); | 85 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); |
75 | 86 |
76 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_L EFT); | 87 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_L EFT); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 801 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
791 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 802 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
792 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 803 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
793 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 804 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
794 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | 805 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
795 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 806 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
796 EXPECT_TRUE(platformWheelBuilder.canScroll()); | 807 EXPECT_TRUE(platformWheelBuilder.canScroll()); |
797 } | 808 } |
798 } | 809 } |
799 } // anonymous namespace | 810 } // anonymous namespace |
OLD | NEW |