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

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

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip 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
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 "web/TextFinder.h" 5 #include "web/TextFinder.h"
6 6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/NodeList.h" 9 #include "core/dom/NodeList.h"
10 #include "core/dom/Range.h" 10 #include "core/dom/Range.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 Node* textInBElement = document().body()->firstChild()->firstChild(); 191 Node* textInBElement = document().body()->firstChild()->firstChild();
192 Node* textInIElement = document().body()->lastChild()->firstChild(); 192 Node* textInIElement = document().body()->lastChild()->firstChild();
193 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild(); 193 Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild();
194 194
195 int identifier = 0; 195 int identifier = 0;
196 WebString searchText(String("foo")); 196 WebString searchText(String("foo"));
197 WebFindOptions findOptions; // Default. 197 WebFindOptions findOptions; // Default.
198 bool wrapWithinFrame = true; 198 bool wrapWithinFrame = true;
199 WebRect* selectionRect = nullptr; 199 WebRect* selectionRect = nullptr;
200 200
201 // TextIterator currently returns the matches in the composed treeorder, so 201 // TextIterator currently returns the matches in the flat treeorder, so
202 // in this case the matches will be returned in the order of 202 // in this case the matches will be returned in the order of
203 // <i> -> <u> -> <b>. 203 // <i> -> <u> -> <b>.
204 ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithi nFrame, selectionRect)); 204 ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithi nFrame, selectionRect));
205 Range* activeMatch = textFinder().activeMatch(); 205 Range* activeMatch = textFinder().activeMatch();
206 ASSERT_TRUE(activeMatch); 206 ASSERT_TRUE(activeMatch);
207 EXPECT_EQ(textInIElement, activeMatch->startContainer()); 207 EXPECT_EQ(textInIElement, activeMatch->startContainer());
208 EXPECT_EQ(0, activeMatch->startOffset()); 208 EXPECT_EQ(0, activeMatch->startOffset());
209 EXPECT_EQ(textInIElement, activeMatch->endContainer()); 209 EXPECT_EQ(textInIElement, activeMatch->endContainer());
210 EXPECT_EQ(3, activeMatch->endOffset()); 210 EXPECT_EQ(3, activeMatch->endOffset());
211 211
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 int identifier = 0; 309 int identifier = 0;
310 WebString searchText(String("fOO")); 310 WebString searchText(String("fOO"));
311 WebFindOptions findOptions; // Default. 311 WebFindOptions findOptions; // Default.
312 312
313 textFinder().resetMatchCount(); 313 textFinder().resetMatchCount();
314 textFinder().scopeStringMatches(identifier, searchText, findOptions, true); 314 textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
315 while (textFinder().scopingInProgress()) 315 while (textFinder().scopingInProgress())
316 runPendingTasks(); 316 runPendingTasks();
317 317
318 // TextIterator currently returns the matches in the composed tree order, 318 // TextIterator currently returns the matches in the flat tree order,
319 // so in this case the matches will be returned in the order of 319 // so in this case the matches will be returned in the order of
320 // <i> -> <u> -> <b>. 320 // <i> -> <u> -> <b>.
321 EXPECT_EQ(3, textFinder().totalMatchCount()); 321 EXPECT_EQ(3, textFinder().totalMatchCount());
322 WebVector<WebFloatRect> matchRects; 322 WebVector<WebFloatRect> matchRects;
323 textFinder().findMatchRects(matchRects); 323 textFinder().findMatchRects(matchRects);
324 ASSERT_EQ(3u, matchRects.size()); 324 ASSERT_EQ(3u, matchRects.size());
325 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[0 ]); 325 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[0 ]);
326 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[1 ]); 326 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[1 ]);
327 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[2 ]); 327 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[2 ]);
328 } 328 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // There will be only one iteration before timeout, because increment 455 // There will be only one iteration before timeout, because increment
456 // of the TimeProxyPlatform timer is greater than timeout threshold. 456 // of the TimeProxyPlatform timer is greater than timeout threshold.
457 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); 457 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true );
458 while (textFinder().scopingInProgress()) 458 while (textFinder().scopingInProgress())
459 runPendingTasks(); 459 runPendingTasks();
460 460
461 EXPECT_EQ(4, textFinder().totalMatchCount()); 461 EXPECT_EQ(4, textFinder().totalMatchCount());
462 } 462 }
463 463
464 } // namespace blink 464 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698