Skip to content

Commit ffd2c3c

Browse files
Merge a7b38d4 into 0132cdd
2 parents 0132cdd + a7b38d4 commit ffd2c3c

File tree

8 files changed

+152
-1
lines changed

8 files changed

+152
-1
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ apiValidation {
7070
"sentry-uitest-android-benchmark",
7171
"test-app-plain",
7272
"test-app-sentry",
73-
"sentry-samples-netflix-dgs"
73+
"sentry-samples-netflix-dgs",
74+
"sentry-uitest-android-critical"
7475
)
7576
)
7677
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/maestro-logs
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import io.gitlab.arturbosch.detekt.Detekt
2+
3+
plugins {
4+
id("com.android.application")
5+
kotlin("android")
6+
}
7+
8+
android {
9+
compileSdk = Config.Android.compileSdkVersion
10+
namespace = "io.sentry.uitest.android.critical"
11+
12+
defaultConfig {
13+
applicationId = "io.sentry.uitest.android.critical"
14+
minSdk = 21
15+
targetSdk = Config.Android.targetSdkVersion
16+
versionCode = 1
17+
versionName = "1.0"
18+
}
19+
20+
buildTypes {
21+
release {
22+
isMinifyEnabled = false
23+
proguardFiles(
24+
getDefaultProguardFile("proguard-android-optimize.txt"),
25+
"proguard-rules.pro"
26+
)
27+
}
28+
}
29+
kotlinOptions {
30+
jvmTarget = JavaVersion.VERSION_1_8.toString()
31+
}
32+
buildFeatures {
33+
compose = true
34+
}
35+
composeOptions {
36+
kotlinCompilerExtensionVersion = Config.androidComposeCompilerVersion
37+
}
38+
}
39+
40+
dependencies {
41+
implementation(kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION))
42+
implementation(Config.Libs.androidxCore)
43+
implementation(Config.Libs.composeActivity)
44+
implementation(Config.Libs.composeFoundation)
45+
implementation(Config.Libs.composeMaterial)
46+
implementation(Config.Libs.constraintLayout)
47+
implementation(projects.sentryAndroidCore)
48+
}
49+
50+
tasks.withType<Detekt> {
51+
// Target version of the generated JVM bytecode. It is used for type resolution.
52+
jvmTarget = JavaVersion.VERSION_1_8.toString()
53+
}
54+
55+
kotlin {
56+
explicitApi()
57+
}
58+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
appId: io.sentry.uitest.android.critical
2+
---
3+
- launchApp
4+
- tapOn: "Write Corrupted Envelope"
5+
# The close here ensures the next corrupted envelope
6+
# will be present on the next app launch
7+
- tapOn: "Close SDK"
8+
- tapOn: "Write Corrupted Envelope"
9+
- stopApp
10+
- launchApp
11+
- assertVisible: "Welcome!"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
appId: io.sentry.uitest.android.critical
2+
---
3+
- launchApp
4+
- tapOn: "Crash"
5+
- launchApp
6+
- assertVisible: "Welcome!"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:label="Sentry UI Tests Critical"
7+
android:supportsRtl="true"
8+
tools:targetApi="31">
9+
<meta-data android:name="io.sentry.dsn" android:value="https://[email protected]/5428559" />
10+
<meta-data android:name="io.sentry.debug" android:value="true" />
11+
<activity
12+
android:name=".MainActivity"
13+
android:exported="true">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.sentry.uitest.android.critical
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.foundation.layout.Column
7+
import androidx.compose.material3.Button
8+
import androidx.compose.material3.MaterialTheme
9+
import androidx.compose.material3.Surface
10+
import androidx.compose.material3.Text
11+
import io.sentry.Sentry
12+
import java.io.File
13+
14+
class MainActivity : ComponentActivity() {
15+
override fun onCreate(savedInstanceState: Bundle?) {
16+
super.onCreate(savedInstanceState)
17+
val outboxPath = Sentry.getCurrentHub().options.outboxPath
18+
?: throw RuntimeException("Outbox path is not set.")
19+
20+
setContent {
21+
MaterialTheme {
22+
Surface() {
23+
Column() {
24+
Text(text = "Welcome!")
25+
Button(onClick = {
26+
throw RuntimeException("Crash the test app.")
27+
}) {
28+
Text("Crash")
29+
}
30+
Button(onClick = {
31+
Sentry.close()
32+
}) {
33+
Text("Close SDK")
34+
}
35+
Button(onClick = {
36+
val file = File(outboxPath, "corrupted.envelope")
37+
val corruptedEnvelopeContent = """
38+
{"event_id":"1990b5bc31904b7395fd07feb72daf1c","sdk":{"name":"sentry.java.android","version":"7.21.0"}}
39+
{"type":"test","length":50}
40+
""".trimIndent()
41+
file.writeText(corruptedEnvelopeContent)
42+
println("Wrote corrupted envelope to: ${file.absolutePath}")
43+
}) {
44+
Text("Write Corrupted Envelope")
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ include(
6161
"sentry-samples:sentry-samples-spring-boot-webflux",
6262
"sentry-samples:sentry-samples-spring-boot-webflux-jakarta",
6363
"sentry-samples:sentry-samples-netflix-dgs",
64+
"sentry-android-integration-tests:sentry-uitest-android-critical",
6465
"sentry-android-integration-tests:sentry-uitest-android-benchmark",
6566
"sentry-android-integration-tests:sentry-uitest-android",
6667
"sentry-android-integration-tests:test-app-plain",

0 commit comments

Comments
 (0)