use of com.google.testing.timing.FakeScheduledExecutorService in project firebase-android-sdk by firebase.
the class RemoteConfigManagerTest method setUp.
@Before
public void setUp() {
initMocks(this);
fakeExecutor = new FakeScheduledExecutorService();
when(mockFirebaseRemoteConfigProvider.get()).thenReturn(mockFirebaseRemoteConfigComponent);
when(mockFirebaseRemoteConfigComponent.get(FIREPERF_FRC_NAMESPACE_NAME)).thenReturn(mockFirebaseRemoteConfig);
when(mockFirebaseRemoteConfig.getAll()).thenReturn(new HashMap<>());
}
use of com.google.testing.timing.FakeScheduledExecutorService in project firebase-android-sdk by firebase.
the class AppStartTraceTest method testDelayedAppStart.
@Test
public void testDelayedAppStart() {
FakeScheduledExecutorService fakeExecutorService = new FakeScheduledExecutorService();
AppStartTrace trace = new AppStartTrace(transportManager, clock, fakeExecutorService);
// Delays activity creation after 1 minute from app start time.
currentTime = appStartTime + TimeUnit.MINUTES.toMicros(1) + 1;
trace.onActivityCreated(activity1, bundle);
Assert.assertEquals(currentTime, trace.getOnCreateTime().getMicros());
++currentTime;
trace.onActivityStarted(activity1);
++currentTime;
trace.onActivityResumed(activity1);
Assert.assertNull(trace.getOnStartTime());
Assert.assertNull(trace.getOnResumeTime());
// There should be no trace sent.
verify(transportManager, times(0)).log(traceArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
}
use of com.google.testing.timing.FakeScheduledExecutorService in project firebase-android-sdk by firebase.
the class TransportManagerTest method setUp.
@Before
public void setUp() {
initMocks(this);
when(mockConfigResolver.isPerformanceMonitoringEnabled()).thenReturn(true);
mockInstallationsGetId(FAKE_FIREBASE_INSTALLATIONS_ID);
when(mockRateLimiter.isEventSampled(ArgumentMatchers.any())).thenReturn(true);
when(mockRateLimiter.isEventRateLimited(ArgumentMatchers.any())).thenReturn(false);
fakeExecutorService = new FakeScheduledExecutorService();
initializeTransport(true);
fakeExecutorService.runAll();
}
use of com.google.testing.timing.FakeScheduledExecutorService in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method setUp.
@Before
public void setUp() throws IOException {
fakeScheduledExecutorService = new FakeScheduledExecutorService();
fakeProcFile = createFakeFileToEmulateProcPidStat("100", "100", "100", "100");
testGaugeCollector = new CpuGaugeCollector(fakeScheduledExecutorService, fakeProcFile, fakeClockTicksPerSecond);
}
use of com.google.testing.timing.FakeScheduledExecutorService in project firebase-android-sdk by firebase.
the class GaugeManagerTest method setUp.
@Before
public void setUp() {
fakeScheduledExecutorService = new FakeScheduledExecutorService();
mockTransportManager = mock(TransportManager.class);
mockConfigResolver = mock(ConfigResolver.class);
fakeGaugeMetadataManager = spy(new GaugeMetadataManager(Runtime.getRuntime(), ApplicationProvider.getApplicationContext()));
fakeCpuGaugeCollector = spy(new CpuGaugeCollector());
fakeMemoryGaugeCollector = spy(new MemoryGaugeCollector());
doNothing().when(fakeCpuGaugeCollector).startCollecting(ArgumentMatchers.anyLong(), ArgumentMatchers.nullable(Timer.class));
doNothing().when(fakeCpuGaugeCollector).stopCollecting();
doNothing().when(fakeMemoryGaugeCollector).startCollecting(ArgumentMatchers.anyLong(), ArgumentMatchers.nullable(Timer.class));
doNothing().when(fakeMemoryGaugeCollector).stopCollecting();
doNothing().when(fakeCpuGaugeCollector).collectOnce(ArgumentMatchers.nullable(Timer.class));
doNothing().when(fakeMemoryGaugeCollector).collectOnce(ArgumentMatchers.nullable(Timer.class));
forceVerboseSession();
doReturn(DEFAULT_CPU_GAUGE_COLLECTION_FREQUENCY_BG_MS).when(mockConfigResolver).getSessionsCpuCaptureFrequencyBackgroundMs();
doReturn(DEFAULT_CPU_GAUGE_COLLECTION_FREQUENCY_FG_MS).when(mockConfigResolver).getSessionsCpuCaptureFrequencyForegroundMs();
doReturn(DEFAULT_MEMORY_GAUGE_COLLECTION_FREQUENCY_BG_MS).when(mockConfigResolver).getSessionsMemoryCaptureFrequencyBackgroundMs();
doReturn(DEFAULT_MEMORY_GAUGE_COLLECTION_FREQUENCY_FG_MS).when(mockConfigResolver).getSessionsMemoryCaptureFrequencyForegroundMs();
when(mockTransportManager.isInitialized()).thenReturn(true);
testGaugeManager = new GaugeManager(new Lazy<>(() -> fakeScheduledExecutorService), mockTransportManager, mockConfigResolver, fakeGaugeMetadataManager, new Lazy<>(() -> fakeCpuGaugeCollector), new Lazy<>(() -> fakeMemoryGaugeCollector));
}
Aggregations