Skip to content

Commit

Permalink
Disable ANR detection by default: Add maze scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed May 20, 2019
1 parent 5b1b383 commit fa29303
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions features/detect_anr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ Scenario: Test ANR wait time can be set to under default time
Scenario: Test ANR wait time can be set to over default time
When I run "AppNotRespondingLongerThresholdScenario"
Then I should receive 0 requests

Scenario: Test does not capture ANRs by default
When I run "AppNotRespondingDefaultsScenario"
Then I should receive 0 requests
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ class MainActivity : Activity() {
}

private fun prepareConfig(): Configuration {
val eventType = intent.getStringExtra("EVENT_TYPE")
val config = Configuration(intent.getStringExtra("BUGSNAG_API_KEY"))
val port = intent.getStringExtra("BUGSNAG_PORT")
config.setEndpoints("${findHostname()}:$port", "${findHostname()}:$port")
config.detectAnrs = false

// Added to stop override of the default ANR state
if (eventType != "AppNotRespondingDefaultsScenario") {
config.detectAnrs = false
}
return config
}

Expand Down
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 com.bugsnag.android.Bugsnag
import com.bugsnag.android.Configuration

/**
* Stops the app from responding for a time period
*/
internal class AppNotRespondingDefaultsScenario(config: Configuration,
context: Context) : Scenario(config, context) {
init {
config.setAutoCaptureSessions(false)
}

override fun run() {
super.run()
Thread.sleep(6000)
}

}

0 comments on commit fa29303

Please sign in to comment.