Skip to content

Commit a985c4a

Browse files
authored
Fix tests on lower api levels (#6071)
I noticed tests were failing when testing on api 21 for the file system change. They were failing because the `ApplicationExitInfo` class isn't available until Android 11, that's api level 30.
1 parent 2bf11d2 commit a985c4a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common/CrashlyticsControllerTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.content.Context;
3030
import android.content.SharedPreferences;
3131
import android.os.Bundle;
32+
import androidx.test.filters.SdkSuppress;
3233
import com.google.android.gms.tasks.Task;
3334
import com.google.android.gms.tasks.TaskCompletionSource;
3435
import com.google.android.gms.tasks.Tasks;
@@ -194,6 +195,7 @@ private CrashlyticsController createController() {
194195
return controller;
195196
}
196197

198+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
197199
public void testWriteNonFatal_callsSessionReportingCoordinatorPersistNonFatal() throws Exception {
198200
final String sessionId = "sessionId";
199201
final Thread thread = Thread.currentThread();
@@ -210,6 +212,7 @@ public void testWriteNonFatal_callsSessionReportingCoordinatorPersistNonFatal()
210212
.persistNonFatalEvent(eq(nonFatal), eq(thread), eq(sessionId), anyLong());
211213
}
212214

215+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
213216
public void testFatalException_callsSessionReportingCoordinatorPersistFatal() throws Exception {
214217
final String sessionId = "sessionId";
215218
final Thread thread = Thread.currentThread();
@@ -226,6 +229,7 @@ public void testFatalException_callsSessionReportingCoordinatorPersistFatal() th
226229
}
227230

228231
@Test
232+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
229233
public void testOnDemandFatal_callLogFatalException() {
230234
Thread thread = Thread.currentThread();
231235
Exception fatal = new RuntimeException("Fatal");
@@ -245,6 +249,7 @@ public void testOnDemandFatal_callLogFatalException() {
245249
verify(mockUserMetadata).setNewSession(not(eq(SESSION_ID)));
246250
}
247251

252+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
248253
public void testNativeCrashDataCausesNativeReport() throws Exception {
249254
final String sessionId = "sessionId_1_new";
250255
final String previousSessionId = "sessionId_0_previous";
@@ -325,6 +330,7 @@ public File getOsFile() {
325330
.finalizeSessionWithNativeEvent(eq(sessionId), any(), any());
326331
}
327332

333+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
328334
public void testMissingNativeComponentCausesNoReports() {
329335
final CrashlyticsController controller = createController();
330336
controller.finalizeSessions(testSettingsProvider);
@@ -341,6 +347,7 @@ public void testMissingNativeComponentCausesNoReports() {
341347
* it to throw exceptions!
342348
*/
343349
// FIXME: Validate this test is working as intended
350+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
344351
public void testLoggedExceptionsAfterCrashOk() {
345352
final CrashlyticsController controller = builder().build();
346353
controller.handleUncaughtException(
@@ -355,6 +362,7 @@ public void testLoggedExceptionsAfterCrashOk() {
355362
* it to throw exceptions!
356363
*/
357364
// FIXME: Validate this test works as intended
365+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
358366
public void testLogStringAfterCrashOk() {
359367
final CrashlyticsController controller = builder().build();
360368
controller.handleUncaughtException(
@@ -369,6 +377,7 @@ public void testLogStringAfterCrashOk() {
369377
* it to throw exceptions!
370378
*/
371379
// FIXME: Validate this test works as intended
380+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
372381
public void testFinalizeSessionAfterCrashOk() throws Exception {
373382
final CrashlyticsController controller = builder().build();
374383
controller.handleUncaughtException(
@@ -378,6 +387,7 @@ public void testFinalizeSessionAfterCrashOk() throws Exception {
378387
controller.finalizeSessions(testSettingsProvider);
379388
}
380389

390+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
381391
public void testUploadWithNoReports() throws Exception {
382392
when(mockSessionReportingCoordinator.hasReportsToSend()).thenReturn(false);
383393

@@ -391,6 +401,7 @@ public void testUploadWithNoReports() throws Exception {
391401
verifyNoMoreInteractions(mockSessionReportingCoordinator);
392402
}
393403

404+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
394405
public void testUploadWithDataCollectionAlwaysEnabled() throws Exception {
395406
when(mockSessionReportingCoordinator.hasReportsToSend()).thenReturn(true);
396407
when(mockSessionReportingCoordinator.sendReports(any(Executor.class)))
@@ -408,6 +419,7 @@ public void testUploadWithDataCollectionAlwaysEnabled() throws Exception {
408419
verifyNoMoreInteractions(mockSessionReportingCoordinator);
409420
}
410421

422+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
411423
public void testUploadDisabledThenOptIn() throws Exception {
412424
when(mockSessionReportingCoordinator.hasReportsToSend()).thenReturn(true);
413425
when(mockSessionReportingCoordinator.sendReports(any(Executor.class)))
@@ -437,6 +449,7 @@ public void testUploadDisabledThenOptIn() throws Exception {
437449
verifyNoMoreInteractions(mockSessionReportingCoordinator);
438450
}
439451

452+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
440453
public void testUploadDisabledThenOptOut() throws Exception {
441454
when(mockSessionReportingCoordinator.hasReportsToSend()).thenReturn(true);
442455
when(mockSessionReportingCoordinator.sendReports(any(Executor.class)))
@@ -464,6 +477,7 @@ public void testUploadDisabledThenOptOut() throws Exception {
464477
verifyNoMoreInteractions(mockSessionReportingCoordinator);
465478
}
466479

480+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
467481
public void testUploadDisabledThenEnabled() throws Exception {
468482
when(mockSessionReportingCoordinator.hasReportsToSend()).thenReturn(true);
469483
when(mockSessionReportingCoordinator.sendReports(any(Executor.class)))
@@ -520,6 +534,7 @@ public void testUploadDisabledThenEnabled() throws Exception {
520534
verifyNoMoreInteractions(mockSessionReportingCoordinator);
521535
}
522536

537+
@SdkSuppress(minSdkVersion = 30) // ApplicationExitInfo
523538
public void testFatalEvent_sendsAppExceptionEvent() {
524539
final String sessionId = "sessionId";
525540
final LogFileManager logFileManager = new LogFileManager(testFileStore);

0 commit comments

Comments
 (0)