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(WebViewImpl* webViewImpl, KeyboardEvent::KeyL ocationCode location) |
64 { | 64 { |
65 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo cation); | 65 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo cation); |
66 WebKeyboardEventBuilder convertedEvent(*event); | 66 WebKeyboardEventBuilder convertedEvent(toLocalFrame(webViewImpl->page()->mai nFrame())->view(), *event); |
67 return convertedEvent.modifiers; | 67 return convertedEvent.modifiers; |
68 } | 68 } |
69 | 69 |
70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) | 70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) |
71 { | 71 { |
72 const std::string baseURL("http://www.test0.com/"); | |
bokan
2015/01/23 15:35:25
I seem to recall this test file failing recently b
Habib Virji
2015/01/23 15:58:16
Have added all test to have URL in sequential orde
| |
73 const std::string fileName("fixed_layout.html"); | |
74 | |
75 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8(fileName.c_str())); | |
76 FrameTestHelpers::WebViewHelper webViewHelper; | |
77 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
78 webViewImpl->resize(WebSize(680, 480)); | |
79 webViewImpl->layout(); | |
80 | |
72 // Test key location conversion. | 81 // Test key location conversion. |
73 int modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATI ON_STANDARD); | 82 int modifiers = getModifiersForKeyLocationCode(webViewImpl, KeyboardEvent::D OM_KEY_LOCATION_STANDARD); |
74 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); | 83 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); |
75 | 84 |
76 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_L EFT); | 85 modifiers = getModifiersForKeyLocationCode(webViewImpl, KeyboardEvent::DOM_K EY_LOCATION_LEFT); |
77 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); | 86 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); |
78 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight); | 87 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight); |
79 | 88 |
80 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_R IGHT); | 89 modifiers = getModifiersForKeyLocationCode(webViewImpl, KeyboardEvent::DOM_K EY_LOCATION_RIGHT); |
81 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); | 90 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); |
82 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft); | 91 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft); |
83 | 92 |
84 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_N UMPAD); | 93 modifiers = getModifiersForKeyLocationCode(webViewImpl, KeyboardEvent::DOM_K EY_LOCATION_NUMPAD); |
85 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); | 94 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); |
86 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight); | 95 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight); |
87 } | 96 } |
88 | 97 |
89 TEST(WebInputEventConversionTest, WebMouseEventBuilder) | 98 TEST(WebInputEventConversionTest, WebMouseEventBuilder) |
90 { | 99 { |
91 RefPtrWillBeRawPtr<TouchEvent> event = TouchEvent::create(); | 100 RefPtrWillBeRawPtr<TouchEvent> event = TouchEvent::create(); |
92 WebMouseEventBuilder mouse(0, 0, *event); | 101 WebMouseEventBuilder mouse(0, 0, *event); |
93 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); | 102 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); |
94 } | 103 } |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 799 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
791 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 800 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
792 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 801 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
793 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 802 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
794 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | 803 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
795 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 804 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
796 EXPECT_TRUE(platformWheelBuilder.canScroll()); | 805 EXPECT_TRUE(platformWheelBuilder.canScroll()); |
797 } | 806 } |
798 } | 807 } |
799 } // anonymous namespace | 808 } // anonymous namespace |
OLD | NEW |