use of org.acra.data.CrashReportDataFactory in project AnkiChinaAndroid by ankichinateam.
the class ACRATest method testCrashReportLimit.
@Test
public void testCrashReportLimit() throws Exception {
// To test ACRA switch on reporting, plant a production tree, and trigger a report
Timber.plant(new AnkiDroidApp.ProductionCrashReportingTree());
// set up as if the user had prefs saved to full auto
setReportConfig(FEEDBACK_REPORT_ALWAYS);
// If the user is set to always, then it's production, with interaction mode toast
// will be useful with ACRA 5.2.0
setAcraConfig("Production");
// The same class/method combo is only sent once, so we face a new method each time (should test that system later)
Exception crash = new Exception("testCrashReportSend at " + System.currentTimeMillis());
StackTraceElement[] trace = new StackTraceElement[] { new StackTraceElement("Class", "Method" + (int) System.currentTimeMillis(), "File", (int) System.currentTimeMillis()) };
crash.setStackTrace(trace);
// one send should work
CrashReportData crashData = new CrashReportDataFactory(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build()).createCrashData(new ReportBuilder().exception(crash));
assertTrue(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// A second send should not work
assertFalse(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// Now let's clear data
AnkiDroidApp.deleteACRALimiterData(InstrumentationRegistry.getInstrumentation().getTargetContext());
// A third send should work again
assertTrue(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
}
use of org.acra.data.CrashReportDataFactory in project Anki-Android by ankidroid.
the class ACRATest method testCrashReportLimit.
@Test
public void testCrashReportLimit() throws Exception {
// To test ACRA switch on reporting, plant a production tree, and trigger a report
Timber.plant(new AnkiDroidApp.ProductionCrashReportingTree());
// set up as if the user had prefs saved to full auto
setReportConfig(FEEDBACK_REPORT_ALWAYS);
// If the user is set to always, then it's production, with interaction mode toast
// will be useful with ACRA 5.2.0
setAcraConfig("Production");
// The same class/method combo is only sent once, so we face a new method each time (should test that system later)
Exception crash = new Exception("testCrashReportSend at " + System.currentTimeMillis());
StackTraceElement[] trace = new StackTraceElement[] { new StackTraceElement("Class", "Method" + (int) System.currentTimeMillis(), "File", (int) System.currentTimeMillis()) };
crash.setStackTrace(trace);
// one send should work
CrashReportData crashData = new CrashReportDataFactory(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build()).createCrashData(new ReportBuilder().exception(crash));
assertTrue(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// A second send should not work
assertFalse(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// Now let's clear data
AnkiDroidApp.deleteACRALimiterData(getTestContext());
// A third send should work again
assertTrue(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
}
Aggregations