TestTimeUtil: Allow to get current timestamp
This allows tests to know what the next timestamp is going to be and use this timestamp for test assertions. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I63f63d877bce406967d5bc6ab00d26c3aaae2908
This commit is contained in:
@@ -118,6 +118,15 @@ public class TestTimeUtil {
|
|||||||
clockMs.addAndGet(clockStepUnit.toMillis(clockStep));
|
clockMs.addAndGet(clockStepUnit.toMillis(clockStep));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current timestamp.
|
||||||
|
*
|
||||||
|
* @return current timestamp
|
||||||
|
*/
|
||||||
|
public static synchronized Timestamp getCurrentTimestamp() {
|
||||||
|
return new Timestamp(clockMs.get());
|
||||||
|
}
|
||||||
|
|
||||||
/** Reset the clock to use the actual system clock. */
|
/** Reset the clock to use the actual system clock. */
|
||||||
public static synchronized void useSystemTime() {
|
public static synchronized void useSystemTime() {
|
||||||
clockMs = null;
|
clockMs = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user