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

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

Issue 1483013003: Find In Page doesn't work properly when " " is searched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding testcase Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "web/TextFinder.h" 6 #include "web/TextFinder.h"
7 7
8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/NodeList.h" 10 #include "core/dom/NodeList.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 388
389 EXPECT_EQ(3, textFinder().totalMatchCount()); 389 EXPECT_EQ(3, textFinder().totalMatchCount());
390 WebVector<WebFloatRect> matchRects; 390 WebVector<WebFloatRect> matchRects;
391 textFinder().findMatchRects(matchRects); 391 textFinder().findMatchRects(matchRects);
392 ASSERT_EQ(3u, matchRects.size()); 392 ASSERT_EQ(3u, matchRects.size());
393 EXPECT_EQ(findInPageRect(textNode, 0, textNode, 2), matchRects[0]); 393 EXPECT_EQ(findInPageRect(textNode, 0, textNode, 2), matchRects[0]);
394 EXPECT_EQ(findInPageRect(textNode, 2, textNode, 4), matchRects[1]); 394 EXPECT_EQ(findInPageRect(textNode, 2, textNode, 4), matchRects[1]);
395 EXPECT_EQ(findInPageRect(textNode, 4, textNode, 6), matchRects[2]); 395 EXPECT_EQ(findInPageRect(textNode, 4, textNode, 6), matchRects[2]);
396 } 396 }
397 397
398 TEST_F(TextFinderTest, WhitespaceMatches)
399 {
400 document().body()->setInnerHTML("<span>Some text </span> <input type='button ' value='Button text'/><span>Some more text</span>", ASSERT_NO_EXCEPTION);
401
402 int identifier = 0;
403 WebString searchText(String(" "));
404 WebFindOptions findOptions; // Default.
405
406 textFinder().resetMatchCount();
407 textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
408 while (textFinder().scopingInProgress())
409 runPendingTasks();
410
411 EXPECT_EQ(5, textFinder().totalMatchCount());
412 }
413
398 class TextFinderFakeTimerTest : public TextFinderTest { 414 class TextFinderFakeTimerTest : public TextFinderTest {
399 protected: 415 protected:
400 // A simple platform that mocks out the clock. 416 // A simple platform that mocks out the clock.
401 class TimeProxyPlatform : public TestingPlatformSupport { 417 class TimeProxyPlatform : public TestingPlatformSupport {
402 public: 418 public:
403 TimeProxyPlatform() 419 TimeProxyPlatform()
404 : m_timeCounter(m_oldPlatform->currentTimeSeconds()) 420 : m_timeCounter(m_oldPlatform->currentTimeSeconds())
405 { 421 {
406 } 422 }
407 423
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // There will be only one iteration before timeout, because increment 472 // There will be only one iteration before timeout, because increment
457 // of the TimeProxyPlatform timer is greater than timeout threshold. 473 // of the TimeProxyPlatform timer is greater than timeout threshold.
458 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); 474 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true );
459 while (textFinder().scopingInProgress()) 475 while (textFinder().scopingInProgress())
460 runPendingTasks(); 476 runPendingTasks();
461 477
462 EXPECT_EQ(4, textFinder().totalMatchCount()); 478 EXPECT_EQ(4, textFinder().totalMatchCount());
463 } 479 }
464 480
465 } // namespace blink 481 } // namespace blink
OLDNEW
« third_party/WebKit/Source/web/TextFinder.cpp ('K') | « third_party/WebKit/Source/web/TextFinder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698