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);
}
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());
}
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);
}
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);
}
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());
}
Aggregations