use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsCpuCaptureFrequencyBackgroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue.
@Test
public void getSessionsCpuCaptureFrequencyBackgroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue() {
when(mockRemoteConfigManager.getLong(SESSIONS_CPU_CAPTURE_FREQUENCY_BG_MS_FRC_KEY)).thenReturn(Optional.of(200L));
assertThat(testConfigResolver.getSessionsCpuCaptureFrequencyBackgroundMs()).isEqualTo(200L);
// Android Metadata bundle value is negative.
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);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsMaxDurationMinutes_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence.
@Test
public void getSessionsMaxDurationMinutes_metadataAndRemoteConfigAndCacheAreSet_metadataHasHighestConfigPrecedence() {
// Set cache value.
when(mockDeviceCacheManager.getLong(SESSIONS_MAX_DURATION_MIN_CACHE_KEY)).thenReturn(Optional.of(200L));
// Set remote config value.
when(mockRemoteConfigManager.getLong(SESSIONS_MAX_DURATION_MIN_FRC_KEY)).thenReturn(Optional.of(300L));
// Set Android Manifest value.
Bundle bundle = new Bundle();
bundle.putInt(SESSIONS_MAX_DURATION_MIN_METADATA_KEY, 400);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getSessionsMaxDurationMinutes()).isEqualTo(400L);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getFragmentSamplingRate_validMetadata_returnsMetadata.
@Test
public void getFragmentSamplingRate_validMetadata_returnsMetadata() {
// #1 pass: Validate that method returns Remote Config Value when there is no metadata value.
when(mockRemoteConfigManager.getFloat(FRAGMENT_SAMPLING_RATE_FRC_KEY)).thenReturn(Optional.of(0.01f));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(0.01f);
// #2 pass: Validate that method returns Metadata value which takes higher precedence.
Bundle bundle = new Bundle();
bundle.putFloat("fragment_sampling_percentage", 20.0f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(0.2f);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getSessionsSamplingRate_invalidMetadataBundle_returnCacheValue.
@Test
public void getSessionsSamplingRate_invalidMetadataBundle_returnCacheValue() {
when(mockRemoteConfigManager.getFloat(SESSION_SAMPLING_RATE_FRC_KEY)).thenReturn(Optional.absent());
when(mockDeviceCacheManager.getFloat(SESSION_SAMPLING_RATE_CACHE_KEY)).thenReturn(Optional.of(1.0f));
assertThat(testConfigResolver.getSessionsSamplingRate()).isEqualTo(1.0f);
// Case #1: Android Metadata bundle value is too high.
Bundle bundle = new Bundle();
bundle.putFloat("sessions_sampling_percentage", 200.00f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getSessionsSamplingRate()).isEqualTo(1.0f);
// Case #2: Android Metadata bundle value is too low.
bundle = new Bundle();
bundle.putFloat("sessions_sampling_percentage", -1.00f);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getSessionsSamplingRate()).isEqualTo(1.0f);
}
use of com.google.firebase.perf.util.ImmutableBundle in project firebase-android-sdk by firebase.
the class ConfigResolverTest method getIsPerformanceCollectionDeactivated_flagIsTrue_returnsTrue.
@Test
public void getIsPerformanceCollectionDeactivated_flagIsTrue_returnsTrue() {
Bundle bundle = new Bundle();
bundle.putBoolean("firebase_performance_collection_deactivated", true);
testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
assertThat(testConfigResolver.getIsPerformanceCollectionDeactivated()).isTrue();
}
Aggregations