-
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
1 parent
d0ff588
commit 045d97c
Showing
8 changed files
with
81 additions
and
5 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,9 @@ | ||
Feature: Android support | ||
|
||
Scenario: Test handled Android Exception | ||
When I run "StrictModeDiscScenario" with the defaults | ||
Then I should receive a request | ||
And the request is a valid for the error reporting API | ||
And the exception "errorClass" equals "android.os.StrictMode$StrictModeViolation" | ||
And the exception "message" equals "policy=262145 violation=1" | ||
And the event "metaData.StrictMode.Violation" equals "DiskWrite" |
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: Test handled Android Exception | ||
When I run "StrictModeNetworkScenario" with the defaults | ||
Then I should receive a request | ||
And the request is a valid for the error reporting API | ||
And the exception "errorClass" equals "android.os.StrictMode$StrictModeViolation" | ||
And the exception "message" equals "policy=262148 violation=4" | ||
And the event "metaData.StrictMode.Violation" equals "NetworkOperation" |
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
7 changes: 5 additions & 2 deletions
7
mazerunner/src/main/java/com/bugsnag/android/mazerunner/TestCaseFactory.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
3 changes: 3 additions & 0 deletions
3
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/Scenario.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
20 changes: 20 additions & 0 deletions
20
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/StrictModeDiscScenario.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.os.StrictMode | ||
import java.io.File | ||
|
||
/** | ||
* Generates a strictmode exception caused by writing to disc on main thread | ||
*/ | ||
internal class StrictModeDiscScenario : Scenario() { | ||
|
||
override fun run() { | ||
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder() | ||
.detectDiskWrites() | ||
.penaltyDeath() | ||
.build()) | ||
val file = File(context?.cacheDir, "fake") | ||
file.writeBytes("test".toByteArray()) | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...unner/src/main/java/com/bugsnag/android/mazerunner/scenarios/StrictModeNetworkScenario.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,23 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.os.StrictMode | ||
import java.net.HttpURLConnection | ||
import java.net.URL | ||
|
||
/** | ||
* Generates a strictmode exception caused by performing a network request on the main thread | ||
*/ | ||
internal class StrictModeNetworkScenario : Scenario() { | ||
|
||
override fun run() { | ||
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder() | ||
.detectNetwork() | ||
.penaltyDeath() | ||
.build()) | ||
|
||
val urlConnection = URL("http://example.com").openConnection() as HttpURLConnection | ||
urlConnection.doOutput = true | ||
urlConnection.responseMessage | ||
} | ||
|
||
} |
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