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

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

Issue 20986003: Define DOM_KEY_LOCATION_* constants on KeyboardEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 7 years, 4 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 int getModifiersForKeyLocationCode(WebCore::KeyboardEvent::KeyLocationCode locat ion) 60 int getModifiersForKeyLocationCode(WebCore::KeyboardEvent::KeyLocationCode locat ion)
61 { 61 {
62 RefPtr<WebCore::KeyboardEvent> event = createKeyboardEventWithLocation(locat ion); 62 RefPtr<WebCore::KeyboardEvent> event = createKeyboardEventWithLocation(locat ion);
63 WebKit::WebKeyboardEventBuilder convertedEvent(*event); 63 WebKit::WebKeyboardEventBuilder convertedEvent(*event);
64 return convertedEvent.modifiers; 64 return convertedEvent.modifiers;
65 } 65 }
66 66
67 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) 67 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder)
68 { 68 {
69 // Test key location conversion. 69 // Test key location conversion.
70 int modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOMKe yLocationStandard); 70 int modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_K EY_LOCATION_STANDARD);
71 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight); 71 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft || modifiers & WebInputEvent::IsRight);
72 72
73 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOMKeyLoc ationLeft); 73 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_LEFT);
74 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); 74 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft);
75 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight); 75 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsRight);
76 76
77 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOMKeyLoc ationRight); 77 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_RIGHT);
78 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); 78 EXPECT_TRUE(modifiers & WebInputEvent::IsRight);
79 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft); 79 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven t::IsLeft);
80 80
81 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOMKeyLoc ationNumpad); 81 modifiers = getModifiersForKeyLocationCode(WebCore::KeyboardEvent::DOM_KEY_L OCATION_NUMPAD);
82 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); 82 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad);
83 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight); 83 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent: :IsRight);
84 } 84 }
85 85
86 TEST(WebInputEventConversionTest, WebTouchEventBuilder) 86 TEST(WebInputEventConversionTest, WebTouchEventBuilder)
87 { 87 {
88 RefPtr<WebCore::TouchEvent> event = WebCore::TouchEvent::create(); 88 RefPtr<WebCore::TouchEvent> event = WebCore::TouchEvent::create();
89 WebMouseEventBuilder mouse(0, 0, *event); 89 WebMouseEventBuilder mouse(0, 0, *event);
90 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); 90 EXPECT_EQ(WebInputEvent::Undefined, mouse.type);
91 } 91 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 EXPECT_EQ(10, webTouchBuilder.touches[0].position.x); 275 EXPECT_EQ(10, webTouchBuilder.touches[0].position.x);
276 EXPECT_EQ(10, webTouchBuilder.touches[0].position.y); 276 EXPECT_EQ(10, webTouchBuilder.touches[0].position.y);
277 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX); 277 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusX);
278 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY); 278 EXPECT_EQ(10, webTouchBuilder.touches[0].radiusY);
279 } 279 }
280 280
281 webViewImpl->close(); 281 webViewImpl->close();
282 } 282 }
283 283
284 } // anonymous namespace 284 } // anonymous namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698