@@ -54,14 +54,17 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
5454 {
5555 param (
5656 [string ] $Dsn ,
57- [string ] $TestArg = ' None'
57+ [string ] $TestArg = ' None' ,
58+ [string ] $TestCondition = ' OnAppearing' ,
59+ [scriptblock ] $Callback = $null
5860 )
5961 Write-Host " ::group::Run Android app (TestArg=$TestArg )"
6062 $dsn = $Dsn.Replace (' http://' , ' http://key@' ) + ' /0'
6163 xharness android adb - v `
6264 -- shell am start - S - n io.sentry.dotnet.maui.device.integrationtestapp/ .MainActivity `
6365 - e SENTRY_DSN $dsn `
64- - e SENTRY_TEST_ARG $TestArg
66+ - e SENTRY_TEST_ARG $TestArg `
67+ - e SENTRY_TEST_CONDITION $TestCondition
6568 | ForEach-Object { Write-Host $_ }
6669 Write-Host ' ::endgroup::'
6770 $LASTEXITCODE | Should - Be 0
@@ -73,7 +76,10 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
7376
7477 $procid = (& xharness android adb -- shell pidof " io.sentry.dotnet.maui.device.integrationtestapp" ) -replace ' \s' , ' '
7578 $activity = (& xharness android adb -- shell dumpsys activity activities) -match " io\.sentry\.dotnet\.maui\.device\.integrationtestapp"
76-
79+ if ($procid -and $activity -and $Callback )
80+ {
81+ & $Callback
82+ }
7783 } while ($procid -and $activity )
7884 }
7985
@@ -202,16 +208,36 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
202208 $result.Envelopes () | Should - HaveCount 1
203209 }
204210
205- It ' Lifecycle events (<configuration>)' {
211+ It ' Native native lifecycle events' {
212+ $result = Invoke-SentryServer {
213+ param ([string ]$url )
214+ RunAndroidApp - Dsn $url - TestArg $type - TestCondition " OnSleep" {
215+ xharness android adb -- shell input keyevent KEYCODE_HOME
216+ }
217+ RunAndroidApp - Dsn $url
218+ }
219+
220+ Dump- ServerErrors - Result $result
221+ $result.HasErrors () | Should - BeFalse
222+ @ (' created' , ' started' , ' resumed' , ' paused' ) | ForEach-Object {
223+ # TODO: why is native breadcrumb data a string instead of object?
224+ $result.Envelopes () | Should - AnyElementMatch (' "type":"navigation","data":"{\"screen\":\"MainActivity\",\"state\":\"' + $_ + ' \"}\","category":"ui.lifecycle"' )
225+ }
226+ $result.Envelopes () | Should - HaveCount 1
227+ }
228+
229+ It ' Managed lifecycle events' {
206230 $result = Invoke-SentryServer {
207231 param ([string ]$url )
208- RunAndroidApp - Dsn $url - TestArg " Background"
232+ RunAndroidApp - Dsn $url - TestArg $type - TestCondition " OnSleep" {
233+ xharness android adb -- shell input keyevent KEYCODE_HOME
234+ }
209235 }
210236
211237 Dump- ServerErrors - Result $result
212238 $result.HasErrors () | Should - BeFalse
213- @ (' created' , ' started' , ' resumed' , ' paused' , ' stopped ' ) | ForEach-Object {
214- $result.Envelopes () | Should - AnyElementMatch " `" type`" : ` " navigation`" , ` " data` " :{` " screen`" : ` " MainActivity`" , ` " state`" : `" $_ ` " },` " category`" : ` " ui.lifecycle`" "
239+ @ (' created' , ' started' , ' resumed' , ' paused' ) | ForEach-Object {
240+ $result.Envelopes () | Should - AnyElementMatch ( ' " type": "navigation", "data":{"screen": "MainActivity", "state":" ' + $_ + ' "},"category": "ui.lifecycle" ' )
215241 }
216242 $result.Envelopes () | Should - HaveCount 1
217243 }
0 commit comments