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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 19 matching lines...) Expand all
30 30
31 #include "core/editing/EditingBehavior.h" 31 #include "core/editing/EditingBehavior.h"
32 #include "core/editing/Editor.h" 32 #include "core/editing/Editor.h"
33 #include "core/events/EventTarget.h" 33 #include "core/events/EventTarget.h"
34 #include "core/events/KeyboardEvent.h" 34 #include "core/events/KeyboardEvent.h"
35 #include "core/frame/Settings.h" 35 #include "core/frame/Settings.h"
36 #include "platform/KeyboardCodes.h" 36 #include "platform/KeyboardCodes.h"
37 #include "public/web/WebInputEvent.h" 37 #include "public/web/WebInputEvent.h"
38 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
39 #include "web/WebInputEventConversion.h" 39 #include "web/WebInputEventConversion.h"
40 #include <memory>
41 40
42 namespace blink { 41 namespace blink {
43 42
44 class KeyboardTest : public testing::Test { 43 class KeyboardTest : public testing::Test {
45 public: 44 public:
46 45
47 // Pass a WebKeyboardEvent into the EditorClient and get back the string 46 // Pass a WebKeyboardEvent into the EditorClient and get back the string
48 // name of which editing event that key causes. 47 // name of which editing event that key causes.
49 // E.g., sending in the enter key gives back "InsertNewline". 48 // E.g., sending in the enter key gives back "InsertNewline".
50 const char* interpretKeyEvent( 49 const char* interpretKeyEvent(
51 const WebKeyboardEvent& webKeyboardEvent, 50 const WebKeyboardEvent& webKeyboardEvent,
52 PlatformEvent::EventType keyType) 51 PlatformEvent::EventType keyType)
53 { 52 {
54 PlatformKeyboardEventBuilder evt(webKeyboardEvent); 53 PlatformKeyboardEventBuilder evt(webKeyboardEvent);
55 evt.setKeyType(keyType); 54 evt.setKeyType(keyType);
56 KeyboardEvent* keyboardEvent = KeyboardEvent::create(evt, 0); 55 KeyboardEvent* keyboardEvent = KeyboardEvent::create(evt, 0);
57 std::unique_ptr<Settings> settings = Settings::create(); 56 OwnPtr<Settings> settings = Settings::create();
58 EditingBehavior behavior(settings->editingBehaviorType()); 57 EditingBehavior behavior(settings->editingBehaviorType());
59 return behavior.interpretKeyEvent(*keyboardEvent); 58 return behavior.interpretKeyEvent(*keyboardEvent);
60 } 59 }
61 60
62 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers. 61 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers.
63 void setupKeyDownEvent(WebKeyboardEvent* keyboardEvent, 62 void setupKeyDownEvent(WebKeyboardEvent* keyboardEvent,
64 char keyCode, 63 char keyCode,
65 int modifiers) 64 int modifiers)
66 { 65 {
67 keyboardEvent->windowsKeyCode = keyCode; 66 keyboardEvent->windowsKeyCode = keyCode;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 { 184 {
186 EXPECT_STREQ("InsertNewline", interpretNewLine(noModifiers)); 185 EXPECT_STREQ("InsertNewline", interpretNewLine(noModifiers));
187 } 186 }
188 187
189 TEST_F(KeyboardTest, TestInsertLineBreak) 188 TEST_F(KeyboardTest, TestInsertLineBreak)
190 { 189 {
191 EXPECT_STREQ("InsertLineBreak", interpretNewLine(WebInputEvent::ShiftKey)); 190 EXPECT_STREQ("InsertLineBreak", interpretNewLine(WebInputEvent::ShiftKey));
192 } 191 }
193 192
194 } // namespace blink 193 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp ('k') | third_party/WebKit/Source/web/tests/PrerenderingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698