use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyForegroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue.
@Test
public void getSessionsMemoryCaptureFrequencyForegroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue() {
when(mockRemoteConfigManager.getLong(SESSIONS_MEMORY_CAPTURE_FREQUENCY_FG_MS_FRC_KEY)).thenReturn(Optional.of(200L));
assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyForegroundMs()).isEqualTo(200L);
// Android Metadata bundle value is negative.
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);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyBackgroundMs_validMetadata_notSaveMetadataInCache.
@Test
public void getSessionsMemoryCaptureFrequencyBackgroundMs_validMetadata_notSaveMetadataInCache() {
Bundle bundle = new Bundle();
bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_METADATA_KEY, 20);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
testConfigResolver.getSessionsMemoryCaptureFrequencyBackgroundMs();
verify(mockDeviceCacheManager, never()).setValue(any(), any());
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyBackgroundMs_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence.
@Test
public void getSessionsMemoryCaptureFrequencyBackgroundMs_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence() {
// Set cache value.
when(mockDeviceCacheManager.getLong(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_CACHE_KEY)).thenReturn(Optional.of(200L));
// Set remote config value.
when(mockRemoteConfigManager.getLong(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_FRC_KEY)).thenReturn(Optional.of(300L));
// Set Android Manifest value.
Bundle bundle = new Bundle();
bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_METADATA_KEY, 400);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyBackgroundMs()).isEqualTo(400L);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getFragmentSamplingRate_invalidAndroidMetadataBundle_returnDefaultValue.
@Test
public void getFragmentSamplingRate_invalidAndroidMetadataBundle_returnDefaultValue() {
Float defaultValue = ConfigurationConstants.FragmentSamplingRate.getInstance().getDefault();
when(mockRemoteConfigManager.getFloat(FRAGMENT_SAMPLING_RATE_FRC_KEY)).thenReturn(Optional.absent());
when(mockDeviceCacheManager.getFloat(FRAGMENT_SAMPLING_RATE_CACHE_KEY)).thenReturn(Optional.absent());
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(defaultValue);
// Case #1: Android Metadata bundle value is too high.
Bundle bundle = new Bundle();
bundle.putFloat("fragment_sampling_percentage", 200.00f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(defaultValue);
// Case #2: Android Metadata bundle value is too low.
bundle = new Bundle();
bundle.putFloat("fragment_sampling_percentage", -1.00f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(defaultValue);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsMaxDurationMinutes_validMetadata_notSaveMetadataInCache.
@Test
public void getSessionsMaxDurationMinutes_validMetadata_notSaveMetadataInCache() {
Bundle bundle = new Bundle();
bundle.putInt(SESSIONS_MAX_DURATION_MIN_METADATA_KEY, 20);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
testConfigResolver.getSessionsMaxDurationMinutes();
verify(mockDeviceCacheManager, never()).setValue(any(), any());
}
Aggregations