@@ -244,47 +244,41 @@ test('discards a retained physical iOS runner when relaunch fails and preserves
244244 expect ( notifyRunnerAppRelaunched ) . not . toHaveBeenCalled ( ) ;
245245} ) ;
246246
247- test ( 'close finalization stops a busy retained runner instead of pooling it back (#2552)' , async ( ) => {
248- const signal = new AbortController ( ) . signal ;
249- const baseHost = platformRuntimeHostFixture ( ) ;
250- const stopRunnerSessionIfBusy = vi . fn ( async ( ) => true ) ;
251- const stopRunnerSession = vi . fn ( async ( ) => { } ) ;
252- const scheduleRunnerIdleStop = vi . fn ( ) ;
253- const host = {
254- ... baseHost ,
255- appleApplications : {
256- ... baseHost . appleApplications ,
257- stopRunnerSessionIfBusy ,
258- stopRunnerSession ,
259- scheduleRunnerIdleStop ,
260- } ,
261- } as unknown as PlatformRuntimeHost ;
262- const lifecycle = bindAppleApplicationLifecycle ( { host, device, signal } ) ;
247+ test . each ( [ true , false ] ) (
248+ 'close finalization delegates the runner release to the runner module with retain=%s (#2552)' ,
249+ async ( retainRunner ) => {
250+ const signal = new AbortController ( ) . signal ;
251+ const baseHost = platformRuntimeHostFixture ( ) ;
252+ const releaseRunnerOnClose = vi . fn ( async ( ) => { } ) ;
253+ const dismissCloseAlerts = vi . fn ( async ( ) => { } ) ;
254+ const host = {
255+ ... baseHost ,
256+ appleApplications : {
257+ ... baseHost . appleApplications ,
258+ releaseRunnerOnClose ,
259+ dismissCloseAlerts ,
260+ } ,
261+ } as unknown as PlatformRuntimeHost ;
262+ const lifecycle = bindAppleApplicationLifecycle ( { host, device, signal } ) ;
263263
264- await lifecycle . finalizeApplicationClose ( {
265- surface : 'app' ,
266- retainRunner : true ,
267- stateDir : '/tmp' ,
268- } ) ;
264+ await lifecycle . finalizeApplicationClose ( { surface : 'app' , retainRunner, stateDir : '/tmp' } ) ;
269265
270- expect ( stopRunnerSessionIfBusy ) . toHaveBeenCalledWith ( device . id ) ;
271- expect ( scheduleRunnerIdleStop ) . not . toHaveBeenCalled ( ) ;
272- expect ( stopRunnerSession ) . not . toHaveBeenCalled ( ) ;
273- } ) ;
266+ expect ( releaseRunnerOnClose ) . toHaveBeenCalledWith ( device . id , { retain : retainRunner } ) ;
267+ expect ( dismissCloseAlerts ) . toHaveBeenCalled ( ) ;
268+ } ,
269+ ) ;
274270
275- test ( 'close finalization retains an idle runner and schedules its idle stop ' , async ( ) => {
271+ test ( 'daemon-shutdown finalization dismisses alerts and defers the runner release to the gateway (#2552) ' , async ( ) => {
276272 const signal = new AbortController ( ) . signal ;
277273 const baseHost = platformRuntimeHostFixture ( ) ;
278- const stopRunnerSessionIfBusy = vi . fn ( async ( ) => false ) ;
279- const stopRunnerSession = vi . fn ( async ( ) => { } ) ;
280- const scheduleRunnerIdleStop = vi . fn ( ) ;
274+ const releaseRunnerOnClose = vi . fn ( async ( ) => { } ) ;
275+ const dismissCloseAlerts = vi . fn ( async ( ) => { } ) ;
281276 const host = {
282277 ...baseHost ,
283278 appleApplications : {
284279 ...baseHost . appleApplications ,
285- stopRunnerSessionIfBusy,
286- stopRunnerSession,
287- scheduleRunnerIdleStop,
280+ releaseRunnerOnClose,
281+ dismissCloseAlerts,
288282 } ,
289283 } as unknown as PlatformRuntimeHost ;
290284 const lifecycle = bindAppleApplicationLifecycle ( { host, device, signal } ) ;
@@ -293,36 +287,11 @@ test('close finalization retains an idle runner and schedules its idle stop', as
293287 surface : 'app' ,
294288 retainRunner : true ,
295289 stateDir : '/tmp' ,
290+ daemonShutdown : true ,
296291 } ) ;
297292
298- expect ( stopRunnerSessionIfBusy ) . toHaveBeenCalledWith ( device . id ) ;
299- expect ( scheduleRunnerIdleStop ) . toHaveBeenCalledWith ( device . id ) ;
300- expect ( stopRunnerSession ) . not . toHaveBeenCalled ( ) ;
301- } ) ;
302-
303- test ( 'close finalization stops a non-retained runner without the busy probe' , async ( ) => {
304- const signal = new AbortController ( ) . signal ;
305- const baseHost = platformRuntimeHostFixture ( ) ;
306- const stopRunnerSessionIfBusy = vi . fn ( async ( ) => true ) ;
307- const stopRunnerSession = vi . fn ( async ( ) => { } ) ;
308- const host = {
309- ...baseHost ,
310- appleApplications : {
311- ...baseHost . appleApplications ,
312- stopRunnerSessionIfBusy,
313- stopRunnerSession,
314- } ,
315- } as unknown as PlatformRuntimeHost ;
316- const lifecycle = bindAppleApplicationLifecycle ( { host, device, signal } ) ;
317-
318- await lifecycle . finalizeApplicationClose ( {
319- surface : 'app' ,
320- retainRunner : false ,
321- stateDir : '/tmp' ,
322- } ) ;
323-
324- expect ( stopRunnerSessionIfBusy ) . not . toHaveBeenCalled ( ) ;
325- expect ( stopRunnerSession ) . toHaveBeenCalledWith ( device . id ) ;
293+ expect ( releaseRunnerOnClose ) . not . toHaveBeenCalled ( ) ;
294+ expect ( dismissCloseAlerts ) . toHaveBeenCalled ( ) ;
326295} ) ;
327296
328297test ( 'prepare shares one startup budget across the Simulator boot and the runner preparation' , async ( ) => {
0 commit comments