| Index: Source/web/tests/KeyboardTest.cpp
|
| diff --git a/Source/web/tests/KeyboardTest.cpp b/Source/web/tests/KeyboardTest.cpp
|
| index f33d651d499fb456e6072b8420f8e2b3548251b7..64c605ef38e622777f0b98182b79663cd2e73d0c 100644
|
| --- a/Source/web/tests/KeyboardTest.cpp
|
| +++ b/Source/web/tests/KeyboardTest.cpp
|
| @@ -36,10 +36,17 @@
|
| #include "core/editing/Editor.h"
|
| #include "core/events/EventTarget.h"
|
| #include "core/events/KeyboardEvent.h"
|
| +#include "core/frame/FrameView.h"
|
| #include "core/frame/Settings.h"
|
| +#include "core/page/Page.h"
|
| +#include "core/testing/URLTestHelpers.h"
|
| #include "platform/KeyboardCodes.h"
|
| +#include "public/platform/Platform.h"
|
| +#include "public/platform/WebUnitTestSupport.h"
|
| #include "public/web/WebInputEvent.h"
|
| #include "web/WebInputEventConversion.h"
|
| +#include "web/WebViewImpl.h"
|
| +#include "web/tests/FrameTestHelpers.h"
|
|
|
| using namespace blink;
|
|
|
| @@ -55,7 +62,7 @@ public:
|
| const WebKeyboardEvent& webKeyboardEvent,
|
| PlatformEvent::Type keyType)
|
| {
|
| - PlatformKeyboardEventBuilder evt(webKeyboardEvent);
|
| + PlatformKeyboardEventBuilder evt(toLocalFrame(m_webView->page()->mainFrame())->view(), webKeyboardEvent);
|
| evt.setKeyType(keyType);
|
| RefPtrWillBeRawPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create(evt, 0);
|
| OwnPtr<Settings> settings = Settings::create();
|
| @@ -114,17 +121,38 @@ public:
|
| return interpretKeyEvent(keyboardEvent, PlatformEvent::Char);
|
| }
|
|
|
| + void initializeAndLoad()
|
| + {
|
| + const std::string baseURL("http://www.test5.com/");
|
| + const std::string fileName("fixed_layout.html");
|
| + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8(fileName.c_str()));
|
| + m_webView = m_helper.initializeAndLoad(baseURL + fileName, true);
|
| + m_webView->resize(WebSize(640, 480));
|
| + m_webView->layout();
|
| + }
|
| +
|
| + virtual ~KeyboardTest()
|
| + {
|
| + Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
|
| + }
|
| +
|
| // A name for "no modifiers set".
|
| static const int noModifiers = 0;
|
| +
|
| +private:
|
| + FrameTestHelpers::WebViewHelper m_helper;
|
| + WebViewImpl* m_webView;
|
| };
|
|
|
| TEST_F(KeyboardTest, TestCtrlReturn)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertNewline", interpretCtrlKeyPress(0xD));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestOSModifierZ)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("Undo", interpretOSModifierKeyPress('Z'));
|
| #endif
|
| @@ -132,6 +160,7 @@ TEST_F(KeyboardTest, TestOSModifierZ)
|
|
|
| TEST_F(KeyboardTest, TestOSModifierY)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y'));
|
| #endif
|
| @@ -139,6 +168,7 @@ TEST_F(KeyboardTest, TestOSModifierY)
|
|
|
| TEST_F(KeyboardTest, TestOSModifierA)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A'));
|
| #endif
|
| @@ -146,6 +176,7 @@ TEST_F(KeyboardTest, TestOSModifierA)
|
|
|
| TEST_F(KeyboardTest, TestOSModifierX)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("Cut", interpretOSModifierKeyPress('X'));
|
| #endif
|
| @@ -153,6 +184,7 @@ TEST_F(KeyboardTest, TestOSModifierX)
|
|
|
| TEST_F(KeyboardTest, TestOSModifierC)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C'));
|
| #endif
|
| @@ -160,6 +192,7 @@ TEST_F(KeyboardTest, TestOSModifierC)
|
|
|
| TEST_F(KeyboardTest, TestOSModifierV)
|
| {
|
| + initializeAndLoad();
|
| #if !OS(MACOSX)
|
| EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V'));
|
| #endif
|
| @@ -167,6 +200,7 @@ TEST_F(KeyboardTest, TestOSModifierV)
|
|
|
| TEST_F(KeyboardTest, TestEscape)
|
| {
|
| + initializeAndLoad();
|
| WebKeyboardEvent keyboardEvent;
|
| setupKeyDownEvent(&keyboardEvent, VKEY_ESCAPE, noModifiers);
|
|
|
| @@ -177,36 +211,43 @@ TEST_F(KeyboardTest, TestEscape)
|
|
|
| TEST_F(KeyboardTest, TestInsertTab)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertTab", interpretTab(noModifiers));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertBackTab)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertBacktab", interpretTab(WebInputEvent::ShiftKey));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertNewline)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertNewline", interpretNewLine(noModifiers));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertNewline2)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertNewline", interpretNewLine(WebInputEvent::ControlKey));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertLineBreak)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertLineBreak", interpretNewLine(WebInputEvent::ShiftKey));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertNewline3)
|
| {
|
| + initializeAndLoad();
|
| EXPECT_STREQ("InsertNewline", interpretNewLine(WebInputEvent::AltKey));
|
| }
|
|
|
| TEST_F(KeyboardTest, TestInsertNewline4)
|
| {
|
| + initializeAndLoad();
|
| int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey;
|
| const char* result = interpretNewLine(modifiers);
|
| EXPECT_STREQ("InsertNewline", result);
|
|
|