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

Unified 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: "Updated test for keypress and keyup. Added DOM3 code attribute as runtime enabled feature. DOMcode… 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/tests/KeyboardTest.cpp
diff --git a/Source/web/tests/KeyboardTest.cpp b/Source/web/tests/KeyboardTest.cpp
index f33d651d499fb456e6072b8420f8e2b3548251b7..91b2e8f190c12f5f0025f8dcc4bb74009e1556d1 100644
--- a/Source/web/tests/KeyboardTest.cpp
+++ b/Source/web/tests/KeyboardTest.cpp
@@ -36,10 +36,15 @@
#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/web/WebInputEvent.h"
#include "web/WebInputEventConversion.h"
+#include "web/WebViewImpl.h"
+#include "web/tests/FrameTestHelpers.h"
using namespace blink;
@@ -55,7 +60,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 +119,33 @@ public:
return interpretKeyEvent(keyboardEvent, PlatformEvent::Char);
}
+ void initializeAndLoad()
+ {
+ const std::string baseURL("http://www.test5.com/");
bokan 2015/01/23 15:35:25 You'll likely get the same problem here with tryin
Habib Virji 2015/01/23 15:58:16 Done.
+ 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();
+ }
+
// 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 +153,7 @@ TEST_F(KeyboardTest, TestOSModifierZ)
TEST_F(KeyboardTest, TestOSModifierY)
{
+ initializeAndLoad();
#if !OS(MACOSX)
EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y'));
#endif
@@ -139,6 +161,7 @@ TEST_F(KeyboardTest, TestOSModifierY)
TEST_F(KeyboardTest, TestOSModifierA)
{
+ initializeAndLoad();
#if !OS(MACOSX)
EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A'));
#endif
@@ -146,6 +169,7 @@ TEST_F(KeyboardTest, TestOSModifierA)
TEST_F(KeyboardTest, TestOSModifierX)
{
+ initializeAndLoad();
#if !OS(MACOSX)
EXPECT_STREQ("Cut", interpretOSModifierKeyPress('X'));
#endif
@@ -153,6 +177,7 @@ TEST_F(KeyboardTest, TestOSModifierX)
TEST_F(KeyboardTest, TestOSModifierC)
{
+ initializeAndLoad();
#if !OS(MACOSX)
EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C'));
#endif
@@ -160,6 +185,7 @@ TEST_F(KeyboardTest, TestOSModifierC)
TEST_F(KeyboardTest, TestOSModifierV)
{
+ initializeAndLoad();
#if !OS(MACOSX)
EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V'));
#endif
@@ -167,6 +193,7 @@ TEST_F(KeyboardTest, TestOSModifierV)
TEST_F(KeyboardTest, TestEscape)
{
+ initializeAndLoad();
WebKeyboardEvent keyboardEvent;
setupKeyDownEvent(&keyboardEvent, VKEY_ESCAPE, noModifiers);
@@ -177,36 +204,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);

Powered by Google App Engine
This is Rietveld 408576698