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

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

Issue 1936853002: Assert event timestamp to be monotonic and not from future Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to histogram Created 4 years, 2 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 Node* textInIElement = document().body()->lastChild()->firstChild(); 457 Node* textInIElement = document().body()->lastChild()->firstChild();
458 EXPECT_EQ(findInPageRect(textInBElement, 4, textInBElement, 10), matchRects[ 0]); 458 EXPECT_EQ(findInPageRect(textInBElement, 4, textInBElement, 10), matchRects[ 0]);
459 EXPECT_EQ(findInPageRect(textInIElement, 2, textInIElement, 8), matchRects[1 ]); 459 EXPECT_EQ(findInPageRect(textInIElement, 2, textInIElement, 8), matchRects[1 ]);
460 } 460 }
461 461
462 class TextFinderFakeTimerTest : public TextFinderTest { 462 class TextFinderFakeTimerTest : public TextFinderTest {
463 protected: 463 protected:
464 void SetUp() override 464 void SetUp() override
465 { 465 {
466 s_timeElapsed = 0.0; 466 s_timeElapsed = 0.0;
467 m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime); 467 m_originalMonotonicTimeFunction = setMonotonicallyIncreasingTimeFunction ForTesting(returnMockTime);
468 m_originalCurrentTimeFunction = setCurrentTimeFunctionForTesting(returnM ockTime);
468 } 469 }
469 470
470 void TearDown() override 471 void TearDown() override
471 { 472 {
472 setTimeFunctionsForTesting(m_originalTimeFunction); 473 setMonotonicallyIncreasingTimeFunctionForTesting(m_originalMonotonicTime Function);
474 setCurrentTimeFunctionForTesting(m_originalCurrentTimeFunction);
473 } 475 }
474 476
475 private: 477 private:
476 static double returnMockTime() 478 static double returnMockTime()
477 { 479 {
478 s_timeElapsed += 1.0; 480 s_timeElapsed += 1.0;
479 return s_timeElapsed; 481 return s_timeElapsed;
480 } 482 }
481 483
482 TimeFunction m_originalTimeFunction; 484 TimeFunction m_originalMonotonicTimeFunction;
485 TimeFunction m_originalCurrentTimeFunction;
483 static double s_timeElapsed; 486 static double s_timeElapsed;
484 }; 487 };
485 488
486 double TextFinderFakeTimerTest::s_timeElapsed; 489 double TextFinderFakeTimerTest::s_timeElapsed;
487 490
488 TEST_F(TextFinderFakeTimerTest, ScopeWithTimeouts) 491 TEST_F(TextFinderFakeTimerTest, ScopeWithTimeouts)
489 { 492 {
490 // Make a long string. 493 // Make a long string.
491 String text(Vector<UChar>(100)); 494 String text(Vector<UChar>(100));
492 text.fill('a'); 495 text.fill('a');
(...skipping 15 matching lines...) Expand all
508 // There will be only one iteration before timeout, because increment 511 // There will be only one iteration before timeout, because increment
509 // of the TimeProxyPlatform timer is greater than timeout threshold. 512 // of the TimeProxyPlatform timer is greater than timeout threshold.
510 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); 513 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true );
511 while (textFinder().scopingInProgress()) 514 while (textFinder().scopingInProgress())
512 runPendingTasks(); 515 runPendingTasks();
513 516
514 EXPECT_EQ(4, textFinder().totalMatchCount()); 517 EXPECT_EQ(4, textFinder().totalMatchCount());
515 } 518 }
516 519
517 } // namespace blink 520 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebTestingSupport.cpp ('k') | third_party/WebKit/Source/wtf/CurrentTime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698