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
fee3c43
commit 7b80c02
Showing
3 changed files
with
58 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,18 @@ | ||
Feature: Android support | ||
|
||
Scenario: Test Unhandled Android Exception with Session | ||
When I run "SessionCacheScenario" with the defaults | ||
Then I should receive no requests | ||
|
||
When I force stop the "com.bugsnag.android.mazerunner" Android app | ||
And I set environment variable "EVENT_TYPE" to "Wait" | ||
And I start the "com.bugsnag.android.mazerunner" Android app using the "com.bugsnag.android.mazerunner.MainActivity" activity | ||
Then I should receive a request | ||
|
||
And the request is a valid for the session tracking API | ||
And the payload field "sessions" is an array with 1 element | ||
And the session "user.id" equals "123" | ||
And the session "user.email" equals "user@example.com" | ||
And the session "user.name" equals "Joe Bloggs" | ||
And the session "id" is not null | ||
And the session "startedAt" is not null |
20 changes: 20 additions & 0 deletions
20
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/SessionCacheScenario.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 | ||
|
||
/** | ||
* Sends a session which is cached on disk to Bugsnag, then sent on a separate launch. | ||
*/ | ||
internal class SessionCacheScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
Bugsnag.setUser("123", "user@example.com", "Joe Bloggs") | ||
Bugsnag.startSession() | ||
disableSessionDelivery() | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/Wait.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 android.os.Handler | ||
import android.os.HandlerThread | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.flushAllSessions | ||
|
||
internal class Wait(config: Configuration, context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
val thread = HandlerThread("HandlerThread") | ||
thread.start() | ||
Handler(thread.looper).post { | ||
flushAllSessions() | ||
} | ||
} | ||
|
||
} |