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

Issue 899863002: Add support in TestMockTimeTaskRunner for vending out mock Time and mock Clocks. (Closed)

Created:
5 years, 10 months ago by engedy
Modified:
5 years, 10 months ago
CC:
chromium-reviews, sadrul, nkostylev+watch_chromium.org, oshima+watch_chromium.org, kalyank, gcasto+watchlist_chromium.org, erikwright+watch_chromium.org, stevenjb+watch_chromium.org, davemoore+watch_chromium.org, mkwst+watchlist-passwords_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add support in TestMockTimeTaskRunner for vending mock Time values and mock Clocks. Previously, TestMockTimeTaskRunner had only supported vending out TimeTicks and TickClocks. Now it supports mock Time and mock Clocks too (they start at the Unix epoch). This CL also shortens the names of the methods that vend the current time and time ticks to Now() and NowTicks(), respectively; removes using the "base" namespace prefix inside the "base" namespace; and provides a clean implementation for FastForwardUntilNoTasksRemain() instead of a hacky solution. BUG=329911 TBR=phajdan.jr@chromium.org # OOO. Committed: https://crrev.com/5cae03fa3f7f836be37d6dfb37cc8b3d7dcb3c3c Cr-Commit-Position: refs/heads/master@{#316219}

Patch Set 1 : #

Patch Set 2 : Nits, remove base:: mentions. #

Patch Set 3 : Fix ash_unittests missing header. #

Total comments: 10

Patch Set 4 : Fixed hackery, and nits. #

Total comments: 4

Patch Set 5 : Addressed comments from thestig@. #

Patch Set 6 : Phrasing nit. #

Total comments: 4

Patch Set 7 : Fix bug and phrasing. #

Patch Set 8 : Fix DCHECK_GT --> DCHECK_GE. #

Total comments: 42

Patch Set 9 : Addressed comments from bartfab@. #

Patch Set 10 : Start ticks from 1 us. #

Total comments: 2

Patch Set 11 : Fix typo and TimeTicks initialization. #

Patch Set 12 : Start ticks from 0, some tests depend on this. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+178 lines, -125 lines) Patch
M ash/system/chromeos/session/logout_confirmation_controller_unittest.cc View 1 2 9 chunks +22 lines, -21 lines 0 comments Download
M base/test/test_mock_time_task_runner.h View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +47 lines, -19 lines 2 comments Download
M base/test/test_mock_time_task_runner.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +88 lines, -37 lines 2 comments Download
M chrome/browser/chromeos/session_length_limiter_unittest.cc View 10 chunks +15 lines, -23 lines 0 comments Download
M chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M components/password_manager/core/browser/affiliation_fetch_throttler_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc View 2 chunks +2 lines, -21 lines 0 comments Download

Messages

Total messages: 36 (11 generated)
engedy
@Bartosz, could you please review the whole thing, and also components/policy for OWNER's approval? Everyone ...
5 years, 10 months ago (2015-02-04 14:08:01 UTC) #6
engedy
@Bartosz: This CL results in a change of |test_start_time_| in remote_commands_queue_unittest.cc. It used to be ...
5 years, 10 months ago (2015-02-04 14:13:37 UTC) #7
vabr (Chromium)
components/password_manager LGTM
5 years, 10 months ago (2015-02-04 15:31:52 UTC) #8
Lei Zhang
https://codereview.chromium.org/899863002/diff/80001/base/test/test_mock_time_task_runner.cc File base/test/test_mock_time_task_runner.cc (left): https://codereview.chromium.org/899863002/diff/80001/base/test/test_mock_time_task_runner.cc#oldcode77 base/test/test_mock_time_task_runner.cc:77: now_ = original_now + delta; Just trying to understand ...
5 years, 10 months ago (2015-02-04 20:27:37 UTC) #9
engedy
https://codereview.chromium.org/899863002/diff/80001/base/test/test_mock_time_task_runner.cc File base/test/test_mock_time_task_runner.cc (left): https://codereview.chromium.org/899863002/diff/80001/base/test/test_mock_time_task_runner.cc#oldcode77 base/test/test_mock_time_task_runner.cc:77: now_ = original_now + delta; On 2015/02/04 20:27:37, Lei ...
5 years, 10 months ago (2015-02-05 10:22:57 UTC) #11
Lei Zhang
The desired behavior of TestMockTimeTaskRunner is easy to understand, but the implementation is a little ...
5 years, 10 months ago (2015-02-05 10:52:59 UTC) #12
engedy
@Lei, PTAL. Writing unit tests for this sounds good, but let me do that in ...
5 years, 10 months ago (2015-02-05 12:41:24 UTC) #13
Lei Zhang
https://codereview.chromium.org/899863002/diff/140001/base/test/test_mock_time_task_runner.cc File base/test/test_mock_time_task_runner.cc (right): https://codereview.chromium.org/899863002/diff/140001/base/test/test_mock_time_task_runner.cc#newcode96 base/test/test_mock_time_task_runner.cc:96: TimeTicks original_now_ticks; Do you to initialize this to |now_ticks_| ...
5 years, 10 months ago (2015-02-05 18:25:26 UTC) #14
engedy
https://codereview.chromium.org/899863002/diff/140001/base/test/test_mock_time_task_runner.cc File base/test/test_mock_time_task_runner.cc (right): https://codereview.chromium.org/899863002/diff/140001/base/test/test_mock_time_task_runner.cc#newcode96 base/test/test_mock_time_task_runner.cc:96: TimeTicks original_now_ticks; On 2015/02/05 18:25:26, Lei Zhang wrote: > ...
5 years, 10 months ago (2015-02-05 18:31:54 UTC) #15
Lei Zhang
Thank, lgtm.
5 years, 10 months ago (2015-02-05 18:34:13 UTC) #16
Lei Zhang
On 2015/02/05 18:34:13, Lei Zhang wrote: > Thank, lgtm. Thanks, even!
5 years, 10 months ago (2015-02-05 18:34:25 UTC) #17
engedy
@Bartosz, friendly ping. In case are busy, feel free to just look at components/policy.
5 years, 10 months ago (2015-02-06 10:38:26 UTC) #19
bartfab (slow)
Oops, I forgot to hit send... several days ago :( https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc File ash/system/chromeos/session/logout_confirmation_controller_unittest.cc (right): https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc#newcode12 ...
5 years, 10 months ago (2015-02-12 09:50:55 UTC) #20
engedy
https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc File ash/system/chromeos/session/logout_confirmation_controller_unittest.cc (right): https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc#newcode12 ash/system/chromeos/session/logout_confirmation_controller_unittest.cc:12: #include "base/time/tick_clock.h" On 2015/02/12 09:50:55, bartfab wrote: > Nit: ...
5 years, 10 months ago (2015-02-12 11:27:03 UTC) #21
bartfab (slow)
LGTM with a couple more nits. https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc File ash/system/chromeos/session/logout_confirmation_controller_unittest.cc (right): https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc#newcode12 ash/system/chromeos/session/logout_confirmation_controller_unittest.cc:12: #include "base/time/tick_clock.h" On ...
5 years, 10 months ago (2015-02-12 12:36:08 UTC) #22
stevenjb
owner lgtm https://codereview.chromium.org/899863002/diff/220001/base/test/test_mock_time_task_runner.h File base/test/test_mock_time_task_runner.h (right): https://codereview.chromium.org/899863002/diff/220001/base/test/test_mock_time_task_runner.h#newcode36 base/test/test_mock_time_task_runner.h:36: // - It does not check for ...
5 years, 10 months ago (2015-02-12 18:26:26 UTC) #23
engedy
https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc File ash/system/chromeos/session/logout_confirmation_controller_unittest.cc (right): https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc#newcode12 ash/system/chromeos/session/logout_confirmation_controller_unittest.cc:12: #include "base/time/tick_clock.h" On 2015/02/12 12:36:07, bartfab wrote: > On ...
5 years, 10 months ago (2015-02-13 11:08:05 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/899863002/240001
5 years, 10 months ago (2015-02-13 11:10:33 UTC) #27
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/24744)
5 years, 10 months ago (2015-02-13 12:15:14 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/899863002/260001
5 years, 10 months ago (2015-02-13 13:04:43 UTC) #31
engedy
https://codereview.chromium.org/899863002/diff/180001/base/test/test_mock_time_task_runner.h File base/test/test_mock_time_task_runner.h (right): https://codereview.chromium.org/899863002/diff/180001/base/test/test_mock_time_task_runner.h#newcode49 base/test/test_mock_time_task_runner.h:49: // whose time ticks will still start at zero. ...
5 years, 10 months ago (2015-02-13 13:07:49 UTC) #32
commit-bot: I haz the power
Committed patchset #12 (id:260001)
5 years, 10 months ago (2015-02-13 15:17:54 UTC) #33
commit-bot: I haz the power
Patchset 12 (id:??) landed as https://crrev.com/5cae03fa3f7f836be37d6dfb37cc8b3d7dcb3c3c Cr-Commit-Position: refs/heads/master@{#316219}
5 years, 10 months ago (2015-02-13 15:18:30 UTC) #34
bartfab (slow)
Still LGTM. https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc File ash/system/chromeos/session/logout_confirmation_controller_unittest.cc (right): https://codereview.chromium.org/899863002/diff/180001/ash/system/chromeos/session/logout_confirmation_controller_unittest.cc#newcode12 ash/system/chromeos/session/logout_confirmation_controller_unittest.cc:12: #include "base/time/tick_clock.h" On 2015/02/13 11:08:04, engedy wrote: ...
5 years, 10 months ago (2015-02-16 13:40:35 UTC) #35
engedy
5 years, 10 months ago (2015-02-16 13:49:29 UTC) #36
Message was sent while issue was closed.
https://codereview.chromium.org/899863002/diff/180001/base/test/test_mock_tim...
File base/test/test_mock_time_task_runner.h (right):

https://codereview.chromium.org/899863002/diff/180001/base/test/test_mock_tim...
base/test/test_mock_time_task_runner.h:49: // whose time ticks will still start
at zero.
On 2015/02/16 13:40:34, bartfab wrote:
> On 2015/02/13 13:07:49, engedy wrote:
> > On 2015/02/12 11:27:03, engedy wrote:
> > > On 2015/02/12 09:50:55, bartfab wrote:
> > > > Starting at zero is problematic. Zero is a special magic value that is
> often
> > > > used to mean "not initialized." There is even an TimeTicks::is_null() to
> > test
> > > > for it.
> > > > 
> > > > This design of Time and TimeTicks is bad of course - arithmetic with
real
> > > times
> > > > can always produce a zero, inadvertently making is_null() return true
from
> > now
> > > > on. Changing the fundamental design of Time and TimeTicks would be a
large
> > > > endeavor. The least we can do to work around it is to start with a
> non-zero
> > > > TimeTicks.
> > > 
> > > Done.
> > 
> > I needed to revert this change, some tests depend on that Ticks will start
> from
> > 0. Happy to change this in a follow-up CL if you are strongly against this.
> > (Note, though, that this was not introduced in the current CL.)
> 
> SGTM. The correct solution is to get rid of is_null() and the magical meaning
> assigned to the zero value. This is actually being discussed right now, so I
> have hope that it will be fixed eventually.

Awesome, glad to hear that!

https://codereview.chromium.org/899863002/diff/260001/base/test/test_mock_tim...
File base/test/test_mock_time_task_runner.cc (right):

https://codereview.chromium.org/899863002/diff/260001/base/test/test_mock_tim...
base/test/test_mock_time_task_runner.cc:79: : now_(Time::UnixEpoch()) {
On 2015/02/16 13:40:34, bartfab wrote:
> Nit: Why break this line? It fits on one line.

Done in https://codereview.chromium.org/929923003.

https://codereview.chromium.org/899863002/diff/260001/base/test/test_mock_tim...
File base/test/test_mock_time_task_runner.h (right):

https://codereview.chromium.org/899863002/diff/260001/base/test/test_mock_tim...
base/test/test_mock_time_task_runner.h:36: //   - It does not check for overflow
when doing time arithmetic``. A sufficient
On 2015/02/16 13:40:34, bartfab wrote:
> What are the two grave accents for?

Uhm. Typo. Fixed in https://codereview.chromium.org/929923003.

Powered by Google App Engine
This is Rietveld 408576698