| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
| 9 #include "core/dom/Node.h" | 9 #include "core/dom/Node.h" |
| 10 #include "core/html/HTMLElement.h" | 10 #include "core/html/HTMLElement.h" |
| 11 #include "core/testing/URLTestHelpers.h" | 11 #include "core/testing/URLTestHelpers.h" |
| 12 #include "core/testing/UnitTestHelpers.h" |
| 12 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
| 13 #include "public/platform/WebUnitTestSupport.h" | 14 #include "public/platform/WebUnitTestSupport.h" |
| 14 #include "public/web/WebDocument.h" | 15 #include "public/web/WebDocument.h" |
| 15 #include "web/WebLocalFrameImpl.h" | 16 #include "web/WebLocalFrameImpl.h" |
| 16 #include "web/tests/FrameTestHelpers.h" | 17 #include "web/tests/FrameTestHelpers.h" |
| 17 | 18 |
| 18 #include <gtest/gtest.h> | 19 #include <gtest/gtest.h> |
| 19 | 20 |
| 20 using namespace blink; | 21 using namespace blink; |
| 21 using blink::FrameTestHelpers::runPendingTasks; | |
| 22 using blink::FrameTestHelpers::loadFrame; | 22 using blink::FrameTestHelpers::loadFrame; |
| 23 using blink::testing::runPendingTasks; |
| 23 using URLTestHelpers::registerMockedURLFromBaseURL; | 24 using URLTestHelpers::registerMockedURLFromBaseURL; |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class ImeRequestTrackingWebViewClient : public FrameTestHelpers::TestWebViewClie
nt { | 28 class ImeRequestTrackingWebViewClient : public FrameTestHelpers::TestWebViewClie
nt { |
| 28 public: | 29 public: |
| 29 ImeRequestTrackingWebViewClient() : | 30 ImeRequestTrackingWebViewClient() : |
| 30 m_imeRequestCount(0) | 31 m_imeRequestCount(0) |
| 31 { | 32 { |
| 32 } | 33 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 | 46 |
| 46 int imeRequestCount() | 47 int imeRequestCount() |
| 47 { | 48 { |
| 48 return m_imeRequestCount; | 49 return m_imeRequestCount; |
| 49 } | 50 } |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 int m_imeRequestCount; | 53 int m_imeRequestCount; |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 class ImeOnFocusTest : public testing::Test { | 56 class ImeOnFocusTest : public ::testing::Test { |
| 56 public: | 57 public: |
| 57 ImeOnFocusTest() | 58 ImeOnFocusTest() |
| 58 : m_baseURL("http://www.test.com/") | 59 : m_baseURL("http://www.test.com/") |
| 59 { | 60 { |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual void TearDown() | 63 virtual void TearDown() |
| 63 { | 64 { |
| 64 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 65 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 65 } | 66 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 webGestureEvent.type = WebInputEvent::GestureTap; | 81 webGestureEvent.type = WebInputEvent::GestureTap; |
| 81 webGestureEvent.x = clientPoint.x(); | 82 webGestureEvent.x = clientPoint.x(); |
| 82 webGestureEvent.y = clientPoint.y(); | 83 webGestureEvent.y = clientPoint.y(); |
| 83 webGestureEvent.globalX = clientPoint.x(); | 84 webGestureEvent.globalX = clientPoint.x(); |
| 84 webGestureEvent.globalY = clientPoint.y(); | 85 webGestureEvent.globalY = clientPoint.y(); |
| 85 webGestureEvent.data.tap.tapCount = 1; | 86 webGestureEvent.data.tap.tapCount = 1; |
| 86 webGestureEvent.data.tap.width = 10; | 87 webGestureEvent.data.tap.width = 10; |
| 87 webGestureEvent.data.tap.height = 10; | 88 webGestureEvent.data.tap.height = 10; |
| 88 | 89 |
| 89 webView->handleInputEvent(webGestureEvent); | 90 webView->handleInputEvent(webGestureEvent); |
| 90 FrameTestHelpers::runPendingTasks(); | 91 runPendingTasks(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void ImeOnFocusTest::focus(const WTF::AtomicString& element) | 94 void ImeOnFocusTest::focus(const WTF::AtomicString& element) |
| 94 { | 95 { |
| 95 m_document->body()->getElementById(element)->focus(); | 96 m_document->body()->getElementById(element)->focus(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void ImeOnFocusTest::runImeOnFocusTest(std::string fileName, int expectedImeRequ
estCount, IntPoint tapPoint, const WTF::AtomicString& focusElement, std::string
frame) | 99 void ImeOnFocusTest::runImeOnFocusTest(std::string fileName, int expectedImeRequ
estCount, IntPoint tapPoint, const WTF::AtomicString& focusElement, std::string
frame) |
| 99 { | 100 { |
| 100 ImeRequestTrackingWebViewClient client; | 101 ImeRequestTrackingWebViewClient client; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 { | 149 { |
| 149 runImeOnFocusTest("ime-on-focus-after-navigation-within-page.html", 1, IntPo
int(50, 50), "input"); | 150 runImeOnFocusTest("ime-on-focus-after-navigation-within-page.html", 1, IntPo
int(50, 50), "input"); |
| 150 } | 151 } |
| 151 | 152 |
| 152 TEST_F(ImeOnFocusTest, AfterFrameLoadOnGesture) | 153 TEST_F(ImeOnFocusTest, AfterFrameLoadOnGesture) |
| 153 { | 154 { |
| 154 runImeOnFocusTest("ime-on-focus-after-frame-load-on-gesture.html", 1, IntPoi
nt(50, 50), "input", "frame.html"); | 155 runImeOnFocusTest("ime-on-focus-after-frame-load-on-gesture.html", 1, IntPoi
nt(50, 50), "input", "frame.html"); |
| 155 } | 156 } |
| 156 | 157 |
| 157 } | 158 } |
| OLD | NEW |