use of com.google.firebase.crashlytics.internal.settings.Settings in project firebase-android-sdk by firebase.
the class CrashlyticsReportPersistenceTest method testPersistEvent_whenSettingsChanges_keepsAppropriateNumberOfMostRecentEvents.
public void testPersistEvent_whenSettingsChanges_keepsAppropriateNumberOfMostRecentEvents() throws IOException {
SettingsProvider settingsProvider = mock(SettingsProvider.class);
Settings.SessionData sessionData1 = new Settings.SessionData(4, VERY_LARGE_UPPER_LIMIT);
Settings.SessionData sessionData2 = new Settings.SessionData(8, VERY_LARGE_UPPER_LIMIT);
Settings settings1 = new Settings(0, sessionData1, new FeatureFlagData(true, true), 3, 0, 1.0, 1.0, 1);
Settings settings2 = new Settings(0, sessionData2, new FeatureFlagData(true, true), 3, 0, 1.0, 1.0, 1);
when(settingsProvider.getSettingsSync()).thenReturn(settings1);
reportPersistence = new CrashlyticsReportPersistence(fileStore, settingsProvider);
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);
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);
when(settingsProvider.getSettingsSync()).thenReturn(settings2);
final CrashlyticsReport.Session.Event testEvent6 = makeTestEvent("type6", "reason6");
final CrashlyticsReport.Session.Event testEvent7 = makeTestEvent("type7", "reason7");
final CrashlyticsReport.Session.Event testEvent8 = makeTestEvent("type8", "reason8");
final CrashlyticsReport.Session.Event testEvent9 = makeTestEvent("type9", "reason9");
final CrashlyticsReport.Session.Event testEvent10 = makeTestEvent("type10", "reason10");
final String sessionId2 = "testSession2";
final CrashlyticsReport testReport2 = makeTestReport(sessionId2);
reportPersistence.persistReport(testReport2);
reportPersistence.persistEvent(testEvent1, sessionId2);
reportPersistence.persistEvent(testEvent2, sessionId2);
reportPersistence.persistEvent(testEvent3, sessionId2);
reportPersistence.persistEvent(testEvent4, sessionId2);
reportPersistence.persistEvent(testEvent5, sessionId2);
reportPersistence.persistEvent(testEvent6, sessionId2);
reportPersistence.persistEvent(testEvent7, sessionId2);
reportPersistence.persistEvent(testEvent8, sessionId2);
reportPersistence.persistEvent(testEvent9, sessionId2);
reportPersistence.persistEvent(testEvent10, sessionId2);
endedAt = System.currentTimeMillis();
reportPersistence.finalizeReports("skippedSession", endedAt);
final List<CrashlyticsReportWithSessionId> finalizedReports2 = reportPersistence.loadFinalizedReports();
assertEquals(2, finalizedReports2.size());
final CrashlyticsReport finalizedReport2 = finalizedReports2.get(0).getReport();
assertEquals(8, finalizedReport2.getSession().getEvents().size());
assertEquals(testReport2.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent3, testEvent4, testEvent5, testEvent6, testEvent7, testEvent8, testEvent9, testEvent10)), finalizedReport2);
}
use of com.google.firebase.crashlytics.internal.settings.Settings in project firebase-android-sdk by firebase.
the class CrashlyticsControllerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
testContext = getContext();
FirebaseInstallationsApi installationsApiMock = mock(FirebaseInstallationsApi.class);
when(installationsApiMock.getId()).thenReturn(Tasks.forResult("instanceId"));
idManager = new IdManager(testContext, testContext.getPackageName(), installationsApiMock, DataCollectionArbiterTest.MOCK_ARBITER_ENABLED);
testFileStore = new FileStore(testContext);
Settings testSettings = new TestSettings(3);
mockSessionReportingCoordinator = mock(SessionReportingCoordinator.class);
mockDataCollectionArbiter = mock(DataCollectionArbiter.class);
when(mockDataCollectionArbiter.isAutomaticDataCollectionEnabled()).thenReturn(true);
testSettingsProvider = mock(SettingsProvider.class);
when(testSettingsProvider.getSettingsSync()).thenReturn(testSettings);
when(testSettingsProvider.getSettingsAsync()).thenReturn(Tasks.forResult(testSettings));
}
use of com.google.firebase.crashlytics.internal.settings.Settings in project firebase-android-sdk by firebase.
the class CrashlyticsCoreInitializationTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mockAppContext = newMockContext();
mockResources = mock(Resources.class);
testFirebaseOptions = new FirebaseOptions.Builder().setApplicationId(GOOGLE_APP_ID).build();
fileStore = new FileStore(getContext());
mockSettingsController = mock(SettingsController.class);
Settings settings = new TestSettings();
when(mockSettingsController.getSettingsSync()).thenReturn(settings);
when(mockSettingsController.getSettingsAsync()).thenReturn(Tasks.forResult(settings));
}
use of com.google.firebase.crashlytics.internal.settings.Settings in project firebase-android-sdk by firebase.
the class CrashlyticsCoreTest method startCoreAsync.
// Starts the given CrashlyticsCore.
private Task<CrashlyticsCore> startCoreAsync(CrashlyticsCore crashlyticsCore) {
// Swallow exceptions so tests don't crash.
Thread.setDefaultUncaughtExceptionHandler(NOOP_HANDLER);
SettingsController mockSettingsController = mock(SettingsController.class);
final Settings settings = new TestSettings(3);
when(mockSettingsController.getSettingsSync()).thenReturn(settings);
when(mockSettingsController.getSettingsAsync()).thenReturn(Tasks.forResult(settings));
AppData appData = new AppData(GOOGLE_APP_ID, "buildId", "installerPackageName", "packageName", "versionCode", "versionName", mock(DevelopmentPlatformProvider.class));
crashlyticsCore.onPreExecute(appData, mockSettingsController);
return crashlyticsCore.doBackgroundInitializationAsync(mockSettingsController).onSuccessTask(new SuccessContinuation<Void, CrashlyticsCore>() {
@NonNull
@Override
public Task<CrashlyticsCore> then(@Nullable Void aVoid) throws Exception {
return Tasks.forResult(crashlyticsCore);
}
});
}
Aggregations