Search in sources :

Example 31 with ImmutableBundle

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

the class ConfigResolverTest method getSessionsSamplingRate_validMetadata_notSaveMetadataInCache.

@Test
public void getSessionsSamplingRate_validMetadata_notSaveMetadataInCache() {
    Bundle bundle = new Bundle();
    bundle.putFloat("sessions_sampling_percentage", 20.0f);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsSamplingRate()).isEqualTo(0.2f);
    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 32 with ImmutableBundle

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

the class ConfigResolverTest method getIsPerformanceCollectionEnabled_noDeviceCacheAndMetadataIsFalse_returnsFalse.

@Test
public void getIsPerformanceCollectionEnabled_noDeviceCacheAndMetadataIsFalse_returnsFalse() {
    // Arrange metadata.
    Bundle bundle = new Bundle();
    bundle.putBoolean("firebase_performance_collection_enabled", false);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    when(mockDeviceCacheManager.getBoolean(FIREBASE_PERFORMANCE_COLLECTION_ENABLED_CACHE_KEY)).thenReturn(Optional.absent());
    assertThat(testConfigResolver.getIsPerformanceCollectionEnabled()).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 33 with ImmutableBundle

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

the class ConfigResolverTest method getIsPerformanceCollectionEnabled_collectionDeactivated_returnsFalse.

@Test
public void getIsPerformanceCollectionEnabled_collectionDeactivated_returnsFalse() {
    Bundle bundle = new Bundle();
    bundle.putBoolean("firebase_performance_collection_deactivated", true);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getIsPerformanceCollectionEnabled()).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 34 with ImmutableBundle

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

the class ConfigResolverTest method getSessionsMemoryCaptureFrequencyBackgroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue.

@Test
public void getSessionsMemoryCaptureFrequencyBackgroundMs_invalidAndroidMetadataBundle_returnRemoteConfigValue() {
    when(mockRemoteConfigManager.getLong(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_FRC_KEY)).thenReturn(Optional.of(200L));
    assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyBackgroundMs()).isEqualTo(200L);
    // Android Metadata bundle value is negative.
    Bundle bundle = new Bundle();
    bundle.putInt(SESSIONS_MEMORY_CAPTURE_FREQUENCY_BG_MS_METADATA_KEY, -200);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getSessionsMemoryCaptureFrequencyBackgroundMs()).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 35 with ImmutableBundle

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

the class ConfigResolverTest method getFragmentSamplingRate_validMetadata_notSaveMetadataInCache.

@Test
public void getFragmentSamplingRate_validMetadata_notSaveMetadataInCache() {
    Bundle bundle = new Bundle();
    bundle.putFloat("fragment_sampling_percentage", 20.0f);
    testConfigResolver.setMetadataBundle(new ImmutableBundle(bundle));
    assertThat(testConfigResolver.getFragmentSamplingRate()).isEqualTo(0.2f);
    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)

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