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 "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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 WebUnitTestSupport* unitTestSupport() override { return ensureFallback() .unitTestSupport(); } | 426 WebUnitTestSupport* unitTestSupport() override { return ensureFallback() .unitTestSupport(); } |
427 WebString defaultLocale() override { return ensureFallback().defaultLoca le(); } | 427 WebString defaultLocale() override { return ensureFallback().defaultLoca le(); } |
428 WebCompositorSupport* compositorSupport() override { return ensureFallba ck().compositorSupport(); } | 428 WebCompositorSupport* compositorSupport() override { return ensureFallba ck().compositorSupport(); } |
429 | 429 |
430 double m_timeCounter; | 430 double m_timeCounter; |
431 }; | 431 }; |
432 | 432 |
433 TimeProxyPlatform m_proxyTimePlatform; | 433 TimeProxyPlatform m_proxyTimePlatform; |
434 }; | 434 }; |
435 | 435 |
436 TEST_F(TextFinderTest, WhitespaceMatches) | |
yosin_UTC9
2016/01/20 05:33:11
Can we put test in |TextIteratorTest| rather than
ramya.v
2016/01/20 05:59:10
Done.
| |
437 { | |
438 document().body()->setInnerHTML("<span>Some text </span> <input type='button ' value='Button text'/><span>Some more text</span>", ASSERT_NO_EXCEPTION); | |
439 | |
440 int identifier = 0; | |
441 WebString searchText(String(" ")); | |
442 WebFindOptions findOptions; // Default. | |
443 | |
444 textFinder().resetMatchCount(); | |
445 textFinder().scopeStringMatches(identifier, searchText, findOptions, true); | |
446 while (textFinder().scopingInProgress()) | |
447 runPendingTasks(); | |
448 | |
449 EXPECT_EQ(5, textFinder().totalMatchCount()); | |
450 } | |
451 | |
436 TEST_F(TextFinderFakeTimerTest, ScopeWithTimeouts) | 452 TEST_F(TextFinderFakeTimerTest, ScopeWithTimeouts) |
437 { | 453 { |
438 // Make a long string. | 454 // Make a long string. |
439 String text(Vector<UChar>(100)); | 455 String text(Vector<UChar>(100)); |
440 text.fill('a'); | 456 text.fill('a'); |
441 String searchPattern("abc"); | 457 String searchPattern("abc"); |
442 // Make 4 substrings "abc" in text. | 458 // Make 4 substrings "abc" in text. |
443 text.insert(searchPattern, 1); | 459 text.insert(searchPattern, 1); |
444 text.insert(searchPattern, 10); | 460 text.insert(searchPattern, 10); |
445 text.insert(searchPattern, 50); | 461 text.insert(searchPattern, 50); |
446 text.insert(searchPattern, 90); | 462 text.insert(searchPattern, 90); |
447 | 463 |
448 document().body()->setInnerHTML(text, ASSERT_NO_EXCEPTION); | 464 document().body()->setInnerHTML(text, ASSERT_NO_EXCEPTION); |
449 | 465 |
450 int identifier = 0; | 466 int identifier = 0; |
451 WebFindOptions findOptions; // Default. | 467 WebFindOptions findOptions; // Default. |
452 | 468 |
453 textFinder().resetMatchCount(); | 469 textFinder().resetMatchCount(); |
454 | 470 |
455 // There will be only one iteration before timeout, because increment | 471 // There will be only one iteration before timeout, because increment |
456 // of the TimeProxyPlatform timer is greater than timeout threshold. | 472 // of the TimeProxyPlatform timer is greater than timeout threshold. |
457 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); | 473 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); |
458 while (textFinder().scopingInProgress()) | 474 while (textFinder().scopingInProgress()) |
459 runPendingTasks(); | 475 runPendingTasks(); |
460 | 476 |
461 EXPECT_EQ(4, textFinder().totalMatchCount()); | 477 EXPECT_EQ(4, textFinder().totalMatchCount()); |
462 } | 478 } |
463 | 479 |
464 } // namespace blink | 480 } // namespace blink |
OLD | NEW |