use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsCpuCaptureFrequencyForegroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue.
@Test
public void getSessionsCpuCaptureFrequencyForegroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue() {
when(mockRemoteConfigManager.getLong(SESSIONS_CPU_CAPTURE_FREQUENCY_FG_MS_FRC_KEY)).thenReturn(Optional.of(200L));
assertThat(testConfigResolver.getSessionsCpuCaptureFrequencyForegroundMs()).isEqualTo(200L);
// Android Metadata bundle value is negative.
Bundle bundle = new Bundle();
bundle.putInt(SESSIONS_CPU_CAPTURE_FREQUENCY_FG_MS_METADATA_KEY, -200);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getSessionsCpuCaptureFrequencyForegroundMs()).isEqualTo(200L);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getFragmentSamplingRate_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence.
@Test
public void getFragmentSamplingRate_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence() {
// Set cache value.
when(mockDeviceCacheManager.getFloat(FRAGMENT_SAMPLING_RATE_CACHE_KEY)).thenReturn(Optional.of(0.2f));
// Set remote config value.
when(mockRemoteConfigManager.getFloat(FRAGMENT_SAMPLING_RATE_FRC_KEY)).thenReturn(Optional.of(0.3f));
// Set Android Manifest value.
Bundle bundle = new Bundle();
bundle.putFloat("fragment_sampling_percentage", 4.0f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(0.04f);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getFragmentSamplingRate_invalidAndroidMetadataBundle_returnRemoteConfigValue.
@Test
public void getFragmentSamplingRate_invalidAndroidMetadataBundle_returnRemoteConfigValue() {
when(mockRemoteConfigManager.getFloat(FRAGMENT_SAMPLING_RATE_FRC_KEY)).thenReturn(Optional.of(0.25f));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(0.25f);
// 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(0.25f);
// 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(0.25f);
}
Aggregations