-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
176 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...r/src/main/java/com/bugsnag/android/mazerunner/scenarios/SessionSetAutoCaptureScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.SecondActivity | ||
|
||
/** | ||
* Sets automatic capture of sessions in Bugsnag and flushes 1 session | ||
*/ | ||
internal class SessionSetAutoCaptureScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
Bugsnag.setAutoCaptureSessions(true) | ||
context.startActivity(Intent(context, SecondActivity::class.java)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
sdk/src/androidTest/java/com/bugsnag/android/ClientNotifyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.bugsnag.android; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import android.support.test.filters.SmallTest; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Map; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@SmallTest | ||
public class ClientNotifyTest { | ||
|
||
private Client client; | ||
private FakeClient apiClient; | ||
|
||
/** | ||
* Generates a configuration and clears sharedPrefs values to begin the test with a clean slate | ||
* @throws Exception if initialisation failed | ||
*/ | ||
@Before | ||
public void setUp() throws Exception { | ||
client = BugsnagTestUtils.generateClient(); | ||
apiClient = new FakeClient(); | ||
client.setErrorReportApiClient(apiClient); | ||
} | ||
|
||
@Test | ||
public void testNotifyBlockingDefaultSeverity() { | ||
client.notifyBlocking(new RuntimeException("Testing")); | ||
assertEquals(Severity.WARNING, apiClient.report.getError().getSeverity()); | ||
} | ||
|
||
@Test | ||
public void testNotifyBlockingCallback() { | ||
client.notifyBlocking(new RuntimeException("Testing"), new Callback() { | ||
@Override | ||
public void beforeNotify(Report report) { | ||
report.getError().setUserName("Foo"); | ||
} | ||
}); | ||
Error error = apiClient.report.getError(); | ||
assertEquals(Severity.WARNING, error.getSeverity()); | ||
assertEquals("Foo", error.getUser().getName()); | ||
} | ||
|
||
@Test | ||
public void testNotifyBlockingCustomSeverity() { | ||
client.notifyBlocking(new RuntimeException("Testing"), Severity.INFO); | ||
assertEquals(Severity.INFO, apiClient.report.getError().getSeverity()); | ||
} | ||
|
||
@Test | ||
public void testNotifyBlockingCustomStackTrace() { | ||
StackTraceElement[] stacktrace = { | ||
new StackTraceElement("MyClass", "MyMethod", "MyFile", 5) | ||
}; | ||
|
||
client.notifyBlocking("Name", "Message", stacktrace, new Callback() { | ||
@Override | ||
public void beforeNotify(Report report) { | ||
report.getError().setSeverity(Severity.ERROR); | ||
} | ||
}); | ||
Error error = apiClient.report.getError(); | ||
assertEquals(Severity.ERROR, error.getSeverity()); | ||
assertEquals("Name", error.getExceptionName()); | ||
assertEquals("Message", error.getExceptionMessage()); | ||
} | ||
|
||
static class FakeClient implements ErrorReportApiClient { | ||
Report report; | ||
|
||
@Override | ||
public void postReport(String urlString, | ||
Report report, | ||
Map<String, String> headers) | ||
throws NetworkException, BadResponseException { | ||
this.report = report; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters