| 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 "public/platform/Platform.h" | 7 #include "public/platform/Platform.h" |
| 8 #include "public/platform/WebUnitTestSupport.h" | 8 #include "public/platform/WebUnitTestSupport.h" |
| 9 #include "web/tests/FrameTestHelpers.h" | 9 #include "web/tests/FrameTestHelpers.h" |
| 10 #include "web/tests/URLTestHelpers.h" | 10 #include "web/tests/URLTestHelpers.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 : m_baseURL("http://www.test.com/") | 50 : m_baseURL("http://www.test.com/") |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void TearDown() | 54 virtual void TearDown() |
| 55 { | 55 { |
| 56 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 56 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 void sendGestureTap(WebView*, WebCore::IntPoint); | 60 void sendGestureTap(WebView*, blink::IntPoint); |
| 61 void runImeOnFocusTest(std::string, int, WebCore::IntPoint tapPoint = WebCor
e::IntPoint(-1, -1)); | 61 void runImeOnFocusTest(std::string, int, blink::IntPoint tapPoint = blink::I
ntPoint(-1, -1)); |
| 62 | 62 |
| 63 std::string m_baseURL; | 63 std::string m_baseURL; |
| 64 FrameTestHelpers::WebViewHelper m_webViewHelper; | 64 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 void ImeOnFocusTest::sendGestureTap(WebView* webView, WebCore::IntPoint clientPo
int) | 67 void ImeOnFocusTest::sendGestureTap(WebView* webView, blink::IntPoint clientPoin
t) |
| 68 { | 68 { |
| 69 WebGestureEvent webGestureEvent; | 69 WebGestureEvent webGestureEvent; |
| 70 webGestureEvent.type = WebInputEvent::GestureTap; | 70 webGestureEvent.type = WebInputEvent::GestureTap; |
| 71 webGestureEvent.x = clientPoint.x(); | 71 webGestureEvent.x = clientPoint.x(); |
| 72 webGestureEvent.y = clientPoint.y(); | 72 webGestureEvent.y = clientPoint.y(); |
| 73 webGestureEvent.globalX = clientPoint.x(); | 73 webGestureEvent.globalX = clientPoint.x(); |
| 74 webGestureEvent.globalY = clientPoint.y(); | 74 webGestureEvent.globalY = clientPoint.y(); |
| 75 webGestureEvent.data.tap.tapCount = 1; | 75 webGestureEvent.data.tap.tapCount = 1; |
| 76 webGestureEvent.data.tap.width = 10; | 76 webGestureEvent.data.tap.width = 10; |
| 77 webGestureEvent.data.tap.height = 10; | 77 webGestureEvent.data.tap.height = 10; |
| 78 | 78 |
| 79 webView->handleInputEvent(webGestureEvent); | 79 webView->handleInputEvent(webGestureEvent); |
| 80 FrameTestHelpers::runPendingTasks(); | 80 FrameTestHelpers::runPendingTasks(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ImeOnFocusTest::runImeOnFocusTest(std::string file, int expectedImeRequestC
ount, WebCore::IntPoint tapPoint) | 83 void ImeOnFocusTest::runImeOnFocusTest(std::string file, int expectedImeRequestC
ount, blink::IntPoint tapPoint) |
| 84 { | 84 { |
| 85 ImeRequestTrackingWebViewClient client; | 85 ImeRequestTrackingWebViewClient client; |
| 86 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); | 86 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); |
| 87 WebView* webView = m_webViewHelper.initialize(true, 0, &client); | 87 WebView* webView = m_webViewHelper.initialize(true, 0, &client); |
| 88 m_webViewHelper.webView()->setPageScaleFactorLimits(1, 1); | 88 m_webViewHelper.webView()->setPageScaleFactorLimits(1, 1); |
| 89 webView->resize(WebSize(800, 1200)); | 89 webView->resize(WebSize(800, 1200)); |
| 90 | 90 |
| 91 EXPECT_EQ(0, client.imeRequestCount()); | 91 EXPECT_EQ(0, client.imeRequestCount()); |
| 92 FrameTestHelpers::loadFrame(webView->mainFrame(), m_baseURL + file); | 92 FrameTestHelpers::loadFrame(webView->mainFrame(), m_baseURL + file); |
| 93 if (tapPoint.x() >= 0 && tapPoint.y() >= 0) | 93 if (tapPoint.x() >= 0 && tapPoint.y() >= 0) |
| 94 sendGestureTap(webView, tapPoint); | 94 sendGestureTap(webView, tapPoint); |
| 95 EXPECT_EQ(expectedImeRequestCount, client.imeRequestCount()); | 95 EXPECT_EQ(expectedImeRequestCount, client.imeRequestCount()); |
| 96 | 96 |
| 97 m_webViewHelper.reset(); | 97 m_webViewHelper.reset(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(ImeOnFocusTest, OnLoad) | 100 TEST_F(ImeOnFocusTest, OnLoad) |
| 101 { | 101 { |
| 102 runImeOnFocusTest("ime-on-focus-on-load.html", 0); | 102 runImeOnFocusTest("ime-on-focus-on-load.html", 0); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(ImeOnFocusTest, OnAutofocus) | 105 TEST_F(ImeOnFocusTest, OnAutofocus) |
| 106 { | 106 { |
| 107 runImeOnFocusTest("ime-on-focus-on-autofocus.html", 0); | 107 runImeOnFocusTest("ime-on-focus-on-autofocus.html", 0); |
| 108 } | 108 } |
| 109 | 109 |
| 110 TEST_F(ImeOnFocusTest, OnUserGesture) | 110 TEST_F(ImeOnFocusTest, OnUserGesture) |
| 111 { | 111 { |
| 112 runImeOnFocusTest("ime-on-focus-on-user-gesture.html", 1, WebCore::IntPoint(
50, 50)); | 112 runImeOnFocusTest("ime-on-focus-on-user-gesture.html", 1, blink::IntPoint(50
, 50)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } | 115 } |
| OLD | NEW |