• Gabriel Charette's avatar
    [ScopedTaskEnvironment] Always mock TimeTicks::Now() under MOCK_TIME mode · ef6cbc2d
    Gabriel Charette authored
    This (PS1) passes all existing tests as-is but
    ParkableStringTest.ReportTotalUnparkingTime.
    
    This failure happens because samples of Now() within the same task
    no longer have any delta under MOCK_TIME regardless of how CPU expensive
    the operation actually is.
    
    That test was using a state of the art approach, base::ElapsedTimer,
    MOCK_TIME, base::HistogramTester, etc.
    
    But base::ElaspedTimer is neutered by the change to MOCK_TIME in this CL.
    
    There are two potential solutions:
      1) Have ElapsedTimer play a role in auto-advancing mock-time.
      2) Mock timings returned by ElpasedTimer.
    
    (1) is undesirable because it would make it possible for delayed tasks
    to run as part of a basic RunUntilIdle() which takes control of delayed
    tasks away from the ScopedTaskEnvironment owner and is highly undesired.
    
    (2) is more explicit but also easier to control. This CL does that by
    adding base::ScopedMockElapsedTimersForTest.
    
    This actually makes ParkableStringTest.ReportTotalUnparkingTime cleaner
    because it can now test for a specific timing instead of just
    "has a non-zero timing".
    
    Bug: 905412
    Change-Id: I91fab300b4005fd7802ce837733665e77766d4b2
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1707870
    Auto-Submit: Gabriel Charette <gab@chromium.org>
    Commit-Queue: Kentaro Hara <haraken@chromium.org>
    Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
    Reviewed-by: default avatarkylechar <kylechar@chromium.org>
    Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#683487}
    ef6cbc2d
platform_thread_win.cc 14.3 KB