use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class FirebasePerfOkHttpClient method enqueue.
@Keep
public static void enqueue(final Call call, final Callback callback) {
Timer timer = new Timer();
long startTime = timer.getMicros();
call.enqueue(new InstrumentOkHttpEnqueueCallback(callback, TransportManager.getInstance(), timer, startTime));
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class RateLimiterTest method setUp.
@Before
public void setUp() {
initMocks(this);
doAnswer(new Answer<Timer>() {
@Override
public Timer answer(InvocationOnMock invocationOnMock) throws Throwable {
return new Timer(MICROS.between(Instant.EPOCH, currentTime));
}
}).when(mClock).getTime();
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class PerfSessionTest method testIsExpiredReturnsFalseWhenCurrentSessionLengthIsEqualToMaxSessionLength.
@Test
public void testIsExpiredReturnsFalseWhenCurrentSessionLengthIsEqualToMaxSessionLength() {
Timer mockTimer = mock(Timer.class);
when(mockTimer.getDurationMicros()).thenReturn(// Default Max Session Length is 4 hours
TimeUnit.HOURS.toMicros(4));
when(mockClock.getTime()).thenReturn(mockTimer);
PerfSession session = new PerfSession("sessionId", mockClock);
assertThat(session.isExpired()).isFalse();
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class PerfSessionTest method testIsExpiredReturnsFalseWhenCurrentSessionLengthIsLessThanMaxSessionLength.
@Test
public void testIsExpiredReturnsFalseWhenCurrentSessionLengthIsLessThanMaxSessionLength() {
Timer mockTimer = mock(Timer.class);
when(mockTimer.getDurationMicros()).thenReturn(TimeUnit.HOURS.toMicros(4) - // Default Max Session Length is 4 hours
TimeUnit.MINUTES.toMicros(1));
when(mockClock.getTime()).thenReturn(mockTimer);
PerfSession session = new PerfSession("sessionId", mockClock);
assertThat(session.isExpired()).isFalse();
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class PerfSessionTest method testIsExpiredReturnsTrueWhenCurrentSessionLengthIsGreaterThanMaxSessionLength.
@Test
public void testIsExpiredReturnsTrueWhenCurrentSessionLengthIsGreaterThanMaxSessionLength() {
Timer mockTimer = mock(Timer.class);
when(mockTimer.getDurationMicros()).thenReturn(// Default Max Session Length is 4 hours
TimeUnit.HOURS.toMicros(5));
when(mockClock.getTime()).thenReturn(mockTimer);
PerfSession session = new PerfSession("sessionId", mockClock);
assertThat(session.isExpired()).isTrue();
}
Aggregations