Search in sources :

Example 56 with ImmutableBundle

use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.

the class ConfigResolverTest method getIsPerformanceCollectionDeactivated_flagIsFalse_returnsFalse.

@Test
public void getIsPerformanceCollectionDeactivated_flagIsFalse_returnsFalse() {
    Bundle bundle = new Bundle();
    bundle.putBoolean("firebase_performance_collection_deactivated", false);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getIsPerformanceCollectionDeactivated()).isFalse();
}
Also used : Bundle(android.os.Bundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) Test(org.junit.Test)

Example 57 with ImmutableBundle

use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.

the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyForegroundMs_validMetadata_returnsMetadata.

@Test
public void getSessionsMemoryCaptureFrequencyForegroundMs_validMetadata_returnsMetadata() {
    // #1 pass: Validate that method returns Remote Config Value when there is no metadata value.
    when(mockRemoteConfigManager.getLong(SESSIONS_MEMORY_CAPTURE_FREQUENCY_FG_MS_FRC_KEY)).thenReturn(Optional.of(400L));
    assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyForegroundMs()).isEqualTo(400L);
    // #2 pass: Validate that method returns Metadata value which takes higher precedence.
    Bundle bundle = new Bundle();
    bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_FG_MS_METADATA_KEY, 200);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyForegroundMs()).isEqualTo(200L);
    // #3 pass: Validate that method returns another valid Metadata value which is 0.
    bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_FG_MS_METADATA_KEY, 0);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyForegroundMs()).isEqualTo(0L);
}
Also used : Bundle(android.os.Bundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) Test(org.junit.Test)

Example 58 with ImmutableBundle

use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.

the class ConfigResolverTest method getSessionsCpuCaptureFrequencyBackgroundMs_invalidMetadataBundle_returnCacheValue.

@Test
public void getSessionsCpuCaptureFrequencyBackgroundMs_invalidMetadataBundle_returnCacheValue() {
    when(mockRemoteConfigManager.getLong(SESSIONS_CPU_CAPTURE_FREQUENCY_BG_MS_FRC_KEY)).thenReturn(Optional.absent());
    when(mockDeviceCacheManager.getLong(SESSIONS_CPU_CAPTURE_FREQUENCY_BG_MS_CACHE_KEY)).thenReturn(Optional.of(200L));
    assertThat(testConfigResolver.getSessionsCpuCaptureFrequencyBackgroundMs()).isEqualTo(200L);
    // Android Metadata bundle value is too high.
    Bundle bundle = new Bundle();
    bundle.putInt(SESSIONS_CPU_CAPTURE_FREQUENCY_BG_MS_METADATA_KEY, -200);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsCpuCaptureFrequencyBackgroundMs()).isEqualTo(200L);
}
Also used : Bundle(android.os.Bundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) Test(org.junit.Test)

Example 59 with ImmutableBundle

use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.

the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyForegroundMs_validMetadata_notSaveMetadataInCache.

@Test
public void getSessionsMemoryCaptureFrequencyForegroundMs_validMetadata_notSaveMetadataInCache() {
    Bundle bundle = new Bundle();
    bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_FG_MS_METADATA_KEY, 20);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    testConfigResolver.getSessionsMemoryCaptureFrequencyForegroundMs();
    verify(mockDeviceCacheManager, never()).setValue(any(), any());
}
Also used : Bundle(android.os.Bundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) Test(org.junit.Test)

Example 60 with ImmutableBundle

use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.

the class ConfigResolverTest method getSessionsMaxDurationMinutes_validMetadata_returnsMetadata.

@Test
public void getSessionsMaxDurationMinutes_validMetadata_returnsMetadata() {
    // #1 pass: Validate that method returns Remote Config Value when there is no metadata value.
    when(mockRemoteConfigManager.getLong(SESSIONS_MAX_DURATION_MIN_FRC_KEY)).thenReturn(Optional.of(400L));
    assertThat(testConfigResolver.getSessionsMaxDurationMinutes()).isEqualTo(400L);
    // #2 pass: Validate that method returns Metadata value which takes higher precedence.
    Bundle bundle = new Bundle();
    bundle.putInt(SESSIONS_MAX_DURATION_MIN_METADATA_KEY, 200);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsMaxDurationMinutes()).isEqualTo(200L);
}
Also used : Bundle(android.os.Bundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) ImmutableBundle(com.google.firebase.perf.util.ImmutableBundle) Test(org.junit.Test)

Aggregations

Bundle (android.os.Bundle)63 ImmutableBundle (com.google.firebase.perf.util.ImmutableBundle)63 Test (org.junit.Test)60 TraceMetric (com.google.firebase.perf.v1.TraceMetric)5 ConfigResolver (com.google.firebase.perf.config.ConfigResolver)4 Activity (android.app.Activity)3 ApplicationInfo (android.content.pm.ApplicationInfo)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 DeviceCacheManager (com.google.firebase.perf.config.DeviceCacheManager)1 FakeDirectExecutorService (com.google.testing.timing.FakeDirectExecutorService)1