| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/events/EventTarget.h" | 34 #include "core/events/EventTarget.h" |
| 35 #include "core/events/KeyboardEvent.h" | 35 #include "core/events/KeyboardEvent.h" |
| 36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 37 #include "platform/KeyboardCodes.h" | 37 #include "platform/KeyboardCodes.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include "public/platform/WebInputEvent.h" | 39 #include "public/platform/WebInputEvent.h" |
| 40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class KeyboardTest : public testing::Test { | 44 class KeyboardTest : public ::testing::Test { |
| 45 public: | 45 public: |
| 46 // Pass a WebKeyboardEvent into the EditorClient and get back the string | 46 // Pass a WebKeyboardEvent into the EditorClient and get back the string |
| 47 // name of which editing event that key causes. | 47 // name of which editing event that key causes. |
| 48 // E.g., sending in the enter key gives back "InsertNewline". | 48 // E.g., sending in the enter key gives back "InsertNewline". |
| 49 const char* InterpretKeyEvent(const WebKeyboardEvent& web_keyboard_event) { | 49 const char* InterpretKeyEvent(const WebKeyboardEvent& web_keyboard_event) { |
| 50 KeyboardEvent* keyboard_event = | 50 KeyboardEvent* keyboard_event = |
| 51 KeyboardEvent::Create(web_keyboard_event, 0); | 51 KeyboardEvent::Create(web_keyboard_event, 0); |
| 52 std::unique_ptr<Settings> settings = Settings::Create(); | 52 std::unique_ptr<Settings> settings = Settings::Create(); |
| 53 EditingBehavior behavior(settings->GetEditingBehaviorType()); | 53 EditingBehavior behavior(settings->GetEditingBehaviorType()); |
| 54 return behavior.InterpretKeyEvent(*keyboard_event); | 54 return behavior.InterpretKeyEvent(*keyboard_event); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const char* command; | 174 const char* command; |
| 175 } kDomKeyTestCases[] = { | 175 } kDomKeyTestCases[] = { |
| 176 {"Copy", "Copy"}, {"Cut", "Cut"}, {"Paste", "Paste"}, | 176 {"Copy", "Copy"}, {"Cut", "Cut"}, {"Paste", "Paste"}, |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 for (const auto& test_case : kDomKeyTestCases) | 179 for (const auto& test_case : kDomKeyTestCases) |
| 180 EXPECT_STREQ(test_case.command, InterpretDomKey(test_case.key)); | 180 EXPECT_STREQ(test_case.command, InterpretDomKey(test_case.key)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |