| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "public/web/WebWidget.h" | 87 #include "public/web/WebWidget.h" |
| 88 #include "public/web/WebWidgetClient.h" | 88 #include "public/web/WebWidgetClient.h" |
| 89 #include "testing/gtest/include/gtest/gtest.h" | 89 #include "testing/gtest/include/gtest/gtest.h" |
| 90 #include "third_party/skia/include/core/SkBitmap.h" | 90 #include "third_party/skia/include/core/SkBitmap.h" |
| 91 #include "third_party/skia/include/core/SkCanvas.h" | 91 #include "third_party/skia/include/core/SkCanvas.h" |
| 92 #include "web/WebLocalFrameImpl.h" | 92 #include "web/WebLocalFrameImpl.h" |
| 93 #include "web/WebSettingsImpl.h" | 93 #include "web/WebSettingsImpl.h" |
| 94 #include "web/WebViewImpl.h" | 94 #include "web/WebViewImpl.h" |
| 95 #include "web/tests/FrameTestHelpers.h" | 95 #include "web/tests/FrameTestHelpers.h" |
| 96 | 96 |
| 97 #if OS(MACOSX) |
| 98 #include "public/web/mac/WebSubstringUtil.h" |
| 99 #endif |
| 100 |
| 97 using blink::FrameTestHelpers::loadFrame; | 101 using blink::FrameTestHelpers::loadFrame; |
| 98 using blink::URLTestHelpers::toKURL; | 102 using blink::URLTestHelpers::toKURL; |
| 99 using blink::URLTestHelpers::registerMockedURLLoad; | 103 using blink::URLTestHelpers::registerMockedURLLoad; |
| 100 using blink::testing::runPendingTasks; | 104 using blink::testing::runPendingTasks; |
| 101 | 105 |
| 102 namespace blink { | 106 namespace blink { |
| 103 | 107 |
| 104 enum HorizontalScrollbarState { | 108 enum HorizontalScrollbarState { |
| 105 NoHorizontalScrollbar, | 109 NoHorizontalScrollbar, |
| 106 VisibleHorizontalScrollbar, | 110 VisibleHorizontalScrollbar, |
| (...skipping 3069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 | 3180 |
| 3177 WebFrame* frame = mainWebView.webView()->mainFrame(); | 3181 WebFrame* frame = mainWebView.webView()->mainFrame(); |
| 3178 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3182 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 3179 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); | 3183 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); |
| 3180 ASSERT_TRUE(v8Value->IsObject()); | 3184 ASSERT_TRUE(v8Value->IsObject()); |
| 3181 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent
(), v8Value); | 3185 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent
(), v8Value); |
| 3182 ASSERT_TRUE(document); | 3186 ASSERT_TRUE(document); |
| 3183 EXPECT_FALSE(document->frame()->isLoading()); | 3187 EXPECT_FALSE(document->frame()->isLoading()); |
| 3184 } | 3188 } |
| 3185 | 3189 |
| 3190 #if OS(MACOSX) |
| 3191 TEST_F(WebViewTest, WebSubstringUtil) |
| 3192 { |
| 3193 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); |
| 3194 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_ed
itable_populated.html"); |
| 3195 webView->settings()->setDefaultFontSize(12); |
| 3196 webView->resize(WebSize(400, 400)); |
| 3197 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 3198 FrameView* frameView = frame->frame()->view(); |
| 3199 |
| 3200 WebPoint baselinePoint; |
| 3201 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); |
| 3202 ASSERT_TRUE(!!result); |
| 3203 |
| 3204 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3205 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); |
| 3206 ASSERT_TRUE(!!result); |
| 3207 |
| 3208 webView->setZoomLevel(3); |
| 3209 |
| 3210 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); |
| 3211 ASSERT_TRUE(!!result); |
| 3212 |
| 3213 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3214 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); |
| 3215 ASSERT_TRUE(!!result); |
| 3216 } |
| 3217 #endif |
| 3218 |
| 3186 } // namespace blink | 3219 } // namespace blink |
| OLD | NEW |