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

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

Issue 663523002: Adding support for DOM3 KeyboardEvents Code in KeyboardEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added new embedder API and code review comments update Created 5 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #include <gtest/gtest.h> 33 #include <gtest/gtest.h>
34 34
35 #include "core/editing/EditingBehavior.h" 35 #include "core/editing/EditingBehavior.h"
36 #include "core/editing/Editor.h" 36 #include "core/editing/Editor.h"
37 #include "core/events/EventTarget.h" 37 #include "core/events/EventTarget.h"
38 #include "core/events/KeyboardEvent.h" 38 #include "core/events/KeyboardEvent.h"
39 #include "core/frame/FrameView.h"
39 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
41 #include "core/page/Page.h"
42 #include "core/testing/URLTestHelpers.h"
40 #include "platform/KeyboardCodes.h" 43 #include "platform/KeyboardCodes.h"
41 #include "public/web/WebInputEvent.h" 44 #include "public/web/WebInputEvent.h"
42 #include "web/WebInputEventConversion.h" 45 #include "web/WebInputEventConversion.h"
46 #include "web/WebViewImpl.h"
47 #include "web/tests/FrameTestHelpers.h"
43 48
44 using namespace blink; 49 using namespace blink;
45 50
46 namespace { 51 namespace {
47 52
48 class KeyboardTest : public testing::Test { 53 class KeyboardTest : public testing::Test {
49 public: 54 public:
50 55
51 // Pass a WebKeyboardEvent into the EditorClient and get back the string 56 // Pass a WebKeyboardEvent into the EditorClient and get back the string
52 // name of which editing event that key causes. 57 // name of which editing event that key causes.
53 // E.g., sending in the enter key gives back "InsertNewline". 58 // E.g., sending in the enter key gives back "InsertNewline".
54 const char* interpretKeyEvent( 59 const char* interpretKeyEvent(
55 const WebKeyboardEvent& webKeyboardEvent, 60 const WebKeyboardEvent& webKeyboardEvent,
56 PlatformEvent::Type keyType) 61 PlatformEvent::Type keyType)
57 { 62 {
58 PlatformKeyboardEventBuilder evt(webKeyboardEvent); 63 const std::string baseURL("http://www.test5.com/");
64 const std::string fileName("fixed_layout.html");
65
66 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL .c_str()), WebString::fromUTF8("fixed_layout.html"));
67 FrameTestHelpers::WebViewHelper webViewHelper;
68 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fil eName, true);
Wez 2015/01/17 02:35:10 Doesn't this need cleaning up somewhere?
bokan 2015/01/20 17:05:58 webViewHelper will clean up on destruction. That s
Habib Virji 2015/01/22 16:01:30 Done.
69 int pageWidth = 640;
70 int pageHeight = 480;
71 webViewImpl->resize(WebSize(pageWidth, pageHeight));
72 webViewImpl->layout();
73
74 PlatformKeyboardEventBuilder evt(toLocalFrame(webViewImpl->page()->mainF rame())->view(), webKeyboardEvent);
59 evt.setKeyType(keyType); 75 evt.setKeyType(keyType);
60 RefPtrWillBeRawPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create( evt, 0); 76 RefPtrWillBeRawPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create( evt, 0);
61 OwnPtr<Settings> settings = Settings::create(); 77 OwnPtr<Settings> settings = Settings::create();
62 EditingBehavior behavior(settings->editingBehaviorType()); 78 EditingBehavior behavior(settings->editingBehaviorType());
63 return behavior.interpretKeyEvent(*keyboardEvent); 79 return behavior.interpretKeyEvent(*keyboardEvent);
64 } 80 }
65 81
66 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers. 82 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers.
67 void setupKeyDownEvent(WebKeyboardEvent* keyboardEvent, 83 void setupKeyDownEvent(WebKeyboardEvent* keyboardEvent,
68 char keyCode, 84 char keyCode,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 222 }
207 223
208 TEST_F(KeyboardTest, TestInsertNewline4) 224 TEST_F(KeyboardTest, TestInsertNewline4)
209 { 225 {
210 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; 226 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey;
211 const char* result = interpretNewLine(modifiers); 227 const char* result = interpretNewLine(modifiers);
212 EXPECT_STREQ("InsertNewline", result); 228 EXPECT_STREQ("InsertNewline", result);
213 } 229 }
214 230
215 } // empty namespace 231 } // empty namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698