Skip to content

Commit 8377e8c

Browse files
committed
Revert usage of mockClock
1 parent 97bc643 commit 8377e8c

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

firebase-perf/src/test/java/com/google/firebase/perf/session/PerfSessionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void testIsExpiredReturnsFalseWhenCurrentSessionLengthIsLessThanMaxSessio
231231
- TimeUnit.MINUTES.toMicros(1)); // Default Max Session Length is 4 hours
232232
when(mockClock.getTime()).thenReturn(mockTimer);
233233

234-
PerfSession session = PerfSession.createWithId("sessionId");
234+
PerfSession session = new PerfSession("sessionId", mockClock);
235235
assertThat(session.isSessionRunningTooLong()).isFalse();
236236
}
237237

@@ -242,7 +242,7 @@ public void testIsExpiredReturnsFalseWhenCurrentSessionLengthIsEqualToMaxSession
242242
.thenReturn(TimeUnit.HOURS.toMicros(4)); // Default Max Session Length is 4 hours
243243
when(mockClock.getTime()).thenReturn(mockTimer);
244244

245-
PerfSession session = PerfSession.createWithId("sessionId");
245+
PerfSession session = new PerfSession("sessionId", mockClock);
246246
assertThat(session.isSessionRunningTooLong()).isFalse();
247247
}
248248

@@ -253,7 +253,7 @@ public void testIsExpiredReturnsTrueWhenCurrentSessionLengthIsGreaterThanMaxSess
253253
.thenReturn(TimeUnit.HOURS.toMicros(5)); // Default Max Session Length is 4 hours
254254
when(mockClock.getTime()).thenReturn(mockTimer);
255255

256-
PerfSession session = PerfSession.createWithId("sessionId");
256+
PerfSession session = new PerfSession("sessionId", mockClock);
257257
assertThat(session.isSessionRunningTooLong()).isTrue();
258258
}
259259
}

firebase-perf/src/test/java/com/google/firebase/perf/session/SessionManagerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void testSessionIdDoesNotUpdateIfPerfSessionRunsTooLong() {
112112
Timer mockTimer = mock(Timer.class);
113113
when(mockClock.getTime()).thenReturn(mockTimer);
114114

115-
PerfSession session = new PerfSession("sessionId", mockClock, true);
115+
PerfSession session = new PerfSession("sessionId", mockClock);
116116
SessionManager testSessionManager =
117117
new SessionManager(mockGaugeManager, session, mockAppStateMonitor);
118118

@@ -131,10 +131,10 @@ public void testUpdatePerfSessionStartsCollectingGaugesIfSessionIsVerbose() {
131131
when(mockClock.getTime()).thenReturn(mockTimer);
132132
when(mockAppStateMonitor.getAppState()).thenReturn(ApplicationProcessState.FOREGROUND);
133133

134-
PerfSession previousSession = new PerfSession("previousSession", mockClock, true);
134+
PerfSession previousSession = new PerfSession("previousSession", mockClock);
135135
previousSession.setGaugeAndEventCollectionEnabled(false);
136136

137-
PerfSession newSession = new PerfSession("newSession", mockClock, true);
137+
PerfSession newSession = new PerfSession("newSession", mockClock);
138138
newSession.setGaugeAndEventCollectionEnabled(true);
139139

140140
SessionManager testSessionManager =

firebase-perf/src/test/java/com/google/firebase/perf/session/gauges/GaugeManagerTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.google.firebase.perf.v1.CpuMetricReading;
4242
import com.google.firebase.perf.v1.GaugeMetadata;
4343
import com.google.firebase.perf.v1.GaugeMetric;
44-
import com.google.firebase.sessions.api.SessionSubscriber;
4544
import com.google.testing.timing.FakeScheduledExecutorService;
4645
import java.util.UUID;
4746
import java.util.concurrent.TimeUnit;
@@ -408,8 +407,6 @@ public void testStopCollectingGaugesCreatesOneLastJobToConsumeAnyPendingMetrics(
408407
// It's not currently logging to transport.
409408
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
410409

411-
// An AQS session ID is expected when stopping Gauge collection.
412-
fakeSession.setAQSId(new SessionSubscriber.SessionDetails("aqsSessionId"));
413410
testGaugeManager.stopCollectingGauges();
414411
assertThat(fakeScheduledExecutorService.isEmpty()).isFalse();
415412

@@ -427,9 +424,9 @@ public void testStopCollectingGaugesCreatesOneLastJobToConsumeAnyPendingMetrics(
427424
GaugeMetric recordedGaugeMetric =
428425
getLastRecordedGaugeMetric(ApplicationProcessState.BACKGROUND, 1);
429426
assertThatCpuGaugeMetricWasSentToTransport(
430-
fakeSession.aqsSessionId(), recordedGaugeMetric, fakeCpuMetricReading);
427+
fakeSession.sessionId(), recordedGaugeMetric, fakeCpuMetricReading);
431428
assertThatMemoryGaugeMetricWasSentToTransport(
432-
fakeSession.aqsSessionId(), recordedGaugeMetric, fakeMemoryMetricReading);
429+
fakeSession.sessionId(), recordedGaugeMetric, fakeMemoryMetricReading);
433430
}
434431

435432
@Test
@@ -451,7 +448,6 @@ public void testGaugeManagerDoesNotClearTheQueueUnlessUpdated() {
451448
assertThat(fakeCpuGaugeCollector.cpuMetricReadings).isNotEmpty();
452449
assertThat(fakeMemoryGaugeCollector.memoryMetricReadings).isNotEmpty();
453450

454-
fakeSession.setAQSId(new SessionSubscriber.SessionDetails("aqsSessionId"));
455451
testGaugeManager.updateGaugeCollection(ApplicationProcessState.FOREGROUND);
456452

457453
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();

0 commit comments

Comments
 (0)