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
1 parent
9545c4f
commit c503f90
Showing
6 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Android support | ||
|
||
Scenario: Automatic Context Tracking | ||
When I run "AutoContextScenario" with the defaults | ||
And I wait for 3 seconds | ||
Then I should receive a request | ||
And the request is a valid for the error reporting API | ||
And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" | ||
And the exception "message" equals "AutoContextScenario" | ||
And the event "context" equals "SecondActivity" |
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,9 @@ | ||
Feature: Android support | ||
|
||
Scenario: Manual Context Tracking | ||
When I run "ManualContextScenario" with the defaults | ||
Then I should receive a request | ||
And the request is a valid for the error reporting API | ||
And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" | ||
And the exception "message" equals "ManualContextScenario" | ||
And the event "context" equals "FooContext" |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
</intent-filter> | ||
</activity> | ||
<activity android:name=".SecondActivity"/> | ||
</application> | ||
|
||
</manifest> |
13 changes: 13 additions & 0 deletions
13
mazerunner/src/main/java/com/bugsnag/android/mazerunner/SecondActivity.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,13 @@ | ||
package com.bugsnag.android.mazerunner | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
|
||
class SecondActivity : Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/AutoContextScenario.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,26 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.SecondActivity | ||
|
||
/** | ||
* Sends a handled exception to Bugsnag, which includes automatic context. | ||
*/ | ||
internal class AutoContextScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
context.startActivity(Intent(context, SecondActivity::class.java)) | ||
|
||
val a = context as Activity | ||
a.window.decorView.postDelayed({ | ||
Bugsnag.notify(generateException()) | ||
}, 2000) | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualContextScenario.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,20 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.scenarios.Scenario | ||
|
||
/** | ||
* Sends a handled exception to Bugsnag, which includes manual context. | ||
*/ | ||
internal class ManualContextScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
Bugsnag.setContext("FooContext") | ||
Bugsnag.notify(generateException()) | ||
} | ||
|
||
} |