Package com.google.common.testing
Class FakeTicker
- java.lang.Object
-
- com.google.common.base.Ticker
-
- com.google.common.testing.FakeTicker
-
@Beta @GwtCompatible public class FakeTicker extends Ticker
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: seesetAutoIncrementStep(long, java.util.concurrent.TimeUnit)
.This class is thread-safe.
- Since:
- 10.0
-
-
Constructor Summary
Constructors Constructor Description FakeTicker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FakeTicker
advance(long nanoseconds)
Advances the ticker value bynanoseconds
.FakeTicker
advance(long time, java.util.concurrent.TimeUnit timeUnit)
Advances the ticker value bytime
intimeUnit
.long
read()
Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.FakeTicker
setAutoIncrementStep(long autoIncrementStep, java.util.concurrent.TimeUnit timeUnit)
Sets the increment applied to the ticker whenever it is queried.-
Methods inherited from class com.google.common.base.Ticker
systemTicker
-
-
-
-
Method Detail
-
advance
public FakeTicker advance(long time, java.util.concurrent.TimeUnit timeUnit)
Advances the ticker value bytime
intimeUnit
.
-
advance
public FakeTicker advance(long nanoseconds)
Advances the ticker value bynanoseconds
.
-
setAutoIncrementStep
public FakeTicker setAutoIncrementStep(long autoIncrementStep, java.util.concurrent.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.
-
-