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

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

Issue 2045603002: Handle the "key" field as opposed to keyIdentifier field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix chromeos 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "public/web/WebInputEvent.h" 85 #include "public/web/WebInputEvent.h"
86 #include "public/web/WebScriptSource.h" 86 #include "public/web/WebScriptSource.h"
87 #include "public/web/WebSettings.h" 87 #include "public/web/WebSettings.h"
88 #include "public/web/WebTreeScopeType.h" 88 #include "public/web/WebTreeScopeType.h"
89 #include "public/web/WebViewClient.h" 89 #include "public/web/WebViewClient.h"
90 #include "public/web/WebWidget.h" 90 #include "public/web/WebWidget.h"
91 #include "public/web/WebWidgetClient.h" 91 #include "public/web/WebWidgetClient.h"
92 #include "testing/gtest/include/gtest/gtest.h" 92 #include "testing/gtest/include/gtest/gtest.h"
93 #include "third_party/skia/include/core/SkBitmap.h" 93 #include "third_party/skia/include/core/SkBitmap.h"
94 #include "third_party/skia/include/core/SkCanvas.h" 94 #include "third_party/skia/include/core/SkCanvas.h"
95 #include "ui/events/keycodes/dom/dom_key.h"
95 #include "web/WebLocalFrameImpl.h" 96 #include "web/WebLocalFrameImpl.h"
96 #include "web/WebSettingsImpl.h" 97 #include "web/WebSettingsImpl.h"
97 #include "web/WebViewImpl.h" 98 #include "web/WebViewImpl.h"
98 #include "web/tests/FrameTestHelpers.h" 99 #include "web/tests/FrameTestHelpers.h"
99 100
100 #if OS(MACOSX) 101 #if OS(MACOSX)
101 #include "public/web/mac/WebSubstringUtil.h" 102 #include "public/web/mac/WebSubstringUtil.h"
102 #endif 103 #endif
103 104
104 using blink::FrameTestHelpers::loadFrame; 105 using blink::FrameTestHelpers::loadFrame;
(...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 // Select composition and do sanity check. 1988 // Select composition and do sanity check.
1988 WebVector<WebCompositionUnderline> emptyUnderlines; 1989 WebVector<WebCompositionUnderline> emptyUnderlines;
1989 frame->setEditableSelectionOffsets(6, 6); 1990 frame->setEditableSelectionOffsets(6, 6);
1990 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); 1991 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5));
1991 frame->setEditableSelectionOffsets(11, 11); 1992 frame->setEditableSelectionOffsets(11, 11);
1992 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); 1993 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case");
1993 1994
1994 // Press Backspace and verify composition didn't get cancelled. This is to verify the fix 1995 // Press Backspace and verify composition didn't get cancelled. This is to verify the fix
1995 // for crbug.com/429916. 1996 // for crbug.com/429916.
1996 WebKeyboardEvent keyEvent; 1997 WebKeyboardEvent keyEvent;
1998 keyEvent.domKey = ui::DomKey::FromCharacter('\b');
1997 keyEvent.windowsKeyCode = VKEY_BACK; 1999 keyEvent.windowsKeyCode = VKEY_BACK;
1998 keyEvent.setKeyIdentifierFromWindowsKeyCode(); 2000 keyEvent.setKeyIdentifierFromWindowsKeyCode();
1999 keyEvent.type = WebInputEvent::RawKeyDown; 2001 keyEvent.type = WebInputEvent::RawKeyDown;
2000 webView->handleInputEvent(keyEvent); 2002 webView->handleInputEvent(keyEvent);
2001 2003
2002 frame->setEditableSelectionOffsets(6, 6); 2004 frame->setEditableSelectionOffsets(6, 6);
2003 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); 2005 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4));
2004 frame->setEditableSelectionOffsets(10, 10); 2006 frame->setEditableSelectionOffsets(10, 10);
2005 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba ckspace"); 2007 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba ckspace");
2006 2008
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 2171
2170 WebElement element = webView->mainFrame()->document().getElementById("messag e"); 2172 WebElement element = webView->mainFrame()->document().getElementById("messag e");
2171 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.textContent().utf8().data()); 2173 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.textContent().utf8().data());
2172 } 2174 }
2173 2175
2174 static void openDateTimeChooser(WebView* webView, HTMLInputElement* inputElement ) 2176 static void openDateTimeChooser(WebView* webView, HTMLInputElement* inputElement )
2175 { 2177 {
2176 inputElement->focus(); 2178 inputElement->focus();
2177 2179
2178 WebKeyboardEvent keyEvent; 2180 WebKeyboardEvent keyEvent;
2181 keyEvent.domKey = ui::DomKey::FromCharacter(' ');
2179 keyEvent.windowsKeyCode = VKEY_SPACE; 2182 keyEvent.windowsKeyCode = VKEY_SPACE;
2180 keyEvent.type = WebInputEvent::RawKeyDown; 2183 keyEvent.type = WebInputEvent::RawKeyDown;
2181 keyEvent.setKeyIdentifierFromWindowsKeyCode(); 2184 keyEvent.setKeyIdentifierFromWindowsKeyCode();
2182 webView->handleInputEvent(keyEvent); 2185 webView->handleInputEvent(keyEvent);
2183 2186
2184 keyEvent.type = WebInputEvent::KeyUp; 2187 keyEvent.type = WebInputEvent::KeyUp;
2185 webView->handleInputEvent(keyEvent); 2188 webView->handleInputEvent(keyEvent);
2186 } 2189 }
2187 2190
2188 // TODO(crbug.com/605112) This test is crashing on Android (Nexus 4) bot. 2191 // TODO(crbug.com/605112) This test is crashing on Android (Nexus 4) bot.
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html")); 2800 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html"));
2798 MockAutofillClient client; 2801 MockAutofillClient client;
2799 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true); 2802 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true);
2800 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 2803 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
2801 frame->setAutofillClient(&client); 2804 frame->setAutofillClient(&client);
2802 webView->setInitialFocus(false); 2805 webView->setInitialFocus(false);
2803 2806
2804 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 2807 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
2805 2808
2806 WebKeyboardEvent keyEvent; 2809 WebKeyboardEvent keyEvent;
2810 keyEvent.domKey = ui::DomKey::FromCharacter(' ');
2807 keyEvent.windowsKeyCode = VKEY_SPACE; 2811 keyEvent.windowsKeyCode = VKEY_SPACE;
2808 keyEvent.type = WebInputEvent::RawKeyDown; 2812 keyEvent.type = WebInputEvent::RawKeyDown;
2809 keyEvent.setKeyIdentifierFromWindowsKeyCode(); 2813 keyEvent.setKeyIdentifierFromWindowsKeyCode();
2810 webView->handleInputEvent(keyEvent); 2814 webView->handleInputEvent(keyEvent);
2811 keyEvent.type = WebInputEvent::KeyUp; 2815 keyEvent.type = WebInputEvent::KeyUp;
2812 webView->handleInputEvent(keyEvent); 2816 webView->handleInputEvent(keyEvent);
2813 2817
2814 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 2818 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
2815 frame->setAutofillClient(0); 2819 frame->setAutofillClient(0);
2816 } 2820 }
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 frame->setAutofillClient(&client); 3185 frame->setAutofillClient(&client);
3182 webView->setInitialFocus(false); 3186 webView->setInitialFocus(false);
3183 3187
3184 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3188 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3185 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3189 EXPECT_EQ(1, client.textChangesFromUserGesture());
3186 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3190 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3187 frame->setAutofillClient(0); 3191 frame->setAutofillClient(0);
3188 } 3192 }
3189 3193
3190 } // namespace blink 3194 } // namespace blink
OLDNEW
« third_party/WebKit/Source/web/tests/DEPS ('K') | « third_party/WebKit/Source/web/tests/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698