Package com.google.common.testing
Class FakeTicker
- java.lang.Object
-
- com.google.common.base.Ticker
-
- com.google.common.testing.FakeTicker
-
@GwtCompatible public class FakeTicker extends com.google.common.base.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
- Author:
- Jige Yu
-
-
Constructor Summary
Constructors Constructor Description FakeTicker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FakeTickeradvance(long nanoseconds)Advances the ticker value bynanoseconds.FakeTickeradvance(long time, java.util.concurrent.TimeUnit timeUnit)Advances the ticker value bytimeintimeUnit.FakeTickeradvance(java.time.Duration duration)Advances the ticker value byduration.longread()FakeTickersetAutoIncrementStep(long autoIncrementStep, java.util.concurrent.TimeUnit timeUnit)Sets the increment applied to the ticker whenever it is queried.FakeTickersetAutoIncrementStep(java.time.Duration autoIncrementStep)Sets the increment applied to the ticker whenever it is queried.
-
-
-
Constructor Detail
-
FakeTicker
public FakeTicker()
-
-
Method Detail
-
advance
@CanIgnoreReturnValue public FakeTicker advance(long time, java.util.concurrent.TimeUnit timeUnit)
Advances the ticker value bytimeintimeUnit.
-
advance
@CanIgnoreReturnValue public FakeTicker advance(long nanoseconds)
Advances the ticker value bynanoseconds.
-
advance
@GwtIncompatible @CanIgnoreReturnValue public FakeTicker advance(java.time.Duration duration)
Advances the ticker value byduration.- Since:
- 28.0
-
setAutoIncrementStep
@CanIgnoreReturnValue 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.
-
setAutoIncrementStep
@GwtIncompatible @CanIgnoreReturnValue public FakeTicker setAutoIncrementStep(java.time.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
public long read()
- Specified by:
readin classcom.google.common.base.Ticker
-
-