
org.robolectric.shadows.ShadowSystem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.os.SystemClock;
import java.util.concurrent.TimeUnit;
import org.robolectric.annotation.LooperMode;
public class ShadowSystem {
/**
* Implements {@link System#nanoTime} through ShadowWrangler.
*
* @return Current time with nanos.
*/
@SuppressWarnings("unused")
public static long nanoTime() {
if (ShadowLooper.looperMode() == LooperMode.Mode.LEGACY) {
return ShadowLegacySystemClock.nanoTime();
} else {
return TimeUnit.MILLISECONDS.toNanos(SystemClock.uptimeMillis());
}
}
/**
* Implements {@link System#currentTimeMillis} through ShadowWrangler.
*
* @return Current time with millis.
*/
@SuppressWarnings("unused")
public static long currentTimeMillis() {
if (ShadowLooper.looperMode() == LooperMode.Mode.LEGACY) {
return ShadowLegacySystemClock.currentTimeMillis();
} else {
return SystemClock.uptimeMillis();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy