Search in sources :

Example 1 with FirebasePerformanceInitializer

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

the class AppStateMonitorTest method appHotStart_singleSubscriber_callbackIsNotCalled.

@Test
public void appHotStart_singleSubscriber_callbackIsNotCalled() {
    AppStateMonitor monitor = new AppStateMonitor(transportManager, clock);
    FirebasePerformanceInitializer mockInitializer = mock(FirebasePerformanceInitializer.class);
    monitor.registerForAppColdStart(mockInitializer);
    // Activity comes to Foreground
    monitor.onActivityResumed(activity1);
    verify(mockInitializer, times(1)).onAppColdStart();
    // Activity goes to Background
    monitor.onActivityStopped(activity1);
    // Activity comes to Foreground
    monitor.onActivityResumed(activity1);
    verify(mockInitializer, times(1)).onAppColdStart();
}
Also used : FirebasePerformanceInitializer(com.google.firebase.perf.FirebasePerformanceInitializer) Test(org.junit.Test)

Example 2 with FirebasePerformanceInitializer

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

the class AppStateMonitorTest method appColdStart_singleSubscriber_callbackIsCalled.

@Test
public void appColdStart_singleSubscriber_callbackIsCalled() {
    AppStateMonitor monitor = new AppStateMonitor(transportManager, clock);
    FirebasePerformanceInitializer mockInitializer = mock(FirebasePerformanceInitializer.class);
    monitor.registerForAppColdStart(mockInitializer);
    // Activity comes to Foreground
    monitor.onActivityResumed(activity1);
    verify(mockInitializer, times(1)).onAppColdStart();
}
Also used : FirebasePerformanceInitializer(com.google.firebase.perf.FirebasePerformanceInitializer) Test(org.junit.Test)

Example 3 with FirebasePerformanceInitializer

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

the class AppStateMonitorTest method appColdStart_multipleSubscriber_callbackIsCalled.

@Test
public void appColdStart_multipleSubscriber_callbackIsCalled() {
    AppStateMonitor monitor = new AppStateMonitor(transportManager, clock);
    FirebasePerformanceInitializer mockInitializer1 = mock(FirebasePerformanceInitializer.class);
    FirebasePerformanceInitializer mockInitializer2 = mock(FirebasePerformanceInitializer.class);
    monitor.registerForAppColdStart(mockInitializer1);
    monitor.registerForAppColdStart(mockInitializer2);
    // Activity comes to Foreground
    monitor.onActivityResumed(activity1);
    verify(mockInitializer1, times(1)).onAppColdStart();
    verify(mockInitializer2, times(1)).onAppColdStart();
}
Also used : FirebasePerformanceInitializer(com.google.firebase.perf.FirebasePerformanceInitializer) Test(org.junit.Test)

Example 4 with FirebasePerformanceInitializer

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

the class FirebasePerfProvider method attachInfo.

@Override
public void attachInfo(Context context, ProviderInfo info) {
    // super.attachInfo calls onCreate(). Fail as early as possible.
    checkContentProviderAuthority(info);
    super.attachInfo(context, info);
    // Initialize ConfigResolver early for accessing device caching layer.
    ConfigResolver configResolver = ConfigResolver.getInstance();
    configResolver.setContentProviderContext(getContext());
    AppStateMonitor appStateMonitor = AppStateMonitor.getInstance();
    appStateMonitor.registerActivityLifecycleCallbacks(getContext());
    appStateMonitor.registerForAppColdStart(new FirebasePerformanceInitializer());
    AppStartTrace appStartTrace = AppStartTrace.getInstance();
    appStartTrace.registerActivityLifecycleCallbacks(getContext());
    mainHandler.post(new AppStartTrace.StartFromBackgroundRunnable(appStartTrace));
    // In the case of cold start, we create a session and start collecting gauges as early as
    // possible.
    // There is code in SessionManager that prevents us from resetting the session twice in case
    // of app cold start.
    SessionManager.getInstance().initializeGaugeCollection();
}
Also used : ConfigResolver(com.google.firebase.perf.config.ConfigResolver) AppStartTrace(com.google.firebase.perf.metrics.AppStartTrace) AppStateMonitor(com.google.firebase.perf.application.AppStateMonitor) FirebasePerformanceInitializer(com.google.firebase.perf.FirebasePerformanceInitializer)

Example 5 with FirebasePerformanceInitializer

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

the class AppStateMonitorTest method appColdStart_singleSubscriberRegistersForMultipleTimes_oneCallbackIsCalled.

@Test
public void appColdStart_singleSubscriberRegistersForMultipleTimes_oneCallbackIsCalled() {
    AppStateMonitor monitor = new AppStateMonitor(transportManager, clock);
    FirebasePerformanceInitializer mockInitializer1 = mock(FirebasePerformanceInitializer.class);
    monitor.registerForAppColdStart(mockInitializer1);
    monitor.registerForAppColdStart(mockInitializer1);
    // Activity comes to Foreground
    monitor.onActivityResumed(activity1);
    verify(mockInitializer1, times(1)).onAppColdStart();
}
Also used : FirebasePerformanceInitializer(com.google.firebase.perf.FirebasePerformanceInitializer) Test(org.junit.Test)

Aggregations

FirebasePerformanceInitializer (com.google.firebase.perf.FirebasePerformanceInitializer)5 Test (org.junit.Test)4 AppStateMonitor (com.google.firebase.perf.application.AppStateMonitor)1 ConfigResolver (com.google.firebase.perf.config.ConfigResolver)1 AppStartTrace (com.google.firebase.perf.metrics.AppStartTrace)1