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

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

Issue 1411843008: Make blink platform time consistent with the timer virtual time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CachingCorrectnessTest Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/web/WebKit.cpp ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 TimeProxyPlatform() 407 TimeProxyPlatform()
408 : m_timeCounter(0.) 408 : m_timeCounter(0.)
409 , m_fallbackPlatform(0) 409 , m_fallbackPlatform(0)
410 { } 410 { }
411 411
412 void install() 412 void install()
413 { 413 {
414 // Check that the proxy wasn't installed yet. 414 // Check that the proxy wasn't installed yet.
415 ASSERT_NE(Platform::current(), this); 415 ASSERT_NE(Platform::current(), this);
416 m_fallbackPlatform = Platform::current(); 416 m_fallbackPlatform = Platform::current();
417 m_timeCounter = m_fallbackPlatform->currentTime(); 417 m_timeCounter = m_fallbackPlatform->currentTimeSeconds();
418 Platform::initialize(this); 418 Platform::initialize(this);
419 ASSERT_EQ(Platform::current(), this); 419 ASSERT_EQ(Platform::current(), this);
420 } 420 }
421 421
422 void remove() 422 void remove()
423 { 423 {
424 // Check that the proxy was installed. 424 // Check that the proxy was installed.
425 ASSERT_EQ(Platform::current(), this); 425 ASSERT_EQ(Platform::current(), this);
426 Platform::initialize(m_fallbackPlatform); 426 Platform::initialize(m_fallbackPlatform);
427 ASSERT_EQ(Platform::current(), m_fallbackPlatform); 427 ASSERT_EQ(Platform::current(), m_fallbackPlatform);
428 m_fallbackPlatform = 0; 428 m_fallbackPlatform = 0;
429 } 429 }
430 430
431 private: 431 private:
432 Platform& ensureFallback() 432 Platform& ensureFallback()
433 { 433 {
434 ASSERT(m_fallbackPlatform); 434 ASSERT(m_fallbackPlatform);
435 return *m_fallbackPlatform; 435 return *m_fallbackPlatform;
436 } 436 }
437 437
438 // From blink::Platform: 438 // From blink::Platform:
439 double currentTime() override 439 double currentTimeSeconds() override
440 { 440 {
441 return ++m_timeCounter; 441 return ++m_timeCounter;
442 } 442 }
443 443
444 // These blink::Platform methods must be overriden to make a usable obje ct. 444 // These blink::Platform methods must be overriden to make a usable obje ct.
445 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override 445 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override
446 { 446 {
447 ensureFallback().cryptographicallyRandomValues(buffer, length); 447 ensureFallback().cryptographicallyRandomValues(buffer, length);
448 } 448 }
449 449
450 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryNam e) override 450 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryNam e) override
451 { 451 {
452 return ensureFallback().getTraceCategoryEnabledFlag(categoryName); 452 return ensureFallback().getTraceCategoryEnabledFlag(categoryName);
453 } 453 }
454 454
455 // These two methods allow timers to work correctly. 455 // These two methods allow timers to work correctly.
456 double monotonicallyIncreasingTime() override 456 double monotonicallyIncreasingTimeSeconds() override
457 { 457 {
458 return ensureFallback().monotonicallyIncreasingTime(); 458 return ensureFallback().monotonicallyIncreasingTimeSeconds();
459 } 459 }
460 460
461 WebThread* currentThread() override { return ensureFallback().currentThr ead(); } 461 WebThread* currentThread() override { return ensureFallback().currentThr ead(); }
462 WebUnitTestSupport* unitTestSupport() override { return ensureFallback() .unitTestSupport(); } 462 WebUnitTestSupport* unitTestSupport() override { return ensureFallback() .unitTestSupport(); }
463 WebString defaultLocale() override { return ensureFallback().defaultLoca le(); } 463 WebString defaultLocale() override { return ensureFallback().defaultLoca le(); }
464 WebCompositorSupport* compositorSupport() override { return ensureFallba ck().compositorSupport(); } 464 WebCompositorSupport* compositorSupport() override { return ensureFallba ck().compositorSupport(); }
465 465
466 double m_timeCounter; 466 double m_timeCounter;
467 Platform* m_fallbackPlatform; 467 Platform* m_fallbackPlatform;
468 }; 468 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // There will be only one iteration before timeout, because increment 504 // There will be only one iteration before timeout, because increment
505 // of the TimeProxyPlatform timer is greater than timeout threshold. 505 // of the TimeProxyPlatform timer is greater than timeout threshold.
506 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true ); 506 textFinder().scopeStringMatches(identifier, searchPattern, findOptions, true );
507 while (textFinder().scopingInProgress()) 507 while (textFinder().scopingInProgress())
508 runPendingTasks(); 508 runPendingTasks();
509 509
510 EXPECT_EQ(4, textFinder().totalMatchCount()); 510 EXPECT_EQ(4, textFinder().totalMatchCount());
511 } 511 }
512 512
513 } // namespace blink 513 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebKit.cpp ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698