@@ -3880,6 +3880,54 @@ describe("AndroidDriver emulator registration", () => {
38803880} ) ;
38813881
38823882describe ( "AndroidDriver console ports across a restart" , ( ) => {
3883+ it . each ( [ "shutdown" , "full reclaim" , "standard reclaim" ] as const ) (
3884+ "%s after a restart sends neither kill nor snapshot load to another device on the stored serial (#284)" ,
3885+ async ( operation ) => {
3886+ const spec = {
3887+ physical : false ,
3888+ model : "Pixel 5" ,
3889+ osVersion : "34" ,
3890+ platform : "android" ,
3891+ } as const ;
3892+ const filesystem = await androidFilesystem ( ) ;
3893+ const host = new EmulatorHost ( filesystem ) ;
3894+ const before = await createDriver ( filesystem , host . runner ( ) , { ids : [ "one" ] } ) ;
3895+ await before . resolveSpec ( spec ) ;
3896+ const stopped = await before . makeReady ( await before . provision ( spec ) ) ;
3897+ await before . shutdown ( stopped ) ;
3898+
3899+ const runner = new RecordingRunner ( host . runner ( ) ) ;
3900+ const after = await createDriver ( filesystem , runner , { ids : [ "two" ] } ) ;
3901+ await after . resolveSpec ( spec ) ;
3902+ const running = await after . makeReady ( await after . provision ( spec ) ) ;
3903+ expect ( running . address ) . toBe ( stopped . address ) ;
3904+ expect ( host . avdAnswering ( running . address ) ) . toBe ( "simlock_two" ) ;
3905+ const callStart = runner . calls . length ;
3906+
3907+ const action =
3908+ operation === "shutdown"
3909+ ? after . shutdown ( stopped )
3910+ : after . reclaim ( stopped , {
3911+ clean : operation === "full reclaim" ? "full" : "standard" ,
3912+ } ) ;
3913+ await action . then ( ( ) => undefined , driverCrashMessage ) ;
3914+
3915+ expect ( {
3916+ running : host . avdAnswering ( running . address ) ,
3917+ mutations : runner . calls
3918+ . slice ( callStart )
3919+ . filter (
3920+ ( call ) =>
3921+ call . command === binaries . adb &&
3922+ call . args [ 1 ] === running . address &&
3923+ ( call . args . slice ( 2 ) . join ( " " ) === "emu kill" ||
3924+ call . args . slice ( 2 , 6 ) . join ( " " ) === "emu avd snapshot load" ) ,
3925+ )
3926+ . map ( ( call ) => call . args ) ,
3927+ } ) . toEqual ( { running : "simlock_two" , mutations : [ ] } ) ;
3928+ } ,
3929+ ) ;
3930+
38833931 it ( "readies a stopped device and one provisioned after a restart each at an address its own emulator answers (#52)" , async ( ) => {
38843932 const spec = {
38853933 physical : false ,
@@ -6088,6 +6136,7 @@ const ADB_ANSWERS = new Map([
60886136 [ "shell getprop init.svc.bootanim" , "stopped\n" ] ,
60896137 [ "emu avd snapshot save simlock_clean_baseline" , "OK\n" ] ,
60906138 [ "emu avd snapshot list" , "simlock_clean_baseline\n" ] ,
6139+ [ "emu avd snapshot load simlock_clean_baseline" , "OK\n" ] ,
60916140] ) ;
60926141
60936142function consolePortOf ( serial : string | undefined ) : number {
0 commit comments