Index: third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp |
diff --git a/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp b/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp |
index 54c6c7d18c4086d82308aac69e7372510d1879b0..0f377f75a7664c81e76ef085ccc9c8768efc4246 100644 |
--- a/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp |
@@ -45,6 +45,7 @@ |
#include "core/page/Page.h" |
#include "platform/geometry/IntSize.h" |
#include "platform/testing/URLTestHelpers.h" |
+#include "platform/testing/UnitTestHelpers.h" |
#include "public/web/WebFrame.h" |
#include "public/web/WebSettings.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -54,6 +55,8 @@ |
namespace blink { |
+namespace { |
+ |
KeyboardEvent* createKeyboardEventWithLocation( |
KeyboardEvent::KeyLocationCode location) { |
KeyboardEventInit keyEventInit; |
@@ -69,6 +72,15 @@ int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) { |
return convertedEvent.modifiers(); |
} |
+void registerMockedURL(const std::string& baseURL, |
+ const std::string& fileName) { |
+ URLTestHelpers::registerMockedURLLoadFromBase( |
+ WebString::fromUTF8(baseURL.c_str()), testing::webTestDataPath(), |
kinuko
2017/01/26 09:32:41
ditto
Takashi Toyoshima
2017/01/26 10:57:58
Done.
|
+ WebString::fromUTF8(fileName)); |
+} |
+ |
+} // namespace |
+ |
TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) { |
// Test key location conversion. |
int modifiers = |
@@ -106,9 +118,7 @@ TEST(WebInputEventConversionTest, WebTouchEventBuilder) { |
const std::string baseURL("http://www.test0.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -302,9 +312,7 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { |
const std::string baseURL("http://www.test1.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -584,9 +592,7 @@ TEST(WebInputEventConversionTest, InputEventsTransform) { |
const std::string baseURL("http://www.test2.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -849,9 +855,7 @@ TEST(WebInputEventConversionTest, InputEventsConversions) { |
const std::string baseURL("http://www.test3.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -890,9 +894,7 @@ TEST(WebInputEventConversionTest, VisualViewportOffset) { |
const std::string baseURL("http://www.test4.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -999,9 +1001,7 @@ TEST(WebInputEventConversionTest, ElasticOverscroll) { |
const std::string baseURL("http://www.test5.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |
@@ -1072,9 +1072,7 @@ TEST(WebInputEventConversionTest, ElasticOverscrollWithPageReload) { |
const std::string baseURL("http://www.test6.com/"); |
const std::string fileName("fixed_layout.html"); |
- URLTestHelpers::registerMockedURLFromBaseURL( |
- WebString::fromUTF8(baseURL.c_str()), |
- WebString::fromUTF8("fixed_layout.html")); |
+ registerMockedURL(baseURL, fileName); |
FrameTestHelpers::WebViewHelper webViewHelper; |
WebViewImpl* webViewImpl = |
webViewHelper.initializeAndLoad(baseURL + fileName, true); |