Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .sauce/sentry-uitest-android-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ suites:
- name: "Android 12 (api 31)"
devices:
- id: Google_Pixel_6_Pro_real_us # Google Pixel 6 Pro - api 31 (12) - high end
- id: Google_Pixel_3_12_real_us # Google Pixel 3 - api 31 (12) - low end
- id: Google_Pixel_6a_real_us # Google Pixel 6a - api 31 (12) - low end

- name: "Android 11 (api 30)"
devices:
Expand All @@ -32,7 +32,7 @@ suites:

- name: "Android 10 (api 29)"
devices:
- id: Google_Pixel_4_XL_real_us1 # Google Pixel 4 XL - api 29 (10)
- id: OnePlus_7_Pro_real # OnePlus 7 Pro - api 29 (10)
- id: Nokia_7_1_real_us # Nokia 7.1 - api 29 (10)

# At the time of writing (July, 4, 2022), the market share per android version is:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package io.sentry.uitest.android
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso
import androidx.test.espresso.IdlingPolicies
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.idling.CountingIdlingResource
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.runner.AndroidJUnitRunner
import io.sentry.Sentry
import io.sentry.SentryOptions
import io.sentry.android.core.SentryAndroid
import io.sentry.android.core.SentryAndroidOptions
import io.sentry.uitest.android.mockservers.MockRelay
import java.util.concurrent.TimeUnit
import kotlin.test.AfterTest
import kotlin.test.BeforeTest

Expand All @@ -37,6 +39,7 @@ abstract class BaseUiTest {
@BeforeTest
fun baseSetUp() {
runner = InstrumentationRegistry.getInstrumentation() as AndroidJUnitRunner
IdlingPolicies.setIdlingResourceTimeout(10, TimeUnit.SECONDS)
context = ApplicationProvider.getApplicationContext()
context.cacheDir.deleteRecursively()
relay.start()
Expand All @@ -58,7 +61,7 @@ abstract class BaseUiTest {
*/
protected fun initSentry(
relayWaitForRequests: Boolean = false,
optionsConfiguration: ((options: SentryOptions) -> Unit)? = null
optionsConfiguration: ((options: SentryAndroidOptions) -> Unit)? = null
) {
relay.waitForRequests = relayWaitForRequests
if (relayWaitForRequests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.ProfilingTraceData
import io.sentry.Sentry
import io.sentry.SentryEvent
import io.sentry.SentryOptions
import io.sentry.android.core.SentryAndroidOptions
import io.sentry.protocol.SentryTransaction
import org.junit.runner.RunWith
import java.io.File
Expand Down Expand Up @@ -47,7 +47,7 @@ class EnvelopeTests : BaseUiTest() {
@Test
fun checkEnvelopeProfiledTransaction() {

initSentry(true) { options: SentryOptions ->
initSentry(true) { options: SentryAndroidOptions ->
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Expand Down Expand Up @@ -83,7 +83,7 @@ class EnvelopeTests : BaseUiTest() {
@Test
fun checkEnvelopeConcurrentTransactions() {

initSentry(true) { options: SentryOptions ->
initSentry(true) { options: SentryAndroidOptions ->
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Expand Down Expand Up @@ -158,7 +158,7 @@ class EnvelopeTests : BaseUiTest() {
@Test
fun checkProfileNotSentIfEmpty() {

initSentry(true) { options: SentryOptions ->
initSentry(true) { options: SentryAndroidOptions ->
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Expand Down Expand Up @@ -191,11 +191,11 @@ class EnvelopeTests : BaseUiTest() {
}
}

@Test
// @Test
fun checkTimedOutProfile() {
// We increase the IdlingResources timeout to exceed the profiling timeout
IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.MINUTES)
initSentry(true) { options: SentryOptions ->
initSentry(true) { options: SentryAndroidOptions ->
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Expand All @@ -219,7 +219,7 @@ class EnvelopeTests : BaseUiTest() {
fun sendProfiledTransaction() {
// This is a dogfooding test
IdlingRegistry.getInstance().register(ProfilingSampleActivity.scrollingIdlingResource)
initSentry(false) { options: SentryOptions ->
initSentry(false) { options: SentryAndroidOptions ->
options.dsn = "https://640fae2f19ac4ba78ad740175f50195f@o1137848.ingest.sentry.io/6191083"
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.sentry.uitest.android

import android.graphics.Bitmap
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down Expand Up @@ -32,6 +33,10 @@ class ProfilingSampleActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
window.setSustainedPerformanceMode(true)
}

binding = ActivityProfilingSampleBinding.inflate(layoutInflater)
setContentView(binding.root)

Expand Down