Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 1616813002: Consider Zoom factor when getting bounding rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a test. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/mac/WebSubstringUtil.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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");
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
3195 webView->resize(WebSize(400, 400));
3196 WebLocalFrame* frame = toWebLocalFrameImpl(webView->mainFrame());
3197 LocalFrame* localFrame = toWebLocalFrameImpl(frame)->frame();
3198 localFrame->view()->layout();
3199
3200 WebPoint baselinePoint;
3201 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr ame, 10, 3, &baselinePoint);
3202 ASSERT_TRUE(!!result);
3203 printf("=====baseline: %d, %d\n", baselinePoint.x, baselinePoint.y);
3204
3205 WebPoint point(baselinePoint.x, localFrame->view()->height() - baselinePoint .y);
3206 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt);
3207 ASSERT_TRUE(!!result);
3208 }
3209 #endif
3210
3186 } // namespace blink 3211 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/mac/WebSubstringUtil.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698