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

Side by Side Diff: Source/web/tests/TextFinderTest.cpp

Issue 288443006: Oilpan: Prepare moving ShadowRoot to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/TextIteratorTest.cpp ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "web/TextFinder.h" 7 #include "web/TextFinder.h"
8 8
9 #include "bindings/v8/ExceptionStatePlaceholder.h" 9 #include "bindings/v8/ExceptionStatePlaceholder.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 bool wrapWithinFrame = true; 142 bool wrapWithinFrame = true;
143 WebRect* selectionRect = 0; 143 WebRect* selectionRect = 0;
144 144
145 EXPECT_FALSE(textFinder().find(identifier, searchText, findOptions, wrapWith inFrame, selectionRect)); 145 EXPECT_FALSE(textFinder().find(identifier, searchText, findOptions, wrapWith inFrame, selectionRect));
146 EXPECT_FALSE(textFinder().activeMatch()); 146 EXPECT_FALSE(textFinder().activeMatch());
147 } 147 }
148 148
149 TEST_F(TextFinderTest, FindTextInShadowDOM) 149 TEST_F(TextFinderTest, FindTextInShadowDOM)
150 { 150 {
151 document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION) ; 151 document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION) ;
152 RefPtr<ShadowRoot> shadowRoot = document().body()->createShadowRoot(ASSERT_N O_EXCEPTION); 152 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = document().body()->createShadowR oot(ASSERT_NO_EXCEPTION);
153 shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content ></content>", ASSERT_NO_EXCEPTION); 153 shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content ></content>", ASSERT_NO_EXCEPTION);
154 Node* textInBElement = document().body()->firstChild()->firstChild(); 154 Node* textInBElement = document().body()->firstChild()->firstChild();
155 Node* textInIElement = document().body()->lastChild()->firstChild(); 155 Node* textInIElement = document().body()->lastChild()->firstChild();
156 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild(); 156 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild();
157 157
158 int identifier = 0; 158 int identifier = 0;
159 WebString searchText(String("foo")); 159 WebString searchText(String("foo"));
160 WebFindOptions findOptions; // Default. 160 WebFindOptions findOptions; // Default.
161 bool wrapWithinFrame = true; 161 bool wrapWithinFrame = true;
162 WebRect* selectionRect = 0; 162 WebRect* selectionRect = 0;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 WebVector<WebFloatRect> matchRects; 255 WebVector<WebFloatRect> matchRects;
256 textFinder().findMatchRects(matchRects); 256 textFinder().findMatchRects(matchRects);
257 ASSERT_EQ(2u, matchRects.size()); 257 ASSERT_EQ(2u, matchRects.size());
258 EXPECT_EQ(findInPageRect(textNode, 4, textNode, 10), matchRects[0]); 258 EXPECT_EQ(findInPageRect(textNode, 4, textNode, 10), matchRects[0]);
259 EXPECT_EQ(findInPageRect(textNode, 14, textNode, 20), matchRects[1]); 259 EXPECT_EQ(findInPageRect(textNode, 14, textNode, 20), matchRects[1]);
260 } 260 }
261 261
262 TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM) 262 TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM)
263 { 263 {
264 document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION) ; 264 document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION) ;
265 RefPtr<ShadowRoot> shadowRoot = document().body()->createShadowRoot(ASSERT_N O_EXCEPTION); 265 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = document().body()->createShadowR oot(ASSERT_NO_EXCEPTION);
266 shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content ></content>", ASSERT_NO_EXCEPTION); 266 shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content ></content>", ASSERT_NO_EXCEPTION);
267 Node* textInBElement = document().body()->firstChild()->firstChild(); 267 Node* textInBElement = document().body()->firstChild()->firstChild();
268 Node* textInIElement = document().body()->lastChild()->firstChild(); 268 Node* textInIElement = document().body()->lastChild()->firstChild();
269 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild(); 269 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild();
270 270
271 int identifier = 0; 271 int identifier = 0;
272 WebString searchText(String("fOO")); 272 WebString searchText(String("fOO"));
273 WebFindOptions findOptions; // Default. 273 WebFindOptions findOptions; // Default.
274 274
275 textFinder().resetMatchCount(); 275 textFinder().resetMatchCount();
276 textFinder().scopeStringMatches(identifier, searchText, findOptions, true); 276 textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
277 while (textFinder().scopingInProgress()) 277 while (textFinder().scopingInProgress())
278 FrameTestHelpers::runPendingTasks(); 278 FrameTestHelpers::runPendingTasks();
279 279
280 // TextIterator currently returns the matches in the document order, instead of the visual order. It visits 280 // TextIterator currently returns the matches in the document order, instead of the visual order. It visits
281 // the shadow roots first, so in this case the matches will be returned in t he order of <u> -> <b> -> <i>. 281 // the shadow roots first, so in this case the matches will be returned in t he order of <u> -> <b> -> <i>.
282 EXPECT_EQ(3, textFinder().totalMatchCount()); 282 EXPECT_EQ(3, textFinder().totalMatchCount());
283 WebVector<WebFloatRect> matchRects; 283 WebVector<WebFloatRect> matchRects;
284 textFinder().findMatchRects(matchRects); 284 textFinder().findMatchRects(matchRects);
285 ASSERT_EQ(3u, matchRects.size()); 285 ASSERT_EQ(3u, matchRects.size());
286 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[0 ]); 286 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[0 ]);
287 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[1 ]); 287 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[1 ]);
288 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2 ]); 288 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2 ]);
289 } 289 }
290 290
291 } // namespace 291 } // namespace
OLDNEW
« no previous file with comments | « Source/core/editing/TextIteratorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698