OLD | NEW |
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/core/v8/ExceptionStatePlaceholder.h" | 9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // the shadow roots first, so in this case the matches will be returned in t
he order of <u> -> <b> -> <i>. | 282 // the shadow roots first, so in this case the matches will be returned in t
he order of <u> -> <b> -> <i>. |
283 EXPECT_EQ(3, textFinder().totalMatchCount()); | 283 EXPECT_EQ(3, textFinder().totalMatchCount()); |
284 WebVector<WebFloatRect> matchRects; | 284 WebVector<WebFloatRect> matchRects; |
285 textFinder().findMatchRects(matchRects); | 285 textFinder().findMatchRects(matchRects); |
286 ASSERT_EQ(3u, matchRects.size()); | 286 ASSERT_EQ(3u, matchRects.size()); |
287 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[0
]); | 287 EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[0
]); |
288 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[1
]); | 288 EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[1
]); |
289 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2
]); | 289 EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2
]); |
290 } | 290 } |
291 | 291 |
292 TEST_F(TextFinderTest, ScopeRepeatPatternTextMatches) | |
293 { | |
294 document().body()->setInnerHTML("ab ab ab ab ab", ASSERT_NO_EXCEPTION); | |
295 Node* textNode = document().body()->firstChild(); | |
296 | |
297 int identifier = 0; | |
298 WebString searchText(String("ab ab")); | |
299 WebFindOptions findOptions; // Default. | |
300 | |
301 textFinder().resetMatchCount(); | |
302 textFinder().scopeStringMatches(identifier, searchText, findOptions, true); | |
303 while (textFinder().scopingInProgress()) | |
304 FrameTestHelpers::runPendingTasks(); | |
305 | |
306 EXPECT_EQ(2, textFinder().totalMatchCount()); | |
307 WebVector<WebFloatRect> matchRects; | |
308 textFinder().findMatchRects(matchRects); | |
309 ASSERT_EQ(2u, matchRects.size()); | |
310 EXPECT_EQ(findInPageRect(textNode, 0, textNode, 5), matchRects[0]); | |
311 EXPECT_EQ(findInPageRect(textNode, 6, textNode, 11), matchRects[1]); | |
312 } | |
313 | |
314 } // namespace | 292 } // namespace |
OLD | NEW |