Package com.google.common.testing
Class FakeTicker
java.lang.Object
com.google.common.base.Ticker
com.google.common.testing.FakeTicker
A Ticker whose value can be advanced programmatically in test.
The ticker can be configured so that the time is incremented whenever read()
is called:
see setAutoIncrementStep(long, java.util.concurrent.TimeUnit)
.
This class is thread-safe.
- Since:
- 10.0
- Author:
- Jige Yu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadvance
(long nanoseconds) Advances the ticker value bynanoseconds
.Advances the ticker value bytime
intimeUnit
.Advances the ticker value byduration
.long
read()
setAutoIncrementStep
(long autoIncrementStep, TimeUnit timeUnit) Sets the increment applied to the ticker whenever it is queried.setAutoIncrementStep
(Duration autoIncrementStep) Sets the increment applied to the ticker whenever it is queried.Methods inherited from class com.google.common.base.Ticker
systemTicker
-
Constructor Details
-
FakeTicker
public FakeTicker()
-
-
Method Details
-
advance
Advances the ticker value bytime
intimeUnit
. -
advance
Advances the ticker value bynanoseconds
. -
advance
Advances the ticker value byduration
.- Since:
- 28.0
-
setAutoIncrementStep
@CanIgnoreReturnValue public FakeTicker setAutoIncrementStep(long autoIncrementStep, TimeUnit timeUnit) Sets the increment applied to the ticker whenever it is queried.The default behavior is to auto increment by zero. i.e: The ticker is left unchanged when queried.
-
setAutoIncrementStep
@GwtIncompatible @CanIgnoreReturnValue public FakeTicker setAutoIncrementStep(Duration autoIncrementStep) Sets the increment applied to the ticker whenever it is queried.The default behavior is to auto increment by zero. i.e: The ticker is left unchanged when queried.
- Since:
- 28.0
-
read
- Specified by:
read
in classcom.google.common.base.Ticker
-