@@ -379,7 +379,7 @@ test('boot --headless launches Android emulator when no running device matches',
379379 session : 'default' ,
380380 command : 'boot' ,
381381 positionals : [ ] ,
382- flags : { platform : 'android' , target : 'mobile' , device : 'Pixel_9_Pro_XL' , headless : true } ,
382+ flags : { platform : 'android' , device : 'Pixel_9_Pro_XL' , headless : true } ,
383383 } ,
384384 sessionName : 'default' ,
385385 logPath : path . join ( os . tmpdir ( ) , 'daemon.log' ) ,
@@ -391,6 +391,7 @@ test('boot --headless launches Android emulator when no running device matches',
391391 resolveTargetDevice : async ( ) => {
392392 throw new AppError ( 'DEVICE_NOT_FOUND' , 'No devices found' ) ;
393393 } ,
394+ resolveAndroidBootSelectorDevice : async ( ) => undefined ,
394395 ensureAndroidEmulatorBoot : async ( { avdName, serial, headless } ) => {
395396 launchCalls . push ( { avdName, serial, headless } ) ;
396397 return {
@@ -424,7 +425,7 @@ test('boot launches Android emulator with GUI when no running device matches', a
424425 session : 'default' ,
425426 command : 'boot' ,
426427 positionals : [ ] ,
427- flags : { platform : 'android' , target : 'mobile' , device : 'Pixel_9_Pro_XL' } ,
428+ flags : { platform : 'android' , device : 'Pixel_9_Pro_XL' } ,
428429 } ,
429430 sessionName : 'default' ,
430431 logPath : path . join ( os . tmpdir ( ) , 'daemon.log' ) ,
@@ -434,6 +435,7 @@ test('boot launches Android emulator with GUI when no running device matches', a
434435 resolveTargetDevice : async ( ) => {
435436 throw new AppError ( 'DEVICE_NOT_FOUND' , 'No devices found' ) ;
436437 } ,
438+ resolveAndroidBootSelectorDevice : async ( ) => undefined ,
437439 ensureAndroidEmulatorBoot : async ( { avdName, serial, headless } ) => {
438440 launchCalls . push ( { avdName, serial, headless } ) ;
439441 return {
@@ -466,7 +468,7 @@ test('boot --headless requires avd selector when device cannot be resolved', asy
466468 session : 'default' ,
467469 command : 'boot' ,
468470 positionals : [ ] ,
469- flags : { platform : 'android' , target : 'mobile' , serial : 'emulator-5554' , headless : true } ,
471+ flags : { platform : 'android' , serial : 'emulator-5554' , headless : true } ,
470472 } ,
471473 sessionName : 'default' ,
472474 logPath : path . join ( os . tmpdir ( ) , 'daemon.log' ) ,
@@ -476,6 +478,7 @@ test('boot --headless requires avd selector when device cannot be resolved', asy
476478 resolveTargetDevice : async ( ) => {
477479 throw new AppError ( 'DEVICE_NOT_FOUND' , 'No devices found' ) ;
478480 } ,
481+ resolveAndroidBootSelectorDevice : async ( ) => undefined ,
479482 ensureAndroidEmulatorBoot : async ( ) => {
480483 bootCalled = true ;
481484 throw new Error ( 'unexpected' ) ;
@@ -491,6 +494,45 @@ test('boot --headless requires avd selector when device cannot be resolved', asy
491494 }
492495} ) ;
493496
497+ test ( 'boot uses fast Android selector lookup for already booted device' , async ( ) => {
498+ const sessionStore = makeSessionStore ( ) ;
499+ let ensureCalls = 0 ;
500+ const response = await handleSessionCommands ( {
501+ req : {
502+ token : 't' ,
503+ session : 'default' ,
504+ command : 'boot' ,
505+ positionals : [ ] ,
506+ flags : { platform : 'android' , device : 'Pixel 9 Pro XL' } ,
507+ } ,
508+ sessionName : 'default' ,
509+ logPath : path . join ( os . tmpdir ( ) , 'daemon.log' ) ,
510+ sessionStore,
511+ invoke : noopInvoke ,
512+ ensureReady : async ( ) => {
513+ ensureCalls += 1 ;
514+ } ,
515+ resolveTargetDevice : async ( ) => {
516+ throw new Error ( 'resolveTargetDevice should not be called when fast lookup succeeds' ) ;
517+ } ,
518+ resolveAndroidBootSelectorDevice : async ( ) => ( {
519+ platform : 'android' ,
520+ id : 'emulator-5554' ,
521+ name : 'Pixel 9 Pro XL' ,
522+ kind : 'emulator' ,
523+ target : 'mobile' ,
524+ booted : true ,
525+ } ) ,
526+ } ) ;
527+ assert . ok ( response ) ;
528+ assert . equal ( response ?. ok , true ) ;
529+ assert . equal ( ensureCalls , 0 ) ;
530+ if ( response && response . ok ) {
531+ assert . equal ( response . data ?. platform , 'android' ) ;
532+ assert . equal ( response . data ?. id , 'emulator-5554' ) ;
533+ }
534+ } ) ;
535+
494536test ( 'appstate on iOS requires active session on selected device' , async ( ) => {
495537 const sessionStore = makeSessionStore ( ) ;
496538 const sessionName = 'default' ;
0 commit comments