Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| index ff330cdf7300e65f08184913904f6fa42c02805b..b3390cb0100dd04ae21d262631f4d0ca147321aa 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| @@ -94,6 +94,10 @@ |
| #include "web/WebViewImpl.h" |
| #include "web/tests/FrameTestHelpers.h" |
| +#if OS(MACOSX) |
| +#include "public/web/mac/WebSubstringUtil.h" |
| +#endif |
| + |
| using blink::FrameTestHelpers::loadFrame; |
| using blink::URLTestHelpers::toKURL; |
| using blink::URLTestHelpers::registerMockedURLLoad; |
| @@ -3183,4 +3187,25 @@ TEST_F(WebViewTest, StopLoadingIfJavaScriptURLReturnsNoStringResult) |
| EXPECT_FALSE(document->frame()->isLoading()); |
| } |
| +#if OS(MACOSX) |
| +TEST_F(WebViewTest, WebSubstringUtil) |
| +{ |
| + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("content_editable_populated.html")); |
| + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_populated.html"); |
|
keishi
2016/01/27 13:08:39
Looks like the font size is 1px because the defaul
Shu Chen
2016/01/27 13:58:28
Thanks, keishi@. Now I want to test for page is zo
|
| + webView->resize(WebSize(400, 400)); |
| + WebLocalFrame* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| + LocalFrame* localFrame = toWebLocalFrameImpl(frame)->frame(); |
| + localFrame->view()->layout(); |
| + |
| + WebPoint baselinePoint; |
| + NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(frame, 10, 3, &baselinePoint); |
| + ASSERT_TRUE(!!result); |
| + printf("=====baseline: %d, %d\n", baselinePoint.x, baselinePoint.y); |
| + |
| + WebPoint point(baselinePoint.x, localFrame->view()->height() - baselinePoint.y); |
| + result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoint); |
| + ASSERT_TRUE(!!result); |
| +} |
| +#endif |
| + |
| } // namespace blink |