Search in sources :

Example 16 with CrashlyticsReport

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testLoadFinalizedReports_reportThenEvent_returnsReportWithEvent.

public void testLoadFinalizedReports_reportThenEvent_returnsReportWithEvent() {
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId);
    final long endedAt = System.currentTimeMillis();
    reportPersistence.finalizeReports("skippedSession", endedAt);
    final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
    assertEquals(1, finalizedReports.size());
    final CrashlyticsReport finalizedReport = finalizedReports.get(0).getReport();
    assertEquals(testReport.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent)), finalizedReport);
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 17 with CrashlyticsReport

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testHasFinalizedReports.

public void testHasFinalizedReports() {
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId);
    final long endedAt = System.currentTimeMillis();
    reportPersistence.finalizeReports("skippedSession", endedAt);
    assertTrue(reportPersistence.hasFinalizedReports());
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 18 with CrashlyticsReport

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testDeleteFinalizedReport_removesReports.

public void testDeleteFinalizedReport_removesReports() {
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId);
    reportPersistence.finalizeReports("skippedSession", 0L);
    assertEquals(1, reportPersistence.loadFinalizedReports().size());
    fileStore.getReport(sessionId).delete();
    assertEquals(0, reportPersistence.loadFinalizedReports().size());
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 19 with CrashlyticsReport

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testPersistReportWithAnrEvent.

public void testPersistReportWithAnrEvent() throws IOException {
    reportPersistence = new CrashlyticsReportPersistence(fileStore, createSettingsProviderMock(VERY_LARGE_UPPER_LIMIT, 4));
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final Event testEvent = makeTestAnrEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId, true);
    final long endedAt = System.currentTimeMillis();
    reportPersistence.finalizeReports("skippedSession", endedAt);
    final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
    assertEquals(1, finalizedReports.size());
    final CrashlyticsReport finalizedReport = finalizedReports.get(0).getReport();
    assertEquals(1, finalizedReport.getSession().getEvents().size());
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)

Example 20 with CrashlyticsReport

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testPersistReports_getStartTimestampMillis.

public void testPersistReports_getStartTimestampMillis() {
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    reportPersistence.persistReport(testReport);
    assertEquals(testReport.getSession().getStartedAt() * 1000, reportPersistence.getStartTimestampMillis(sessionId));
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport)

Aggregations

CrashlyticsReport (com.google.firebase.crashlytics.internal.model.CrashlyticsReport)34 CrashlyticsReportWithSessionId (com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)13 Session (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)13 Event (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event)13 IOException (java.io.IOException)8 File (java.io.File)6 Test (org.junit.Test)5 Logger (com.google.firebase.crashlytics.internal.Logger)4 NonNull (androidx.annotation.NonNull)2 TaskCompletionSource (com.google.android.gms.tasks.TaskCompletionSource)2 ArrayList (java.util.ArrayList)2 JsonReader (android.util.JsonReader)1 Settings (com.google.firebase.crashlytics.internal.settings.Settings)1 FeatureFlagData (com.google.firebase.crashlytics.internal.settings.Settings.FeatureFlagData)1 SettingsProvider (com.google.firebase.crashlytics.internal.settings.SettingsProvider)1 StringReader (java.io.StringReader)1