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

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

Issue 2012823003: Move IME related functions from WebFrame to WebLocalFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove null check in spellcheck_provider.cc and add some log Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 FrameTestHelpers::WebViewHelper webViewHelper(this); 3192 FrameTestHelpers::WebViewHelper webViewHelper(this);
3193 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); 3193 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html");
3194 webViewHelper.resize(WebSize(640, 480)); 3194 webViewHelper.resize(WebSize(640, 480));
3195 3195
3196 webViewHelper.webViewImpl()->setPageScaleFactor(2); 3196 webViewHelper.webViewImpl()->setPageScaleFactor(2);
3197 webViewHelper.webViewImpl()->setVisualViewportOffset(WebFloatPoint(50, 60)); 3197 webViewHelper.webViewImpl()->setVisualViewportOffset(WebFloatPoint(50, 60));
3198 3198
3199 WebRect baseRect; 3199 WebRect baseRect;
3200 WebRect extentRect; 3200 WebRect extentRect;
3201 3201
3202 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); 3202 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame();
3203 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); 3203 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388));
3204 3204
3205 EXPECT_EQ(2ul, ix); 3205 EXPECT_EQ(2ul, ix);
3206 } 3206 }
3207 3207
3208 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) 3208 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom)
3209 { 3209 {
3210 registerMockedHttpURLLoad("textbox.html"); 3210 registerMockedHttpURLLoad("textbox.html");
3211 3211
3212 FrameTestHelpers::WebViewHelper webViewHelper(this); 3212 FrameTestHelpers::WebViewHelper webViewHelper(this);
3213 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); 3213 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true);
3214 webViewHelper.resize(WebSize(640, 480)); 3214 webViewHelper.resize(WebSize(640, 480));
3215 3215
3216 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); 3216 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame();
3217 mainFrame->executeScript(WebScriptSource("selectRange();")); 3217 mainFrame->executeScript(WebScriptSource("selectRange();"));
3218 3218
3219 WebRect oldRect; 3219 WebRect oldRect;
3220 mainFrame->firstRectForCharacterRange(0, 5, oldRect); 3220 mainFrame->firstRectForCharacterRange(0, 5, oldRect);
3221 3221
3222 WebFloatPoint visualOffset(100, 130); 3222 WebFloatPoint visualOffset(100, 130);
3223 float scale = 2; 3223 float scale = 2;
3224 webViewHelper.webViewImpl()->setPageScaleFactor(scale); 3224 webViewHelper.webViewImpl()->setPageScaleFactor(scale);
3225 webViewHelper.webViewImpl()->setVisualViewportOffset(visualOffset); 3225 webViewHelper.webViewImpl()->setVisualViewportOffset(visualOffset);
3226 3226
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 // Get the frame text where the subframe separator falls on the boundary of 3660 // Get the frame text where the subframe separator falls on the boundary of
3661 // what we'll take. There used to be a crash in this case. 3661 // what we'll take. There used to be a crash in this case.
3662 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ; 3662 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ;
3663 EXPECT_EQ("Hello world", text.utf8()); 3663 EXPECT_EQ("Hello world", text.utf8());
3664 } 3664 }
3665 3665
3666 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) 3666 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage)
3667 { 3667 {
3668 FrameTestHelpers::WebViewHelper webViewHelper(this); 3668 FrameTestHelpers::WebViewHelper webViewHelper(this);
3669 webViewHelper.initializeAndLoad("about:blank", true); 3669 webViewHelper.initializeAndLoad("about:blank", true);
3670 WebFrame* frame = webViewHelper.webView()->mainFrame(); 3670 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
3671 3671
3672 // Generate a simple test case. 3672 // Generate a simple test case.
3673 const char simpleSource[] = "<p>Hello</p><p>World</p>"; 3673 const char simpleSource[] = "<p>Hello</p><p>World</p>";
3674 KURL testURL = toKURL("about:blank"); 3674 KURL testURL = toKURL("about:blank");
3675 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); 3675 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
3676 3676
3677 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max()); 3677 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max());
3678 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3678 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3679 3679
3680 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame->toWebLoc alFrame()).utf8(); 3680 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame).utf8();
3681 3681
3682 // Load again with the output html. 3682 // Load again with the output html.
3683 FrameTestHelpers::loadHTMLString(frame, html, testURL); 3683 FrameTestHelpers::loadHTMLString(frame, html, testURL);
3684 3684
3685 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame->toWebLocalFrame() ).utf8()); 3685 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame).utf8());
3686 3686
3687 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max()); 3687 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max());
3688 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3688 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3689 3689
3690 // Test selection check 3690 // Test selection check
3691 EXPECT_FALSE(frame->hasSelection()); 3691 EXPECT_FALSE(frame->hasSelection());
3692 frame->executeCommand(WebString::fromUTF8("SelectAll")); 3692 frame->executeCommand(WebString::fromUTF8("SelectAll"));
3693 EXPECT_TRUE(frame->hasSelection()); 3693 EXPECT_TRUE(frame->hasSelection());
3694 frame->executeCommand(WebString::fromUTF8("Unselect")); 3694 frame->executeCommand(WebString::fromUTF8("Unselect"));
3695 EXPECT_FALSE(frame->hasSelection()); 3695 EXPECT_FALSE(frame->hasSelection());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
4123 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 4123 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
4124 } 4124 }
4125 4125
4126 static WebRect elementBounds(WebFrame* frame, const WebString& id) 4126 static WebRect elementBounds(WebFrame* frame, const WebString& id)
4127 { 4127 {
4128 return frame->document().getElementById(id).boundsInViewport(); 4128 return frame->document().getElementById(id).boundsInViewport();
4129 } 4129 }
4130 4130
4131 static std::string selectionAsString(WebFrame* frame) 4131 static std::string selectionAsString(WebFrame* frame)
4132 { 4132 {
4133 return frame->selectionAsText().utf8(); 4133 return frame->toWebLocalFrame()->selectionAsText().utf8();
4134 } 4134 }
4135 4135
4136 TEST_P(ParameterizedWebFrameTest, SelectRange) 4136 TEST_P(ParameterizedWebFrameTest, SelectRange)
4137 { 4137 {
4138 WebFrame* frame; 4138 WebLocalFrame* frame;
4139 WebRect startWebRect; 4139 WebRect startWebRect;
4140 WebRect endWebRect; 4140 WebRect endWebRect;
4141 4141
4142 registerMockedHttpURLLoad("select_range_basic.html"); 4142 registerMockedHttpURLLoad("select_range_basic.html");
4143 registerMockedHttpURLLoad("select_range_scroll.html"); 4143 registerMockedHttpURLLoad("select_range_scroll.html");
4144 4144
4145 FrameTestHelpers::WebViewHelper webViewHelper(this); 4145 FrameTestHelpers::WebViewHelper webViewHelper(this);
4146 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper); 4146 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper);
4147 frame = webViewHelper.webView()->mainFrame(); 4147 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4148 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); 4148 EXPECT_EQ("Some test text for testing.", selectionAsString(frame));
4149 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4149 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4150 frame->executeCommand(WebString::fromUTF8("Unselect")); 4150 frame->executeCommand(WebString::fromUTF8("Unselect"));
4151 EXPECT_EQ("", selectionAsString(frame)); 4151 EXPECT_EQ("", selectionAsString(frame));
4152 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4152 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4153 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4153 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4154 std::string selectionString = selectionAsString(frame); 4154 std::string selectionString = selectionAsString(frame);
4155 EXPECT_TRUE(selectionString == "Some test text for testing." 4155 EXPECT_TRUE(selectionString == "Some test text for testing."
4156 || selectionString == "Some test text for testing"); 4156 || selectionString == "Some test text for testing");
4157 4157
4158 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper); 4158 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper);
4159 frame = webViewHelper.webView()->mainFrame(); 4159 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4160 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ; 4160 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ;
4161 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4161 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4162 frame->executeCommand(WebString::fromUTF8("Unselect")); 4162 frame->executeCommand(WebString::fromUTF8("Unselect"));
4163 EXPECT_EQ("", selectionAsString(frame)); 4163 EXPECT_EQ("", selectionAsString(frame));
4164 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4164 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4165 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4165 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4166 selectionString = selectionAsString(frame); 4166 selectionString = selectionAsString(frame);
4167 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." 4167 EXPECT_TRUE(selectionString == "Some offscreen test text for testing."
4168 || selectionString == "Some offscreen test text for testing"); 4168 || selectionString == "Some offscreen test text for testing");
4169 } 4169 }
4170 4170
4171 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) 4171 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe)
4172 { 4172 {
4173 WebFrame* frame; 4173 WebFrame* frame;
4174 WebRect startWebRect; 4174 WebRect startWebRect;
4175 WebRect endWebRect; 4175 WebRect endWebRect;
4176 4176
4177 registerMockedHttpURLLoad("select_range_iframe.html"); 4177 registerMockedHttpURLLoad("select_range_iframe.html");
4178 registerMockedHttpURLLoad("select_range_basic.html"); 4178 registerMockedHttpURLLoad("select_range_basic.html");
4179 4179
4180 FrameTestHelpers::WebViewHelper webViewHelper(this); 4180 FrameTestHelpers::WebViewHelper webViewHelper(this);
4181 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper); 4181 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper);
4182 frame = webViewHelper.webView()->mainFrame(); 4182 frame = webViewHelper.webView()->mainFrame();
4183 WebFrame* subframe = frame->firstChild(); 4183 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame();
4184 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); 4184 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe));
4185 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4185 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4186 subframe->executeCommand(WebString::fromUTF8("Unselect")); 4186 subframe->executeCommand(WebString::fromUTF8("Unselect"));
4187 EXPECT_EQ("", selectionAsString(subframe)); 4187 EXPECT_EQ("", selectionAsString(subframe));
4188 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) ); 4188 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) );
4189 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4189 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4190 std::string selectionString = selectionAsString(subframe); 4190 std::string selectionString = selectionAsString(subframe);
4191 EXPECT_TRUE(selectionString == "Some test text for testing." 4191 EXPECT_TRUE(selectionString == "Some test text for testing."
4192 || selectionString == "Some test text for testing"); 4192 || selectionString == "Some test text for testing");
4193 } 4193 }
4194 4194
4195 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) 4195 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable)
4196 { 4196 {
4197 WebFrame* frame; 4197 WebLocalFrame* frame;
4198 WebRect startWebRect; 4198 WebRect startWebRect;
4199 WebRect endWebRect; 4199 WebRect endWebRect;
4200 4200
4201 registerMockedHttpURLLoad("select_range_div_editable.html"); 4201 registerMockedHttpURLLoad("select_range_div_editable.html");
4202 4202
4203 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4203 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4204 // The selection range should be clipped to the bounds of the editable eleme nt. 4204 // The selection range should be clipped to the bounds of the editable eleme nt.
4205 FrameTestHelpers::WebViewHelper webViewHelper(this); 4205 FrameTestHelpers::WebViewHelper webViewHelper(this);
4206 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4206 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4207 frame = webViewHelper.webView()->mainFrame(); 4207 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4208 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4208 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4209 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4209 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4210 4210
4211 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4211 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4212 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4212 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4213 4213
4214 // As above, but extending the selection to the bottom of the document. 4214 // As above, but extending the selection to the bottom of the document.
4215 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4215 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4216 frame = webViewHelper.webView()->mainFrame(); 4216 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4217 4217
4218 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4218 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4219 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4219 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4220 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4220 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4221 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4221 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4222 4222
4223 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4223 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4224 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4224 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4225 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4225 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4226 } 4226 }
4227 4227
4228 // positionForPoint returns the wrong values for contenteditable spans. See 4228 // positionForPoint returns the wrong values for contenteditable spans. See
4229 // http://crbug.com/238334. 4229 // http://crbug.com/238334.
4230 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) 4230 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable)
4231 { 4231 {
4232 WebFrame* frame; 4232 WebLocalFrame* frame;
4233 WebRect startWebRect; 4233 WebRect startWebRect;
4234 WebRect endWebRect; 4234 WebRect endWebRect;
4235 4235
4236 registerMockedHttpURLLoad("select_range_span_editable.html"); 4236 registerMockedHttpURLLoad("select_range_span_editable.html");
4237 4237
4238 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4238 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4239 // The selection range should be clipped to the bounds of the editable eleme nt. 4239 // The selection range should be clipped to the bounds of the editable eleme nt.
4240 FrameTestHelpers::WebViewHelper webViewHelper(this); 4240 FrameTestHelpers::WebViewHelper webViewHelper(this);
4241 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4241 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4242 frame = webViewHelper.webView()->mainFrame(); 4242 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4243 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4243 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4244 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4244 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4245 4245
4246 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4246 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4247 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4247 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4248 4248
4249 // As above, but extending the selection to the bottom of the document. 4249 // As above, but extending the selection to the bottom of the document.
4250 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4250 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4251 frame = webViewHelper.webView()->mainFrame(); 4251 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4252 4252
4253 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4253 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4254 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4254 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4255 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4255 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4256 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4256 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4257 4257
4258 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4258 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4259 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4259 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4260 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4260 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4261 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4261 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4262 } 4262 }
4263 4263
4264 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) 4264 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart)
4265 { 4265 {
4266 registerMockedHttpURLLoad("text_selection.html"); 4266 registerMockedHttpURLLoad("text_selection.html");
4267 FrameTestHelpers::WebViewHelper webViewHelper(this); 4267 FrameTestHelpers::WebViewHelper webViewHelper(this);
4268 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4268 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4269 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4269 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4270 4270
4271 // Select second span. We can move the start to include the first span. 4271 // Select second span. We can move the start to include the first span.
4272 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4272 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4273 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4273 EXPECT_EQ("Header 2.", selectionAsString(frame));
4274 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1"))); 4274 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1")));
4275 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4275 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4276 4276
4277 // We can move the start and end together. 4277 // We can move the start and end together.
4278 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4278 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4279 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4279 EXPECT_EQ("Header 1.", selectionAsString(frame));
(...skipping 27 matching lines...) Expand all
4307 // positionForPoint returns the wrong values for contenteditable spans. See 4307 // positionForPoint returns the wrong values for contenteditable spans. See
4308 // http://crbug.com/238334. 4308 // http://crbug.com/238334.
4309 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); 4309 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame));
4310 } 4310 }
4311 4311
4312 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) 4312 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd)
4313 { 4313 {
4314 registerMockedHttpURLLoad("text_selection.html"); 4314 registerMockedHttpURLLoad("text_selection.html");
4315 FrameTestHelpers::WebViewHelper webViewHelper(this); 4315 FrameTestHelpers::WebViewHelper webViewHelper(this);
4316 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4316 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4317 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4317 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4318 4318
4319 // Select first span. We can move the end to include the second span. 4319 // Select first span. We can move the end to include the second span.
4320 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4320 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4321 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4321 EXPECT_EQ("Header 1.", selectionAsString(frame));
4322 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2"))); 4322 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2")));
4323 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4323 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4324 4324
4325 // We can move the start and end together. 4325 // We can move the start and end together.
4326 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4326 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4327 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4327 EXPECT_EQ("Header 2.", selectionAsString(frame));
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4709 4709
4710 FrameTestHelpers::WebViewHelper webViewHelper(this); 4710 FrameTestHelpers::WebViewHelper webViewHelper(this);
4711 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr ); 4711 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr );
4712 webViewHelper.webView()->settings()->setDefaultFontSize(12); 4712 webViewHelper.webView()->settings()->setDefaultFontSize(12);
4713 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); 4713 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1);
4714 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 4714 webViewHelper.resize(WebSize(viewWidth, viewHeight));
4715 webViewHelper.webView()->setFocus(true); 4715 webViewHelper.webView()->setFocus(true);
4716 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html"); 4716 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html");
4717 4717
4718 // The frame starts with no selection. 4718 // The frame starts with no selection.
4719 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4719 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4720 ASSERT_TRUE(frame->hasSelection()); 4720 ASSERT_TRUE(frame->hasSelection());
4721 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4721 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4722 4722
4723 // The selection cleared notification should be triggered upon layout. 4723 // The selection cleared notification should be triggered upon layout.
4724 frame->executeCommand(WebString::fromUTF8("Unselect")); 4724 frame->executeCommand(WebString::fromUTF8("Unselect"));
4725 ASSERT_FALSE(frame->hasSelection()); 4725 ASSERT_FALSE(frame->hasSelection());
4726 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4726 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4727 webViewHelper.webView()->updateAllLifecyclePhases(); 4727 webViewHelper.webView()->updateAllLifecyclePhases();
4728 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4728 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4729 4729
(...skipping 10 matching lines...) Expand all
4740 WebRect startWebRect; 4740 WebRect startWebRect;
4741 WebRect endWebRect; 4741 WebRect endWebRect;
4742 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect); 4742 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect);
4743 WebPoint movedEnd(bottomRightMinusOne(endWebRect)); 4743 WebPoint movedEnd(bottomRightMinusOne(endWebRect));
4744 endWebRect.x -= 20; 4744 endWebRect.x -= 20;
4745 frame->selectRange(topLeft(startWebRect), movedEnd); 4745 frame->selectRange(topLeft(startWebRect), movedEnd);
4746 webViewHelper.webView()->updateAllLifecyclePhases(); 4746 webViewHelper.webView()->updateAllLifecyclePhases();
4747 ASSERT_TRUE(frame->hasSelection()); 4747 ASSERT_TRUE(frame->hasSelection());
4748 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4748 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4749 4749
4750 frame = webViewHelper.webView()->mainFrame(); 4750 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4751 frame->executeCommand(WebString::fromUTF8("Unselect")); 4751 frame->executeCommand(WebString::fromUTF8("Unselect"));
4752 webViewHelper.webView()->updateAllLifecyclePhases(); 4752 webViewHelper.webView()->updateAllLifecyclePhases();
4753 ASSERT_FALSE(frame->hasSelection()); 4753 ASSERT_FALSE(frame->hasSelection());
4754 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4754 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4755 } 4755 }
4756 4756
4757 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient { 4757 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient {
4758 public: 4758 public:
4759 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override 4759 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override
4760 { 4760 {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this. 5138 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this.
5139 } 5139 }
5140 5140
5141 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction) 5141 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction)
5142 { 5142 {
5143 FrameTestHelpers::WebViewHelper webViewHelper(this); 5143 FrameTestHelpers::WebViewHelper webViewHelper(this);
5144 webViewHelper.initializeAndLoad("about:blank", true); 5144 webViewHelper.initializeAndLoad("about:blank", true);
5145 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5145 WebFrame* frame = webViewHelper.webView()->mainFrame();
5146 5146
5147 // This test passes if this doesn't crash. 5147 // This test passes if this doesn't crash.
5148 frame->moveCaretSelection(WebPoint(0, 0)); 5148 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0));
5149 } 5149 }
5150 5150
5151 class SpellCheckClient : public WebSpellCheckClient { 5151 class SpellCheckClient : public WebSpellCheckClient {
5152 public: 5152 public:
5153 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { } 5153 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { }
5154 virtual ~SpellCheckClient() { } 5154 virtual ~SpellCheckClient() { }
5155 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override 5155 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override
5156 { 5156 {
5157 ++m_numberOfTimesChecked; 5157 ++m_numberOfTimesChecked;
5158 Vector<WebTextCheckingResult> results; 5158 Vector<WebTextCheckingResult> results;
(...skipping 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after
8794 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); 8794 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result());
8795 8795
8796 client.reset(); 8796 client.reset();
8797 localFrame->saveImageAt(WebPoint(125, 25)); 8797 localFrame->saveImageAt(WebPoint(125, 25));
8798 EXPECT_EQ(WebString(), client.result()); 8798 EXPECT_EQ(WebString(), client.result());
8799 8799
8800 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient. 8800 helper.reset(); // Explicitly reset to break dependency on locally scoped cl ient.
8801 } 8801 }
8802 8802
8803 } // namespace blink 8803 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698