Search in sources :

Example 26 with CrashlyticsReport

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

the class CrashlyticsReportPersistenceTest method persistReportWithEvent.

private static void persistReportWithEvent(CrashlyticsReportPersistence reportPersistence, String sessionId, boolean isHighPriority) {
    CrashlyticsReport testReport = makeTestReport(sessionId);
    reportPersistence.persistReport(testReport);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistEvent(testEvent, sessionId, isHighPriority);
}
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 27 with CrashlyticsReport

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

the class CrashlyticsReportPersistenceTest method testDeleteAllReports_removesAllReports.

public void testDeleteAllReports_removesAllReports() {
    final String sessionId1 = "testSession1";
    final CrashlyticsReport testReport1 = makeTestReport(sessionId1);
    final String sessionId2 = "testSession2";
    final CrashlyticsReport testReport2 = makeTestReport(sessionId2);
    final CrashlyticsReport.Session.Event testEvent1 = makeTestEvent();
    final CrashlyticsReport.Session.Event testEvent2 = makeTestEvent();
    reportPersistence.persistReport(testReport1);
    reportPersistence.persistReport(testReport2);
    reportPersistence.persistEvent(testEvent1, sessionId1);
    reportPersistence.persistEvent(testEvent2, sessionId2);
    reportPersistence.finalizeReports("skippedSession", 0L);
    assertEquals(2, reportPersistence.loadFinalizedReports().size());
    reportPersistence.deleteAllReports();
    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 28 with CrashlyticsReport

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

the class CrashlyticsReportPersistenceTest method testPersistEvent_keepsAppropriateNumberOfMostRecentEvents.

public void testPersistEvent_keepsAppropriateNumberOfMostRecentEvents() throws IOException {
    reportPersistence = new CrashlyticsReportPersistence(fileStore, createSettingsProviderMock(VERY_LARGE_UPPER_LIMIT, 4));
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final CrashlyticsReport.Session.Event testEvent1 = makeTestEvent("type1", "reason1");
    final CrashlyticsReport.Session.Event testEvent2 = makeTestEvent("type2", "reason2");
    final CrashlyticsReport.Session.Event testEvent3 = makeTestEvent("type3", "reason3");
    final CrashlyticsReport.Session.Event testEvent4 = makeTestEvent("type4", "reason4");
    final CrashlyticsReport.Session.Event testEvent5 = makeTestEvent("type5", "reason5");
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent1, sessionId);
    reportPersistence.persistEvent(testEvent2, sessionId);
    reportPersistence.persistEvent(testEvent3, sessionId);
    reportPersistence.persistEvent(testEvent4, sessionId);
    reportPersistence.persistEvent(testEvent5, 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(4, finalizedReport.getSession().getEvents().size());
    assertEquals(testReport.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent2, testEvent3, testEvent4, testEvent5)), 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 29 with CrashlyticsReport

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

the class CrashlyticsReportPersistenceTest method testLoadFinalizedReports_reportsWithEventsInMultipleSessions_returnsReportsWithProperEvents.

public void testLoadFinalizedReports_reportsWithEventsInMultipleSessions_returnsReportsWithProperEvents() {
    final String sessionId1 = "testSession1";
    final CrashlyticsReport testReport1 = makeTestReport(sessionId1);
    final String sessionId2 = "testSession2";
    final CrashlyticsReport testReport2 = makeTestReport(sessionId2);
    final CrashlyticsReport.Session.Event testEvent1 = makeTestEvent();
    final CrashlyticsReport.Session.Event testEvent2 = makeTestEvent();
    reportPersistence.persistReport(testReport1);
    reportPersistence.persistReport(testReport2);
    reportPersistence.persistEvent(testEvent1, sessionId1);
    reportPersistence.persistEvent(testEvent2, sessionId2);
    final long endedAt = System.currentTimeMillis();
    reportPersistence.finalizeReports("skippedSession", endedAt);
    final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
    assertEquals(2, finalizedReports.size());
    final CrashlyticsReport finalizedReport1 = finalizedReports.get(1).getReport();
    assertEquals(testReport1.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent1)), finalizedReport1);
    final CrashlyticsReport finalizedReport2 = finalizedReports.get(0).getReport();
    assertEquals(testReport2.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent2)), finalizedReport2);
}
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 30 with CrashlyticsReport

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

the class CrashlyticsReportPersistenceTest method testDeleteFinalizedReport_withWrongSessionId_doesNotRemoveReports.

public void testDeleteFinalizedReport_withWrongSessionId_doesNotRemoveReports() {
    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("wrongSessionId").delete();
    assertEquals(1, 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)

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