use of com.google.firebase.components.Lazy in project firebase-android-sdk by firebase.
the class GaugeManagerTest method testLogGaugeMetadataLogsAfterApplicationContextIsSet.
@Test
public void testLogGaugeMetadataLogsAfterApplicationContextIsSet() {
testGaugeManager = new GaugeManager(new Lazy<>(() -> fakeScheduledExecutorService), mockTransportManager, mockConfigResolver, /* gaugeMetadataManager= */
null, new Lazy<>(() -> fakeCpuGaugeCollector), new Lazy<>(() -> fakeMemoryGaugeCollector));
assertThat(testGaugeManager.logGaugeMetadata("sessionId", ApplicationProcessState.FOREGROUND)).isFalse();
testGaugeManager.initializeGaugeMetadataManager(ApplicationProvider.getApplicationContext());
assertThat(testGaugeManager.logGaugeMetadata("sessionId", ApplicationProcessState.FOREGROUND)).isTrue();
GaugeMetric recordedGaugeMetric = getLastRecordedGaugeMetric(ApplicationProcessState.FOREGROUND, 1);
GaugeMetadata recordedGaugeMetadata = recordedGaugeMetric.getGaugeMetadata();
assertThat(recordedGaugeMetric.getSessionId()).isEqualTo("sessionId");
assertThat(recordedGaugeMetadata.hasProcessName()).isTrue();
}
use of com.google.firebase.components.Lazy 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