Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| index d276af66905c075db75afc84d80e65087912c83b..3abe12672d4824f87d75d9d68a84c94ae2f7fade 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| @@ -85,6 +85,7 @@ |
| #include "modules/mediastream/MediaStreamRegistry.h" |
| #include "platform/Cursor.h" |
| #include "platform/DragImage.h" |
| +#include "platform/KeyboardCodes.h" |
| #include "platform/PlatformResourceLoader.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/UserGestureIndicator.h" |
| @@ -109,6 +110,7 @@ |
| #include "public/platform/WebCachePolicy.h" |
| #include "public/platform/WebClipboard.h" |
| #include "public/platform/WebFloatRect.h" |
| +#include "public/platform/WebKeyboardEvent.h" |
| #include "public/platform/WebMockClipboard.h" |
| #include "public/platform/WebSecurityOrigin.h" |
| #include "public/platform/WebThread.h" |
| @@ -4257,6 +4259,62 @@ TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) { |
| EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); |
| } |
| +class ChangedSelectionCounter : public FrameTestHelpers::TestWebFrameClient { |
| + public: |
| + ChangedSelectionCounter() : m_callCount(0) {} |
| + void didChangeSelection(bool isSelectionEmpty) { ++m_callCount; } |
| + int count() const { return m_callCount; } |
| + void reset() { m_callCount = 0; } |
| + |
| + private: |
| + int m_callCount; |
| +}; |
| + |
| +TEST_P(ParameterizedWebFrameTest, TabKeyCursorMoveTriggersOneSelectionChange) { |
| + ChangedSelectionCounter counter; |
| + FrameTestHelpers::WebViewHelper webViewHelper; |
| + registerMockedHttpURLLoad("editable_elements.html"); |
| + WebViewImpl* webView = webViewHelper.initializeAndLoad( |
| + m_baseURL + "editable_elements.html", true, &counter); |
| + |
| + WebKeyboardEvent tabDownEvent(WebInputEvent::KeyDown, |
| + WebInputEvent::NoModifiers, |
| + WebInputEvent::TimeStampForTesting); |
| + WebKeyboardEvent tabUpEvent(WebInputEvent::KeyUp, WebInputEvent::NoModifiers, |
| + WebInputEvent::TimeStampForTesting); |
| + tabDownEvent.domKey = Platform::current()->domKeyEnumFromString("\t"); |
| + tabUpEvent.domKey = Platform::current()->domKeyEnumFromString("\t"); |
| + tabDownEvent.windowsKeyCode = VKEY_TAB; |
| + tabUpEvent.windowsKeyCode = VKEY_TAB; |
| + |
| + // Move to the next text-field: 1 cursor change. |
| + counter.reset(); |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent)); |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent)); |
| + EXPECT_EQ(1, counter.count()); |
| + |
| + // Move to another text-field: 1 cursor change. |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent)); |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent)); |
| + EXPECT_EQ(2, counter.count()); |
| + |
| + // Move to a number-field: 1 cursor change. |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent)); |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent)); |
| + EXPECT_EQ(3, counter.count()); |
| + |
| + // Move to an editable element: 1 cursor change. |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent)); |
| + webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent)); |
| + EXPECT_EQ(4, counter.count()); |
| + |
| + // Move to a non-editable element: 0 cursor changes. |
| + // TODO(blink-editing): Once we've fixed crbug.com/692898 test this too: |
|
yosin_UTC9
2017/03/21 06:49:59
nit: s/blink-editing/editing-dev/
hugoh_UTC2
2017/03/22 02:54:47
Done.
|
| + // webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent)); |
| + // webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent)); |
| + // EXPECT_EQ(4, counter.count()); |
| +} |
| + |
| // Implementation of WebFrameClient that tracks the v8 contexts that are created |
| // and destroyed for verification. |
| class ContextLifetimeTestWebFrameClient |